[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> </DIV>
<DIV><FONT>I guess the obvious question here, to both Kjetil S. =
Matheussen and=20
Bill Schottstaedt, is "Which processor and clock speed are you=20
using?"</FONT></DIV>
<DIV> </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 any given software is going to=20
perform.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </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> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </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" =
<</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>><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>> On Mon, 2007-10-15 at =
15:22=20
-0700, Bill Schottstaedt wrote:<BR>>>> On a very recent Intel =
laptop=20
running a Core Duo at 2.4GHz (I think<BR>>>> that's the speed), =
SuperCollider would do 500 interpolated sine<BR>>>> oscillators =
with a=20
(roughly) 50% cpu load (in one of the cores).<BR>>><BR>>> In =
the=20
Scheme version of Snd, at 44100 KHz, I get about 180 such<BR>>> =
sines=20
(actually, I'm calling the sin function, not interpolating =
some<BR>>>=20
table):<BR>>><BR>>> (with-sound (:statistics=20
#t)<BR>>> (let ((gens (make-vector=20
180)))<BR>>> (do ((i 0 (1+=20
i)))<BR>>> ((=3D i =
180))<BR>>> (vector-set! gens =
i=20
(make-oscil (* 10 (1+ i)) (random (* 2=20
pi)))))<BR>>> =20
(run<BR>>> (lambda=20
()<BR>>> (do ((i 0 (1+=20
i)))<BR>>> &nb=
sp; =20
((=3D i =
44100))<BR>>> =
=20
(let ((sum=20
0.0))<BR>>> &n=
bsp; =20
(do ((k 0 (1+=20
k)))<BR>>> &nb=
sp; =20
((=3D k=20
180))<BR>>> &n=
bsp; =20
(set! sum (+ sum (oscil (vector-ref gens=20
k)))))<BR>>> &=
nbsp; =20
(outa i (* .01 sum) *output*)))))))<BR>>><BR>>>=20
;test.snd:<BR>>> maxamp: =
0.2935<BR>>> =20
compute time: 1.020<BR>><BR>> Wow, that's impressive. 180 directly =
from=20
scheme...<BR>> I never tried Kjetil's realtime snd, that would =
(presumable)=20
be faster?<BR>><BR><BR><BR>Just tried. And yes, its about twice as=20
fast:<BR><BR>(let* ((num =
130)<BR> =20
(gens (make-vector num)))<BR> (do ((i 0 (1+=20
i)))<BR> ((=3D i=20
num))<BR> (vector-set! gens i (make-oscil (* 10 =
(1+ i))=20
(random (* 2 pi)))))<BR> (set! (rt-safety) =
0)<BR> =20
(<rt-play> 0 10<BR> (lambda=20
()<BR> (let ((sum =
0.0))<BR> (do=20
((k 0 (1+ k)))<BR> ((=3D k =
num))<BR> =20
(set! sum (+ sum (oscil (vector-ref gens k)))))<BR> =
(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> while =
(!((rt_globals->k__2 =3D=3D=20
rt_globals->num__4))) {<BR> (rt_globals->sum__1 =
=3D<BR> =20
(rt_globals->sum__1 +<BR> =
mus_oscil(XEN_TO_MUS_ANY<BR> =20
(SCM_VECTOR_REF<BR> =20
(rt_globals->gens__5, ((int) rt_globals->k__2))), 0,<BR> =20
0)), rt_globals->k__2 =3D (1 +=20
rt_globals->k__2)<BR> =
);<BR> =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--