Wavetables in Audacity

classic Classic list List threaded Threaded
2 messages Options
rbd
Reply | Threaded
Open this post in threaded view
|

Wavetables in Audacity

rbd
 From his code, it looks like David Sky figured out how to solve the
    "error: maximum table size (100000) exceeded - NIL"
problem. Since Nyquist tends to compute sounds according to the current
environment which has information about duration, the recommended way to
compute waveforms is to locally restore the environment to the default
like this:

(abs-env (setf *my-waveform* (build-my-waveform)))

By calling BUILD-MY-WAVEFORM inside of ABS-ENV, the stretch factor will
be 1, regardless of what Audacity sets up for you.

Note: I put the ABS-ENV around everything for emphasis, but the code
would compute the same thing if I wrote it at:

(setf *my-waveform* (abs-env (build-my-waveform)))

If you create a waveform with PWL or LFO and make the duration 1, then
you'll have *CONTROL-SRATE* samples in the waveform. If you use OSC or
any other "audio" function, you'll have *SOUND-SRATE* samples in the
waveform. Either way, that's going to be pretty big. You can be more
efficient by specifying a shorter duration or a lower sample rate. I
prefer the lower sample rate method:

(abs-env
    (control-srate-abs 1024
        (setf *my-waveform* (build-my-waveform))))

or if BUILD-MY-WAVEFORM is using OSC or something that runs at the
default audio rate, you should use SOUND-SRATE-ABS instead of
CONTROL-SRATE-ABS.  (Also, you should nest both CONTROL-RATE-ABS and
SOUND-SRATE-ABS if you're mixing control rate and audio rate functions.)
Do NOT set *CONTROL-SRATE* or *SOUND-SRATE* directly! These are meant to
be read-only.

Since I specified 1024 as the rate, the table length for a one second
sound will be 1024.

Tables are interpolated with linear interpolation. In the case of a
pulse wave and panning, a small table will cause some intermediate
values to be generated, making for a smooth transition from 1 to 0 and 0
to 1. This could be useful. Example: To suppress clicks, suppose you
want a 5ms linear pan from left to right or right to left, and the
panning is running at 2Hz. That means we're running through the table
samples every 500ms. If each table sample represents 5ms, the table
should have 500/5 = 100 samples.

-Roger


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: Wavetables in Audacity

David R. Sky
Thanks Roger for your wave-table explanation!

I didn't hear clipping on headphones using the pulse table I set up, but I
assume it's probably better to use the 5ms transition you mentioned.

Also, I'd been trying to figure out how to create a random waveform for
another plug-in I've been working on, using filtered white noise as the
source. Without using *sound-srate* signal. It looks like your code will
help me do this.

Thanks again!

David

--
David R. Sky
http://www.shellworld.net/~davidsky/



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist