Ok, so I finally got Gadfly to draw a graph of the most trivial of audio
dsp, a one pole low pass / high pass filter, but my code doesn't actually
work!
I need the value of "lp" passed in to the lowpass function to actually
update that chunk of memory, which in this case is the global variable "s".
Can anyone please point out how I could do that? In C++ I would define the
lowpass function as taking the arguments: lowpass (double input, double&
lp, double g)
On Wednesday, June 18, 2014 11:50:05 AM UTC+8, Andrew Simper wrote:
>
> And I also got the loop bounds wrong it should be 2:len, not 1:len-1 as
> shown, here is the corrected code:
>
> function lowpass(input::Float64, lp::Float64, g::Float64)
> hp::Float64 = input - lp
> lp += g * hp
> [lp, hp]
> end
> function parametricarray2D(f, time::Vector{Float64})
> len = length(time)
> ret = f(time[1])
> output = Array(Float64, len, length(ret))
> output[1,:] = ret
> for i in 2:len
> output[i,:] = f(time[i])
> end
> output
> end
> s = 0.0;
> data = parametricarray2D(t->begin input=sin(100.0*t); [t, input,
> lowpass(input, s, 0.5)] end, linspace(0.0,2.0pi,2*44100))
>
>
>
>
>