[PlanetCCRMA] Sine Waves, Hardware, and Software

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


This is a multi-part message in MIME format.

------=_NextPart_000_0047_01C811CB.B6098690
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


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=20
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@notam02.no>
To: planetccrma@ccrma.Stanford.EDU
cc: nando@ccrma.Stanford.EDU, bil@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)))
>>         ((=3D i 180))
>>       (vector-set! gens i (make-oscil (* 10 (1+ i)) (random (* 2 =
pi)))))
>>     (run
>>      (lambda ()
>>        (do ((i 0 (1+ i)))
>>            ((=3D i 44100))
>>          (let ((sum 0.0))
>>            (do ((k 0 (1+ k)))
>>                ((=3D 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)))
       ((=3D 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)))
       ((=3D 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 =3D=3D rt_globals->num__4))) {
  (rt_globals->sum__1 =3D
  (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 =3D (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=20
fast.


------=_NextPart_000_0047_01C811CB.B6098690
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1601" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman"=20
size=3D3></FONT></FONT>&nbsp;</DIV>
<DIV><FONT>I guess the obvious question here, to both Kjetil S. =
Matheussen and=20
Bill Schottstaedt,&nbsp;is "Which processor and clock speed are you=20
using?"</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>Although I don't yet understand the syntax you are all using, I =
don't think=20
the </DIV>
<DIV><FONT>44100 KHz referred to below, has anything to do with the =
above, which=20
will largely dictate how well&nbsp;any given&nbsp;software is going to=20
perform.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>Also, while I am still awaiting the machinery, any advice on where =
I should=20
start for getting to grips with this syntax?</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman" =
size=3D3>Date: Tue, 16=20
Oct 2007 21:41:34 +0200 (CEST)<BR>From: "Kjetil S. Matheussen" =
&lt;</FONT><A=20
href=3D"mailto:kjetil.matheussen@notam02.no"><FONT face=3D"Times New =
Roman"=20
size=3D3>kjetil.matheussen@notam02.no</FONT></A><FONT face=3D"Times New =
Roman"=20
size=3D3>&gt;<BR>To: </FONT><A =
href=3D"mailto:planetccrma@ccrma.Stanford.EDU"><FONT=20
face=3D"Times New Roman" =
size=3D3>planetccrma@ccrma.Stanford.EDU</FONT></A><BR><FONT=20
face=3D"Times New Roman" size=3D3>cc: </FONT><A=20
href=3D"mailto:nando@ccrma.Stanford.EDU"><FONT face=3D"Times New Roman"=20
size=3D3>nando@ccrma.Stanford.EDU</FONT></A><FONT face=3D"Times New =
Roman" size=3D3>,=20
</FONT><A href=3D"mailto:bil@ccrma.Stanford.EDU"><FONT face=3D"Times New =
Roman"=20
size=3D3>bil@ccrma.Stanford.EDU</FONT></A><BR><FONT face=3D"Times New =
Roman"=20
size=3D3>Subject: [PlanetCCRMA] Re: Re: sine waves in real=20
time<BR><BR><BR>Fernando Lopez-Lezcano:<BR>&gt; On Mon, 2007-10-15 at =
15:22=20
-0700, Bill Schottstaedt wrote:<BR>&gt;&gt;&gt; On a very recent Intel =
laptop=20
running a Core Duo at 2.4GHz (I think<BR>&gt;&gt;&gt; that's the speed), =

SuperCollider would do 500 interpolated sine<BR>&gt;&gt;&gt; oscillators =
with a=20
(roughly) 50% cpu load (in one of the cores).<BR>&gt;&gt;<BR>&gt;&gt; In =
the=20
Scheme version of Snd, at 44100 KHz, I get about 180 such<BR>&gt;&gt; =
sines=20
(actually, I'm calling the sin function, not interpolating =
some<BR>&gt;&gt;=20
table):<BR>&gt;&gt;<BR>&gt;&gt; (with-sound (:statistics=20
#t)<BR>&gt;&gt;&nbsp;&nbsp; (let ((gens (make-vector=20
180)))<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; (do ((i 0 (1+=20
i)))<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((=3D i =

180))<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (vector-set! gens =
i=20
(make-oscil (* 10 (1+ i)) (random (* 2=20
pi)))))<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;=20
(run<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (lambda=20
()<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (do ((i 0 (1+=20
i)))<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;=20
((=3D i =
44100))<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
=20
(let ((sum=20
0.0))<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;=20
(do ((k 0 (1+=20
k)))<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
((=3D k=20
180))<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
(set! sum (+ sum (oscil (vector-ref gens=20
k)))))<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;=20
(outa i (* .01 sum) *output*)))))))<BR>&gt;&gt;<BR>&gt;&gt;=20
;test.snd:<BR>&gt;&gt;&nbsp;&nbsp; maxamp: =
0.2935<BR>&gt;&gt;&nbsp;&nbsp;=20
compute time: 1.020<BR>&gt;<BR>&gt; Wow, that's impressive. 180 directly =
from=20
scheme...<BR>&gt; I never tried Kjetil's realtime snd, that would =
(presumable)=20
be faster?<BR>&gt;<BR><BR><BR>Just tried. And yes, its about twice as=20
fast:<BR><BR>(let* ((num =
130)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
(gens (make-vector num)))<BR>&nbsp;&nbsp; (do ((i 0 (1+=20
i)))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((=3D i=20
num))<BR>&nbsp;&nbsp;&nbsp;&nbsp; (vector-set! gens i (make-oscil (* 10 =
(1+ i))=20
(random (* 2 pi)))))<BR>&nbsp;&nbsp; (set! (rt-safety) =
0)<BR>&nbsp;&nbsp;=20
(&lt;rt-play&gt; 0 10<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (lambda=20
()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (let ((sum =
0.0))<BR>&nbsp; (do=20
((k 0 (1+ k)))<BR>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; ((=3D k =
num))<BR>&nbsp;=20
&nbsp;&nbsp; (set! sum (+ sum (oscil (vector-ref gens k)))))<BR>&nbsp; =
(out (*=20
.01 sum))))))<BR><BR><BR>Here's the generated c-code for the inner=20
loop:<BR><BR>static void rt_gen1__3(struct RT_Globals=20
*rt_globals)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp; while =
(!((rt_globals-&gt;k__2 =3D=3D=20
rt_globals-&gt;num__4))) {<BR>&nbsp; (rt_globals-&gt;sum__1 =
=3D<BR>&nbsp;=20
(rt_globals-&gt;sum__1 +<BR>&nbsp; &nbsp; =
mus_oscil(XEN_TO_MUS_ANY<BR>&nbsp;=20
&nbsp;&nbsp;&nbsp; (SCM_VECTOR_REF<BR>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;=20
(rt_globals-&gt;gens__5, ((int) rt_globals-&gt;k__2))), 0,<BR>&nbsp;=20
&nbsp;&nbsp;&nbsp; 0)), rt_globals-&gt;k__2 =3D (1 +=20
rt_globals-&gt;k__2)<BR>&nbsp; &nbsp;&nbsp;&nbsp; =
);<BR>&nbsp;&nbsp;&nbsp;&nbsp;=20
};<BR>}<BR><BR>Its not quite optimal, but still I'm pretty<BR>sure most =
of the=20
time is spent in mus_oscil.<BR><BR>So I'm also pretty sure the =
oscillator=20
generator in supercollider is super=20
<BR>fast.</FONT><BR><BR></DIV></FONT></BODY></HTML>

------=_NextPart_000_0047_01C811CB.B6098690--