[PlanetCCRMA] Re: sine waves in real time
Fernando Lopez-Lezcano
nando at ccrma.Stanford.EDU
Mon Oct 15 15:36:03 PDT 2007
On Mon, 2007-10-15 at 15:22 -0700, Bill Schottstaedt wrote:
> > On a very recent Intel laptop running a Core Duo at 2.4GHz (I think
> > that's the speed), SuperCollider would do 500 interpolated sine
> > oscillators with a (roughly) 50% cpu load (in one of the cores).
>
> In the Scheme version of Snd, at 44100 KHz, I get about 180 such
> sines (actually, I'm calling the sin function, not interpolating some
> table):
>
> (with-sound (:statistics #t)
> (let ((gens (make-vector 180)))
> (do ((i 0 (1+ i)))
> ((= i 180))
> (vector-set! gens i (make-oscil (* 10 (1+ i)) (random (* 2 pi)))))
> (run
> (lambda ()
> (do ((i 0 (1+ i)))
> ((= i 44100))
> (let ((sum 0.0))
> (do ((k 0 (1+ k)))
> ((= k 180))
> (set! sum (+ sum (oscil (vector-ref gens k)))))
> (outa i (* .01 sum) *output*)))))))
>
> ;test.snd:
> maxamp: 0.2935
> compute time: 1.020
Wow, that's impressive. 180 directly from scheme...
I never tried Kjetil's realtime snd, that would (presumable) be faster?
-- Fernando
> 30% of the time is handling the loops and writing output, nearly all the rest
> is in the oscils, so if I were writing direct to a DAC, I'd estimate 200.
> More interesting to me is the same question with the fm-violin -- I
> think I get 53:
>
> (with-sound (:statistics #t)
> (do ((k 0 (1+ k)))
> ((= k 53))
> (fm-violin 0 1 440 .01)))
>
> ;test.snd:
> maxamp: 0.4320
> compute time: 1.000
>
>
> In the Common Lisp (sbcl) clm, I get around 68:
>
> (with-sound (:srate 44100 :statistics t) (do ((i 0 (1+ i))) ((= i 68)) (fm-violin 0 1 440 .01)))
> test.snd:
> Duration: 1.0000, Last begin time: 0.0000
> Compute time: 0.997, Compute ratio: 1.00
> OutA max amp: 0.559 (near 0.249 secs)
> "test.snd"
>
>
> and presumably the sine wave case would scale similarly.
More information about the PlanetCCRMA
mailing list