Multiple tracks/outputs

Dear community/team,

I am very intrigued by what one can accomplish with Nyquist. I could not find any info about an idea/possibility that came into my mind: creating tones and arranging them into multiple tracks at certain times

Is this possible with Nyquist?

For example, I need to create 5 tones at certain Hz frequencies with one certain envelope. They need to be placed as such:
Tone 1 = track1 at 0:00 sec
Tone 2 = track2 at 0:50 sec
Tone 3 = track3 at 0:00 sec
Tone 4 = track4 at 0:75 sec
Tone 5 = track5 at 1:00 sec

Maybe I could use some kind of an array in order to automate this? For example, each line is a new group of 5 tones, which will be added into new 5 tracks with a specified time offset via a variable of lets say 1:50 sec, so that this:

Array = (
(432, 0:00), (236, 0:50), (323, 0:00), (789, 0:75), (556, 1:00)
(236, 0:00), (432, 0:00), (323, 0:50), (556, 0:00), (789, 1:00)

(where in order to simplify the example 432Hz is Tone 1, 236Hz Tone 2, 323Hz Tone 3, 789Hz Tone 4 and 556Hz Tone 5 further down)

…would produce something like this:

Tone 1 = track1 at 0:00 sec
Tone 2 = track2 at 0:50 sec
Tone 3 = track3 at 0:00 sec
Tone 4 = track4 at 0:75 sec
Tone 5 = track5 at 1:00 sec

Tone 2 = track1 at 1:50 sec (var 1:50 + 0:00 from the array)
Tone 1 = track2 at 1:50 sec (var 1:50 + 0:00 from the array)
Tone 3 = track3 at 2:00 sec (var 1:50 + 0:50 from the array)
Tone 5 = track4 at 1:50 sec (var 1:50 + 0:00 from the array)
Tone 4 = track5 at 2:50 sec (var 1:50 + 1:00 from the array)

Any idea/hint is greatly appreciated!
All best

Nyquist processes one track at a time.
Nyquist does not create Audacity tracks.
If you select multiple audio tracks, Nyquist will process each track in sequence (top to bottom).
When generating sound with Nyquist, the sound is returned to Audacity, and audacity places it in a track, with the start of the sound positioned at the start of the selection.

To create sounds at different times, you could precede the sounds with varying amounts of silence. Alternatively, you could generate the sound all starting at the same time, but run the plug-in in a macro, and then add macro commands to move the generated sounds. See here for information about macros:

Combining Nyquist plug-ins with macro commands is probably the way to go with this.

Thank you! Sounds great, will try it.
As for an array of Hz frequencies to create the tones needed? Is there such thing in nyquist or do I have to recopy/reuse the function call for as many times as there are notes to be created?

Never mind just found your post from 2010 explaining 3 ways of creating arrays. I am on my smartphone right now and this is a bit cumbersome… Thanks!

Two ways come to mind:

  1. Create a plug-in that generates one tone, and has input parameters for each thing that you want to vary, then call that plug-in from a macro command with the appropriate parameters each time you want to create the tone.
    Unless you have additional requirements that you have not described, this is probably the best approach.

  2. You could use a “list” to hold the parameters. (In LISP based languages such as Nyquist, “lists” are extremely powerful data structures and frequently preferred over arrays).
    Here’s a minimal example that generates tones into multiple selected tracks, taking the tone frequency from a list:

(defun note (hz)
  ;; A sine tone with a simple envelope
  (mult (pwl 0.01 1 0.1 0.2 1)
        (hzosc hz)))

;; List of frequencies
(setf frequencies
  (list 261.63 329.63 392.00
        523.25 659.25 783.99))

;; choice = remainder of "track index" / "number of frequencies"
(setf choice (rem (get '*track* 'index)
                  (length frequencies)))

; Generate the note for the current track
(note (nth choice frequencies))

Thank you so much. Will try it!