Create stereo tone track prompt

i want to create stereo track with specific tones
here is a n example

  1. every tone will run for 5 seconds
    first 5 seconds ( left x frequency+ right y frequency )- x and y numbers will vary
    next 5 sec( left A frequency+ right B frequency )- A and B numbers will vary

and so on
lets say x= 100 hz, Y = 200 HZ, A=300 HZ, B= 400 HZ

summary : i want a prompt where i will enter numbers instead of X,Y,A,B (and more) and create a single stereo audio file ,where every 5 seconds the frequency tones will change ( from XY to AB to CD to EF)
please help me.
Thank You

You could write a Nyquist plug-in to do that.

Hi Steve, i do not know how to write that prompt, how can i learn or from whom i can get help

There isn’t much support for Nyquist scripting any longer, though you can find some documentation by following the links on that page that I sent. Also some additional documentation and a few little tutorials on my blog audionyq.com.

Here is some code to get you started:

;nyquist plug-in
;version 4
;type generate
;name "Stereo Tones"
;author "Steve Daulton"
;release 2.4.2
;copyright "GPLv2+"

;control FREQUENCIES "List of frequencies" string "L1 R1 L2 R2 ..." "110 220 430 450"
;control DURATION "Duration per tone" float "seconds" 5 0 99
;control LEVEL "Level" float "0 to 1" 0.8 0 1

(setf hzlist (eval-string (format nil "(list ~a)" FREQUENCIES)))

(defun gen-tones(breakpoints)
  (seqrep (i (length breakpoints))
          (osc (hz-to-step (nth i breakpoints)) DURATION)))


(defun channel-frequencies (stereo-breakpoints)
  ;;; Return (list left-breakpoint-list right-breakpoint-list)
  (let (bpl bpr)
    (dotimes (i (/ (length stereo-breakpoints) 2)
              (list (reverse bpl)(reverse bpr)))
      (push  (nth (* 2 i) stereo-breakpoints) bpl)
      (push  (nth (1+ (* 2 i)) stereo-breakpoints) bpr))))


(cond
  ((= (rem (length hzlist) 2) 1)
      (print "Error. There must be an even number of frequencies."))
  ((= DURATION 0)
      (print "Error. Duration must be greater than zero."))
  (t  (setf lr-hz (channel-frequencies hzlist))
      (mult LEVEL
            (vector (gen-tones (first lr-hz))
                    (gen-tones (second lr-hz))))))

The code above may be run in the Nyquist Prompt effect, or installed with the Nyquist Plugin Installer.

IMPORTANT:
Nyquist plug-is are not able to create a new stereo track, so you will need to manually select a stereo track to generate the audio into.

Do you know any programming languages? If you want to do a job that thousands of other people want to do, then chances are good that somebody has written a program to do it.

If you have a one-off job, then that’s where you or some one else may have to write a custom program.

Steve got you going there with that code. There’s more information in the links above that.

Or, depending on how much chocolate is involved, you may be able to get someone to write it for you.

Koz

Hello
thank you so much,
I tried it, its good, is it sine waves?
can i get it for square wave please

You will need to change the osc function with osc-pulse. Note that osc-pulse does not have a “duration” parameter, so you will need to use stretch to set the length of each section.

(defun gen-tones(breakpoints)
  (seqrep (i (length breakpoints))
          (osc (hz-to-step (nth i breakpoints)) DURATION)))

becomes:

(defun gen-tones(breakpoints)
  (seqrep (i (length breakpoints))
          (stretch DURATION
              (osc-pulse (nth i breakpoints) 0))))

Here’s a version with a choice of waveforms:

;nyquist plug-in
;version 4
;type generate
;name "Stereo Tones"
;author "Steve Daulton"
;release "2.4.2-1"
;copyright "GPLv2+"

;control FREQUENCIES "List of frequencies" string "L1 R1 L2 R2 ..." "110 220 430 450"
;control WAVEFORM "Waveform" choice "Sine,Square,Triangle,Sawtooth" 0
;control DURATION "Duration per tone" float "seconds" 5 0 99
;control LEVEL "Level" float "0 to 1" 0.8 0 1

(setf hzlist (eval-string (format nil "(list ~a)" FREQUENCIES)))


(defun one-tone (hz)
  (case WAVEFORM
    (0 (osc (hz-to-step hz) DURATION))
    (1 (stretch DURATION (osc-pulse hz 0)))
    (2 (stretch DURATION (osc-tri hz)))
    (t (stretch DURATION (osc-saw hz)))))


(defun gen-tones(breakpoints)
  (seqrep (i (length breakpoints))
          (one-tone (nth i breakpoints))))


(defun channel-frequencies (stereo-breakpoints)
  ;;; Return (list left-breakpoint-list right-breakpoint-list)
  (let (bpl bpr)
    (dotimes (i (/ (length stereo-breakpoints) 2)
              (list (reverse bpl)(reverse bpr)))
      (push  (nth (* 2 i) stereo-breakpoints) bpl)
      (push  (nth (1+ (* 2 i)) stereo-breakpoints) bpr))))


(cond
  ((= (rem (length hzlist) 2) 1)
      (print "Error. There must be an even number of frequencies."))
  ((= DURATION 0)
      (print "Error. Duration must be greater than zero."))
  (t  (setf lr-hz (channel-frequencies hzlist))
      (mult LEVEL
            (vector (gen-tones (first lr-hz))
                    (gen-tones (second lr-hz))))))

Thank You So very much. Really Appreciate it.

Also can i request you one last prompt

changes in above is

  1. mono track instead of stereo
  2. option to record frequencies as
    a) one after another eg 100 200 300 400 500hz one after another for 5 seconds
    b) simultaneously eg 100 200 300 400 500hz ( all 5 frequencies would fire at the same time) and i can export the track.

I would be really very very grateful if i get this prompt.

one question
Level fields in the prompt denotes volume of the track, am i correct?

At some point you will need to learn how to do this yourself. Why not have a go now and I’ll be happy to answer questions to help you get it working.

Hi Steve,
Thank you and so sorry for late reply, ( my wife got admitted in hospital so could not reply earlier)
i would love to learnt it. please let me know how

Some resources for learning Nyquist:

Hi Steve, i did go through it,
Frankly as a doctor , i found it very difficult to understand.
i took my time but…

can you help me with these

  1. mono track instead of stereo
  2. option to record frequencies as
    a) one after another eg 100 200 300 400 500hz one after another for 5 seconds
    b) simultaneously eg 100 200 300 400 500hz ( all 5 frequencies would fire at the same time) and i can export the track.

I would be really very very grateful if i get this prompt.

i would be happy for energy exchange too.

There’s a tutorial about stereo tracks here: Stereo Tracks Tutorial | Audacity Plugins

In Nyquist, because it is designed for working with sound, it defines “sounds” as a “data type”. Data types are things like integers, floats (decimal numbers), characters, strings (text), lists, arrays, and so on. Nyquist has a “sound” data type. Multi-channel sounds are handled as an “array of sounds”, so “stereo sound” is an array containing two “sounds” (the left channel and right channel).

To combine multiple sounds at the same time, use the sim function.

Example:

(sim (hzosc 220)
     (hzosc 330)
     (hzosc 440))

The generated sounds can also be placed at specific times (relative to the start time of the first sound):

(sim (hzosc 220)  ; first sound is automatically at time = 0
     (at-abs 1 (hzosc 330))
     (at-abs 2 (hzosc 440)))

Perhaps it might be worth petitioning the new Audacity team to resume documenting Nyquist for Audacity, especially with some tutorials for beginners.

This topic was automatically closed after 30 days. New replies are no longer allowed.