How to play frequencies in a row


I can play single frequency using Tone generator, but
I would like to play different frequencies in a raw, for instance :
262Hz during 1s
then silence during 200ms
then 460Hz during 1.5s
then silence during 300ms…

It could be useful to make my students understand the link between frequencies and musical notes.

Thanks for answer !

I haven’t finished my cup of tea for the morning and we’ve had a time change… but do you mean something like the picture below?
Each time you generate a new tone, it puts it on a new track. So I used the time shift tool to drag it next to the end of the previous tone…

Or am I missing something?


For the Nyquist Prompt, it could look like this

(defun gather (score)
  (cond ((null score) (s-rest 0))
        (t (seq (abs-env (seq (osc (hz-to-step (car score)) 
                              (cadr score))
                         (s-rest (caddr score)))) 
                (gather (nthcdr 3 score))))))
; Format: <freq (Hz)> <duration (s)> <silence (s)>
(setf score
 '(440 0.5 0.2
   660 1 0.3
   253 0.2 0.1
   487 1 0.125))
(multichan-expand 'gather score)

You can enter the notes in the score list (Format as shown in the example)
It’s a Little difficult to implement this in a plug-in, because many values Change and their number is theoretically not limited.
The best way may be a single TextBox where the triple pair can be entered - or three of them with Frequency, Duration and Gap.
Tell us what you Need - or let your students Experiment further…

Both of your anwers are very helpful to me! Thank you!

→ Damien: Your method could be interesting but when I generate a new tone, howcome it doesn’t appear in a new track but overrides the old one?!

->Robert J. H., your solution looks like THE good solution!
But as it is the first time I hear about Nyquist files, I’m not sure to use it properly:
I copied the code below in a file named freqs.ny located in plug-ins folder. Then, I tried to open it with File/Import/Raw data… but it doesn’t seem to be the right method… :confused:

(defun gather (score)
  (cond ((null score) (s-rest 0))
        (t (seq (abs-env (seq (osc (hz-to-step (car score))
                              (cadr score))
                         (s-rest (caddr score))))
                (gather (nthcdr 3 score))))))
; Format: <freq (Hz)> <duration (s)> <silence (s)>
(setf score
 '(440 0.5 0.2
   660 1 0.3
   253 0.2 0.1
   487 1 0.125))
(multichan-expand 'gather score)

Thanks for your help!

If there is a track selection, the generated tone will overwrite the selection.
If there is no selection, “Generate > Tone” will create a new track.

For just doing a one-off with a few tones, the easiest way is to make a selection where you want the new tone to be and generate the tone:

Select an empty track then call up the “Nyquist Prompt” effect (Effect menu) and copy and paste Robert’s code into the Nyquist Prompt effect.

Sorry, I Forget sometimes that not all users are familiar with the Nyquist prompt.
It is a simple Interpreter for the LISP Derivate language Nyquist.
It is fairly easy and can handle almost every Audio Problem, although it is rather intended for Sound Synthesis.
The prompt is the test Portal for code that is eventually realised as a plug-in.
I have hundreds of such snippets which I’ve collected and placed in a normal Excel worksheet to reuse them in case of Need.
That the snippets are nowhere saved is the greatest drawback of the Nyquist prompt. Therefore it is good that you have saved the code in a text file.
To use it, just copy the text into the Nyquist Prompt (in the effect menu) and press ok.
The text will be still available in the next call (where you can Change the values for example).
However, the code is not saved over sessions.
For this reason, I’ve proposed to put it inside a formal plug-in.

Thank you so much for your quick answers and explanations!
At last, I succeded to play frequencies in a row with both Damien’s and Robert’s methods!

I will first let my students calculate in a spreadsheet the frequencies of every single note using the formula fn=fo*2^(n/12).
Then I will ask them to play an easy melody using Audacity with one of the methods I just learned :slight_smile:

Then report back with a demo!



At least, I’ve finished this work with my students, it worked fine…
All my files -in french- are in this zip :

Merci beaucoup for reporting back.
Fine that it worked so far.
I guess it won’t become a Chart breaker…
Any improvements desired?
You know, there are other tones available than pure sine waves.
Some Timbre changing could at least end up in a nice melody for a ring tone…

Yes, it worked quite well so far and it was interesting to them seeing the ‘scientific side’ of music…
It was not very user-friendly to copy/paste from spreadsheet to Nyquist Prompt and changing the french decimal separator " , " into " . " .
I’m gonna work now on a small program doing this work for them.
By the way, my colleagues decided to use my (I should say our!) work for their next Physic session concerning “waves and sounds”. So, thank you again for your help!

PS: The only way I found for Timbre changing is using the Equalization effect.

I thought the singing/motor frog ring tone was the only one!!

Welcome to 2001.


Ehm, I guess the EQ has not much timbre changing aspects on a sine wave…
Your students can try other waveforms by simply writing tri-table or saw-table* after the Duration Parameter in the osc function, e.g.

(osc <pitch> <Duration> *tri-table*)

Square waves Need another function (osc-pulse) or the Expression

(maketable *step-shape*)

Nyquist has also some physical models built-in like sax, clarinet, mandolin and so on. However, the Parameter handling is a Little more difficult (because of the envelopes used to simulate breath, pressure etc).
The comma as separator is a frequently upcoming issue throughout Audacity’s Interfaces.
The Nyquist prompt could of course be expanded to a ordinary generate plug-in, where you can simply copy the data from the spread sheet into a text field.
These values remain there as Long as Audacity is executed. The read-out Routine can take care of the commas too, if desired.