Hola, estoy intentando hacer un plugin y Audacity me dice que el plugin no devuelve audio, el código es el siguiente:
;nyquist plug-in
;version 3
;type generate
;name "Test-001"
;action "Test-002"
;info "Test-003"
;control Fs "Sample rate" int "Hz" 44100 44000 88000
;control f "First armonic" real "Hz" 8ooo 0.1 20000
;control duracion "Duración" real "s" 3.0 0.001 10.0
;length-y = long. de array "y"
(setf length-y (truncate (* Fs duracion)))
;crea el array "y" de long. "length-y"
(setf y (make-array length-y))
;calcula la cantidad de armónicas "N"
(setf N (truncate (/ Fs 2) f))
(loop
(while (< k length-y)
(setf A (/ (* 3.141592 (* f k)) Fs))
(setf (aref y k) (/ (* (sin (* A (+ N 1))) (cos (* A N))) (sin A)))))
;devuelve un sonido "y-sound" a partir del array "y"
(snd-from-array 0 Fs y)
Pueden haber cosas mal, es mi primer intento de plugin.
Quisiera que me digan en donde me equivoco y también acepto sugerencias.
No se si estoy usando bien las sentencias, o si podrían ser más eficientes.
Uso Audacity 1.3.13-beta
Gracias.
Thanks, I managed to get output, finally.
The code:
;nyquist plug-in
;version 1
;type generate
;name "Test pulses..."
;action "Generating pulse train..."
;info "Tono para excitar filtros"
;control Fs "Sample Rate" int "Hz" 44100 44000 88000
;control f "First Harmonic" real "Hz" 8000.0 0.1 20000.0
;control duracion "Duration" real "s" 3.0 0.001 10.0
;asigna a "lengthY" la long. de array "y"
(setf lengthY (+ (truncate (* Fs duracion)) 1))
;crea el array "y" de long. "lengthY"
(setf y (make-array lengthY))
;calcula la cantidad de armónicas "N"
(setf N (truncate (/ (/ Fs 2) f)))
;llena el array "y"
(setf (aref y 0) 0)
(setf k 1)
(while (< k lengthY)
(setf A (/ (* 3.141592 (* f k)) Fs))
(setf (aref y k) (/ (* (sin (* A (+ N 1))) (cos (* A N))) (sin A)))
(setf k (+ k 1)))
;devuelve un sonido a partir del array "y"
(snd-from-array 0 Fs y)
Now I will see about “normalization” because it gets
clipping, thank you again.
In Audacity the sample rate of generated audio is determined by the Project Rate (bottom left of the Audacity screen) so rather than using a ;control you can just read it from sound-srate
Yes it’s identical, but less typing
Note that “1” is an integer, and if you divide an integer by another integer it will be calculated using integer arithmetic, so you will get an integer result.
(setq mylist (list 1 2 3 4 5 6)) ; can use setq because it is assigning the list '(1 2 3 4 5 6) to the symbol mylist
(setq (nth 3 mylist) 99) ; Error. (nth 3 mylist) is the third value (counting from 0) in mylist. It is not a symbol.
(setf (nth 3 mylist) 99) ; Sets the third field to the value 99
(print mylist) ; returns (1 2 3 99 5 6)
So for giving a value to a simple variable (a symbol) you can use setq, but for setting the value of a place within a bigger structure [such as an array or list] then you must use setf.
setf can be used to set the value of a symbol but it is probably better to setq for that purpose.
Nyquist works to something like 20 decimal places.
It takes no extra time for Nyquist to calculate using 3.14159265358979000737 than using 3.14. They are both floating point values so they use exactly the same number of bits. pi is a predefined constant and is accurate to 20 decimal places, so you may as well use pi.