Simple question, generate tone by list

After some hour googling session, looks it is no any nyquist pluging for music notes.

I try make a simple plugin, nyquist plugin “convert music not to sine wave, using musical notation, lenght, and volume”. Of course, best if, if it is possible put string “A4 100 100, A#4 200 80, C#5 300 100”. Musical note in standard form, A4 (440 Hz middle A), A4#/A#4 etc etc. Lenght in millisecond. Volume in procent. And, of course, pauses.

But, reason this type plugin is not available, I must make my own. It is enough if I can put one note, and audacity convert it to right frequency sine wave. So, input string is about “A4 100 100”, middle A, lenght in millisecond, volume. A4#, maybe # is rejected, so… A4X maybe. PAUSE is maybe “P 100 0”, but: Pause is note without frequency and volume.

Plugin is too simple, so it is difficult to found samples. Musical notes need any list, so maybe use any “cond” etc… in “dtmf”-plugin I found any “list”, but it looks quite difficult to use. Maybe good start point is internal plugin “generate tone”, so, eg. “sine wave/volume/lenght”, but it code is not available. (Say google…)

This is my start code, but this not work- is it any place, where is exact and simple examples of nyquist codes? I think… any “huge nyquist sample stock”?

;nyquist plug-in
;version 1
;type generate
;name "tone Generator freq and lenght"
;action "tehdaan aanta"


;control keys "Tone string" string "" "440 10"

(defun musicallynotes (musicnote notelenght)
 
(setf musicnotefreq

(cond 
    ((musicnotefreq #\A4) 440)
    ( T 0)))

(cond 
    ((musicnotefreq #\Ax4) 466.16)
    ( T 0)))

osc (musicnotefreq notelenght)

Ah, looks quite simple, found…

(defun note (pitch dur amp) 
  (scale-db (- amp 0)(osc pitch dur *table*)))

(abs-env
(seq
(note d5 0.01 db0)
(note e5 0.01 db0)
 
))

Duration must be in seconds, reason no any possibility use milliseconds. Ready-to-use-lenghts does not make possibility to tempo.

Only problem is, chromatic is not possible also. d5, then… es5? se5? sb5? Looks it is not any way tell to nyquist “this must be semi pitch note”. Eg. c5 to b5 with half steps… maybe must found any way use frequencies. Not possible use letters… or… if anyone know secret information :slight_smile:

There are lots of syntax errors in that code.

This function does not make sense:

(defun musicallynotes (musicnote notelenght)
  (setf musicnotefreq
    (cond  ((musicnotefreq #\A4) 440)
            (T 0)))
  (cond ((musicnotefreq #\Ax4) 466.16)
         (T 0)))

and this is not LISP syntax:

osc (musicnotefreq notelenght)



Yes.


If you want milliseconds in the user interface, you just need to convert the ms value into seconds.
Example:

;control duration "Duration in ms" int "" 500 1 1000

;; Convert duration to seconds
(setf duration (/ duration 1000.0))

;; Test it:
(format nil "Duration entered = ~a seconds" duration)

You may find this topic useful: Building an audio track from labels: take 2, with label-determined pitch