
Evan Laforge wrote:
The only thing I'm uncertain about is whether it would have good enough time and space performance. All the real work is writing yet another set of basic envelope, oscillator, and fft primitives. You *should* be able to go all the way down to the samples in pure haskell though, which would be more elegant than those other languages :)
I've been playing with using Arrows as stream processors for audio, and the dataflow syntax of arrows is quite nice for sample manipulation: -- low pass filter (1-zero)
lop i = proc (x, f) -> do sr <- readState -< SampleRate let c = clip (2 * pi * f / sr) 0 1 rec y <- delay i -< o let o = x * c + (1 - c) * y returnA -< o
lop :: (ArrowCircuit a, ArrowReader b a, Floating b, Ord b) => b -> a (b, b) b
Unfortunately it's *very* slow - to render a 5s sine oscillator sweep from 20Hz to 20000Hz through a low pass filter at 44100Hz sampling rate takes around 17s. Admittedly 40% of the time is spent outputting the numbers to a text file, but it's still far far from realtime, and churns through 7GB of memory in the process (the total memory usage at any one time is constant and small, however). Claude -- http://claudiusmaximus.goto10.org