[PlanetCCRMA] Sine Waves, Hardware, and Software

joey.a joey.a at accelerators.co.uk
Thu Oct 18 13:58:00 PDT 2007


I guess the obvious question here, to both Kjetil S. Matheussen and Bill Schottstaedt, is "Which processor and clock speed are you using?"

Although I don't yet understand the syntax you are all using, I don't think the 
44100 KHz referred to below, has anything to do with the above, which will largely dictate how well any given software is going to perform.

Also, while I am still awaiting the machinery, any advice on where I should start for getting to grips with this syntax?


Date: Tue, 16 Oct 2007 21:41:34 +0200 (CEST)
From: "Kjetil S. Matheussen" <kjetil.matheussen at notam02.no>
To: planetccrma at ccrma.Stanford.EDU
cc: nando at ccrma.Stanford.EDU, bil at ccrma.Stanford.EDU
Subject: [PlanetCCRMA] Re: Re: sine waves in real time


Fernando Lopez-Lezcano:
> 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?
>


Just tried. And yes, its about twice as fast:

(let* ((num 130)
        (gens (make-vector num)))
   (do ((i 0 (1+ i)))
       ((= i num))
     (vector-set! gens i (make-oscil (* 10 (1+ i)) (random (* 2 pi)))))
   (set! (rt-safety) 0)
   (<rt-play> 0 10
      (lambda ()
        (let ((sum 0.0))
  (do ((k 0 (1+ k)))
       ((= k num))
     (set! sum (+ sum (oscil (vector-ref gens k)))))
  (out (* .01 sum))))))


Here's the generated c-code for the inner loop:

static void rt_gen1__3(struct RT_Globals *rt_globals)
{
     while (!((rt_globals->k__2 == rt_globals->num__4))) {
  (rt_globals->sum__1 =
  (rt_globals->sum__1 +
    mus_oscil(XEN_TO_MUS_ANY
      (SCM_VECTOR_REF
       (rt_globals->gens__5, ((int) rt_globals->k__2))), 0,
      0)), rt_globals->k__2 = (1 + rt_globals->k__2)
      );
     };
}

Its not quite optimal, but still I'm pretty
sure most of the time is spent in mus_oscil.

So I'm also pretty sure the oscillator generator in supercollider is super 
fast.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/planetccrma/attachments/20071018/f9eb36d1/attachment.html>


More information about the PlanetCCRMA mailing list