26 lines
No EOL
742 B
Zig
26 lines
No EOL
742 B
Zig
const std = @import("std");
|
|
const math = std.math;
|
|
const print = std.debug.print;
|
|
const Activity = @import ("../activity.zig").Activity;
|
|
const SoundNode = @import("../soundnode.zig").SoundNode;
|
|
const utility = @import("../utility.zig");
|
|
const dbg = utility.dbg;
|
|
const idbg = utility.idbg;
|
|
|
|
|
|
// Produces a sine wave to r_amp pin
|
|
pub fn singenN(self: *Activity) void {
|
|
|
|
const current_tick: f64 = @floatFromInt(self.soundnode.fab.current_tick);
|
|
const magnitude = self.operands[0];
|
|
const phase = self.operands[1];
|
|
const freq = self.operands[2];
|
|
const ylevel = self.operands[3];
|
|
|
|
const y = magnitude * math.sin(current_tick * freq + phase) + ylevel;
|
|
|
|
self.soundnode.basefreq = y;
|
|
self.soundnode.out10 = y;
|
|
self.soundnode.out11 = y;
|
|
|
|
} |