problem with a plug-in (generate)
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
problem with a plug-in (generate)
Hello. I try to write a plug - in from a script of P. Morales. It does not work. Do you understand the problem?
Beforehand thank you for your help.
Beforehand thank you for your help.
- Attachments
-
- RISSET TIBETAN.lsp
- (1.3 KiB) Downloaded 74 times
Re: problem with a plug-in (generate)
This is malformed:
A function definition must have its arguments listed in parentheses after the name of the function:
If there are no arguments, then it still needs the parentheses:
Your function definition "sound" is missing a ")" at the end.
This is incorrect because:
a) "freq" is not a function
b) If "freq" is supposed to be a variable (rather than a function), it needs to have a value, either scoped globally or passed to your "sound" function as an argument.
Also, best not to use "sound" as a function name as it is already a defined function in Nyquist.
Code: Select all
(defun sound
(scale 0.1 (tibetan (freq offset dur rise dec)))Code: Select all
(defun finction-name (arg1 arg2 ...)
function body)Code: Select all
(defun finction-name ()
function body)Code: Select all
(freq offset dur rise dec)a) "freq" is not a function
b) If "freq" is supposed to be a variable (rather than a function), it needs to have a value, either scoped globally or passed to your "sound" function as an argument.
Also, best not to use "sound" as a function name as it is already a defined function in Nyquist.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: problem with a plug-in (generate)
Perhaps you meant:
Code: Select all
(defun mysound ()
(scale 0.1 (tibetan pitch offset dur rise dec)))
(stretch 1 (mysound))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: problem with a plug-in (generate)
Thank you.
I try to use the following code:
I added the code following in the plug-in "generate".
The problem is in this code.
The nyquist console indicates the following error;
Do you understand my error?
I try to use the following code:
Code: Select all
(defun mytone ()
(sine pitch dur))Code: Select all
;control pitch "pitch" real "MIDI pitch" 55 36 84The problem is in this code.
Code: Select all
(setf pitch (step–to–hz)) Code: Select all
error: illegal character - -30
Function: #<Subr-(null): #407d328>Re: problem with a plug-in (generate)
"step-to-hz" converts a MIDI note number ("step") into Hz.DERF wrote:(setf pitch (step–to–hz))
For example, A4 is MIDI note number 69 and the frequency of a sine wave at A4 is 440 Hz (standard tuning).
Code: Select all
(print (step-to-hz 69)) ; prints 440Code: Select all
(print (hz-to-step 440)) ; prints 699/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: problem with a plug-in (generate)
Hello.
Thank you.
I would want to evoke the code of Pedro Jose Morales "b5.lsp".
I would want to evoke the following part of the code:
In the user manual of R. B Dannenberg, the author indicates: (lambda args expr...) - make a function closure
args - formal argument list (lambda list) (quoted)
My question is thus the following one: apparently, the "lambda" function is followed by arguments.
So: Is it the first argument?
Is it the second argument?
and Is it the third argument of the "lambda" function?
Beforehand, thank you for your answer.
Thank you.
I would want to evoke the code of Pedro Jose Morales "b5.lsp".
Code: Select all
(defun lfo-pitch-control ()
(pwlv 0.25 0.6 0.25 1.4 0.5 2.0 0.95 2.2 0.25 3.4 0.5 3.8 0.78 dur -0.2))
(defun starship (frq scl)
(apply #' sim
(mapcar #' (lambda (offset)
(fmosc (hz-to-step (+ frq offset)) (scale scl (lfo-pitch-control))))
'(0.0 4.3 9.5 23.0 39.0 84.0))))Code: Select all
(lambda (offset)
(fmosc (hz-to-step (+ frq offset)) (scale scl (lfo-pitch-control))))args - formal argument list (lambda list) (quoted)
My question is thus the following one: apparently, the "lambda" function is followed by arguments.
So:
Code: Select all
(offset)Code: Select all
(fmosc (hz-to-step (+ frq offset))and
Code: Select all
(scale scl (lfo-pitch-control)Beforehand, thank you for your answer.
Re: problem with a plug-in (generate)
The XLISP manual provides more information about lambda:
http://www.audacity-forum.de/download/e ... ef-145.htm
The name of the function is: lambda
The argument list is enclosed in parentheses. There is just one argument: offset
The last part is the body: (fmosc (hz-to-step (+ frq offset)) (scale scl (lfo-pitch-control)))
The body contains one function: fmosc http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index378
fmosc requires at least two arguments. In this case it has exactly two arguments.
The first argument of fmosc defines the pitch:
The second argument of fmosc defines the modulation:
http://www.audacity-forum.de/download/e ... ef-145.htm
Code: Select all
(lambda (offset)
(fmosc (hz-to-step (+ frq offset)) (scale scl (lfo-pitch-control))))
The argument list is enclosed in parentheses. There is just one argument: offset
The last part is the body: (fmosc (hz-to-step (+ frq offset)) (scale scl (lfo-pitch-control)))
The body contains one function: fmosc http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index378
Code: Select all
(fmosc (hz-to-step (+ frq offset))
(scale scl(lfo-pitch-control)))
The first argument of fmosc defines the pitch:
Code: Select all
(hz-to-step (+ frq offset))Code: Select all
(scale scl(lfo-pitch-control))9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
Re: problem with a plug-in (generate)
Thank you.
The user manual of the XLISP function (mapcar indicate:
(mapcar function list1 [list2 ... ])
If the function (lambda with its list which has that an argument is the "list1 ", I presume that the " list 2" is:
It is right?
This is an unevaluated list.
My question is the following one. I tried to understand how the values of the "list 2" act on the generated sound wave. I did not understand the logic.
How do we choose these values?
Beforehand thank you for your answer.
The user manual of the XLISP function (mapcar indicate:
(mapcar function list1 [list2 ... ])
If the function (lambda with its list which has that an argument is the "list1 ", I presume that the " list 2" is:
Code: Select all
'(0.0 4.5 9.4 23.0 39.0 84.0)This is an unevaluated list.
My question is the following one. I tried to understand how the values of the "list 2" act on the generated sound wave. I did not understand the logic.
How do we choose these values?
Beforehand thank you for your answer.
Re: problem with a plug-in (generate)
I presume that you are referring to this code:
This is quite tricky to read, but we can break it down into sections by looking where the "(" match with ")".
Note that the function CAR returns the first element of a list, so when the XLISP manual says "successive CARs", it means the first term, then the next term, then the next. It is simply taking each element of the list in turn.
From the outer brackets we see:
so '(0 1 2 3 4 -1 -2 -3 -4) is the list that the lambda expression is applied to.
Then moving into the lambda expression:
we have an unnamed function with a local variable "off" and the body of the lambda expression consists of the function OSC.
This function is applied to successive terms from the list.
Moving in further to the OSC function we see that OSC has three arguments:
(osc step duration table)
The "step" argument is (hz-to-step (+ frq (* off offset)))
The "duration" argument is the variable "dur"
The "table" argument is the symbol "*tibetan-table*"
The interesting thing here is that the "step" argument is a function that includes the variable "off" [which was defined as a local variable of the lambda expression]
So, moving back out again, the lambda expression has an argument "off" that is used within the function "hz-to-step".
MAPCAR applies the lambda expression to each term in the list. In other words, each of the numbers in the list becomes the "off" variable.
To see how this works, lets take a simple example that can be run in the Nyquist Prompt. Use the Debug button to see the output:
Here, the symbol "x" is a local variable of the unnamed function (the lambda expression) and '(1 2 3 2 1) is the list that the lambda expression is applied to.
Within the body of the lambda expression is the function (print x).
So what happens with MAPCAR is that the first element of the list [the number 1] is passed to the lambda expression and printed. Then the next element of the list [the number 2] and so on. The result is:
In our more complex example, the numbers 0, 1, 2, 3, 4, -1, -2, -3, and -4 are passed to the lambda expression and are evaluated within the HZ-TO-STEP function, so that a series of "step" values is created which can be used by the OSC function. Thus the code creates a list of sounds.
Code: Select all
(mapcar #'(lambda (off)
(osc (hz-to-step (+ frq (* off offset))) dur *tibetan-table*))
'(0 1 2 3 4 -1 -2 -3 -4))
Note that the function CAR returns the first element of a list, so when the XLISP manual says "successive CARs", it means the first term, then the next term, then the next. It is simply taking each element of the list in turn.
From the outer brackets we see:
Code: Select all
(mapcar #'(lambda .....)
'(0 1 2 3 4 -1 -2 -3 -4))
Then moving into the lambda expression:
Code: Select all
(lambda (off) (osc ....))This function is applied to successive terms from the list.
Moving in further to the OSC function we see that OSC has three arguments:
(osc step duration table)
Code: Select all
(osc (hz-to-step (+ frq (* off offset)))
dur
*tibetan-table*)
The "duration" argument is the variable "dur"
The "table" argument is the symbol "*tibetan-table*"
The interesting thing here is that the "step" argument is a function that includes the variable "off" [which was defined as a local variable of the lambda expression]
So, moving back out again, the lambda expression has an argument "off" that is used within the function "hz-to-step".
MAPCAR applies the lambda expression to each term in the list. In other words, each of the numbers in the list becomes the "off" variable.
To see how this works, lets take a simple example that can be run in the Nyquist Prompt. Use the Debug button to see the output:
Code: Select all
(mapcar #'(lambda (x) (print x)) '(1 2 3 2 1))Within the body of the lambda expression is the function (print x).
So what happens with MAPCAR is that the first element of the list [the number 1] is passed to the lambda expression and printed. Then the next element of the list [the number 2] and so on. The result is:
Code: Select all
1
2
3
2
1
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)