4 category = "Instrument",
6 author = "Ardour Team",
7 description = [[Sine Wave Generator (v1.2)]]
12 function dsp_params ()
15 { ["type"] = "input", name = "Frequency", min = 20, max = 20000, default = 1000, unit="Hz", logarithmic = true },
16 { ["type"] = "input", name = "Gain", min = -90, max = 0, default = -18, unit="dB" },
20 function dsp_ioconfig ()
21 return { [1] = { audio_in = -1, audio_out = -1}, }
24 function dsp_init (rate)
29 function low_pass_filter_param(old, new, limit)
30 if math.abs (old - new) < limit then
33 return old + lpf * (new - old)
41 function dsp_run (ins, outs, n_samples)
42 local ctrl = CtrlPorts:array() --call parameters
44 local a = {} --init array
45 local f = ctrl[1] or 1000
46 local amp = low_pass_filter_param(ao, ARDOUR.DSP.dB_to_coefficient(ctrl[2]), 0.02)
49 for s = 1, n_samples do --fill table with fragments of a sine wave
51 a[s] = amp * math.sin(p * (2 * math.pi))
55 outs[c]:set_table(a, n_samples) --passes array into buffer
58 if (f ~= fo) or (a ~= ao) then
65 function render_inline (ctx, w, max_h) --inline display
66 local ctrl = CtrlPorts:array()
71 if f < 0.5 then f = 0.5 end
72 if f > 8 then f = 8 end
75 ctx:rectangle(0, 0, w, h)
76 ctx:set_source_rgba(0, 0, 0, 1.0)
78 ctx:set_line_width(1.5)
79 ctx:set_source_rgba(0.8, 0.8, 0.8, 1.0)
84 y = ARDOUR.DSP.dB_to_coefficient(ctrl[2]) * math.sin(f * (2 * math.pi * (p)))
85 yc = 0.5 * h + ((-0.5 * h) * y)
86 ctx:move_to (x, yc + 3)
87 ctx:line_to (l_x, l_y + 3)