Nyquist Experiment: SND-CONST

<>

Hi dondiego, you have been very thorough.

A few comments on your findings:

(snd-const value t0 srate duration)
http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/manual/part6.html#index476

The first parameter is not a frequency, it is just the height of the samples on the vertical scale. This is the numerical value of each sample produced.
The frequency of a constant is 0 Hz (zero).

The normal range of values for audio is between -1 and +1. We can create values beyond this in Nyquist, but they will be off the scale.
Early versions of Audacity will truncate values to the range +/- 1.0
Recent versions of Audacity 1.3 will allow values beyond this range if the format of the track is 32 bit. 32 bit is the default format, but can be changed in “Edit menu > Preferences > Quality”.

The second parameter (t0) should always be positive. Negative values should produce an error. The fact that early versions of Audacity do not produce an error message for negative values of t0 is a bug.

The reason that t0 should always be positive is that sounds cannot “back up” to an earlier time. In effect, you are asking Nyquist to produce a sound yesterday.
Audacity 1.3.12 correctly produces the error message “error: attempt to create a sound with negative starting time”

To see error messages when running Nyquist code, click the “Debug” button instead of the “OK” button.

In audio, we usually use “Hz” (cycles per second) or “kHz” (thousands of cycles per second).
“MHz” (millions of cycles per second) is way higher frequency than is used in audio.
More information: http://en.wikipedia.org/wiki/Hertz

(PRINT STOP) will print the value of the environmental variable stop which is the end of the line for Nyquist. You can’t have sounds that extend beyond stop. However, since stop is equivalent to about 31 million million years it should be sufficiently large for all purposes.

Regarding “inserting audio at a place in the time-line”;
The “timeline” is a feature of Audacity and has nothing to do with Nyquist. When audio is returned to Audacity from Nyquist, it is placed at the beginning of the track/selection. Audacity 1.2 does not support multiple clips in the same track so there is no way to insert audio at a specific position, other than padding the required gap with silence.
To insert audio at a specific time in a track you need to use Audacity 1.3 (current version 1.3.12).

In Audacity 1.3.12, (snd-const …) will return audio to the beginning of the selection if there is a selection, or at the cursor position.
When Audacity receives the sound from Nyquist, it assumes that the start time is zero, and places that time=zero at the current play position.

If you require an off-set from the current play position, for example, moving the start of a constant to +2.5 seconds, then you must also provide a time=zero reference, for example, by combining the sound with an event at t0 = 0

(snd-const 0.5 2.5 44100 2) will produce a constant signal, duration 2 seconds with a sample rate of 44100Hz, amplitude 0.5 at the cursor position.

If we want the sound to occur 2.5 second later than the cursor position, we must provide an event at time=zero. In the example below, we generate silence of duration 0 at time=zero. This provides a time reference for Audacity as to where to place the snd-const.
(sim
(at 0 (cue (s-rest 0)))
(snd-const 0.5 1 44100 2)
)

I think that some of the apparent confusion is because of limitations in Audacity 1.2. If you upgrade to Audacity 1.3.12 the improved implementation of Nyquist and of handling audio clips will resolve much of the confusion.

Attached are two plug-ins:

snd-const1.ny is a very simple “version 1” plug-in implementation of your experimental code. It allows you to enter parameters for “value t0 srate duration” for each of two (snd-const …) functions. This should work with any version of Audacity. WARNING - this plug-in does not have any error checking - invalid parameters may cause Audacity to crash.

snd-const3.ny is a “version 2” plug-in implementation of your code. Version 3 plug-ins require Audacity 1.3.
This version includes error checking, choice of standard sample rates, and an option to choose which of the (snd-const …) functions to use - so you can run one instance, or two instances of (snd-const …)


How to install plug-ins: http://audacityteam.org/download/plugins
snd-const1.ny (1.17 KB)
snd-const3.ny (2.04 KB)

<>

That’s because of filter resonance when you put an “instantaneous” pulse through it. The “value” is effectively a DC voltage and the start of the selection is that voltage switching on. Not all filters will behave that way. A theoretically perfect low-shelf eq boost will just raise the value/level.

You should (in theory) get a click at the beginning, though it will depend on the filter. You get a click if you use the Equalizer in Audacity 1.3.12.