Re: [ANNOUNCE] saolc v. 1.0 (FDIS release) available

From: Eric Scheirer (eds@media.mit.edu)
Date: Wed Jun 30 1999 - 18:16:37 EDT


>My apologies for bothering you all, but: I am having a small bit of
>trouble... I am trying to make a simple sine wave tone generator (on my
>own, rather than using one of the built in functions)...

Of course we are happy to help on this list; helping to learn
more about SAOL is an important purpose of the list.

>The problem I have is trying to get the current time in a-rate... my sine
>tone sounds "chunky", because the sine input time is a k-rate...
>(everything sounds fine if I set krate to srate)...
>
>aopcode my_sin(asig my_freq)
> {
> return (sin(2*3.14159*my_freq*itime));
> }
>

Yes, itime is a k-rate only variable. So it is not appropriate
for this purpose. To do this, I would write:

aopcode my_sin(asig my_freq) {
  asig atime;

  atime = atime + 1/s_rate;

  return (sin(6.28 * my_freq * atime));
}

That is, to accumulate the value of atime with an a-rate variable.

You may already be aware of this, but the "normal" way to do
this is

aopcode my_sin(asig my_freq) {
  table sinshape(harm,2048,1);

  return(oscil(sinshape,my_freq));
}

This uses the "oscil" function to turn a waveshape (stored in
the table 'sinshape') into a periodic signal. This will be
faster than your way in most cases. But they do the same
thing (in fact, yours is slightly more accurate).

>also: what should the type of my_freq be? It doesn't appear to make a
>difference if I have it an asig or a ksig...

It only matters if you're going to change the frequency (ie, FM).
The rate of my_freq corresponds to how rapidly you're going to
update this parameter in the caller. So if you're not doing FM,
you can use an ivar; if your FM is vibrato-rate (the frequency
changes slowly), you can use a ksig; if you want to do FM-synthesis,
where the FM adds audible sidebands to the spectrum, you'll
want an asig.

Best,

 -- Eric

+-----------------+
| Eric Scheirer |A-7b5 D7b9|G-7 C7|Cb C-7b5 F7#9|Bb |B-7 E7|
|eds@media.mit.edu| < http://sound.media.mit.edu/~eds >
| 617 253 0112 |A A/G# F#-7 F#-/E|Eb-7b5 D7b5|Db|C7b5 B7b5|Bb|
+-----------------+



This archive was generated by hypermail 2b29 : Mon Jan 28 2002 - 11:46:33 EST