few basic problems

my name is Tomek, I’m from Poland and I have recently started experimenting with Nyquist. The thing is that I have few problems with pretty basic effects I would like to implement and I have no idea, why they are not working since I believe they have been written properly. Could you guys please check them out and tell me what’s wrong? I’m a newby to all this nyquist thing and I have been reading reference manual for hours, but still I have no idea what am I doing wrong, so please treat me kindly. thx;)

  1. I wanted to implement the wah-wah effect, so I thought the easiest way is to put the lfo oscilator as a central frequency to the filter, but it does not work…
;nyquist plug-in
;version 1
;type process
;name "Wah-Wah"
;action "performing wah-wah effect..."
;info "autor: Tomasz Adamiak"

;control f "medium frequency" int "[Hz]" 1000 100 4000
;control fl "lfo frequency" real "[Hz]" 1 0.1 5

(allpass2 s (+ f (lfo fl)))
  1. I tried to write echo effect not as a recursive function, but in a loop, I made something like this: it doesn’t work obviously, maybe I screwed up with a loop construction or something?
;nyquist plug-in
;version 1
;type process
;name "Echo"
;action "performing echo effect..."
;info "autor: Tomasz Adamiak"

;control d "delay" real "[s]" 1 0.1 6
;control e "no. of echoes" int " " 5 1 10
;control z "decay" int "[dB]" 6 2 18
for i = 1 to e by 1
(sim (cue s) (loud (* z i) (at (* d i) (cue s)))) 
  1. Here I have like no idea what might be wrong, cause it’s pretty simple and I belive I wrote it properly, but still it doesn’t want to work. It’s a simple phaser effect, I’m multiplying the original signal with it’s copy, which is slightly moved in time and slightly more silent.
;nyquist plug-in
;version 1
;type process
;name "Flanger"
;action "performing flanger effect..."
;info "autor: Tomasz Adamiak"

(mult( s (loud -3 (at 0.02 s))))

so, as you guys may see, I’m dealing with a basics here, but I can’t move forward without them, so please, help me.

I think that’s probably the wrong sort of filter to use for a wah effect as it passes all frequencies equally. All-pass filter - Wikipedia
Also, the “hz” parameter must be a FLONUM (floating point number) and not a sound, so you can’t use an oscillator for the “hz” argument.
If you click the “Debug” button for your effect, you should see an error message, something like:

error: bad argument type - #<Sound: #b3a0b450>

Also there is either an error in the manual, or a bug in Nyquist because the manual says that “Q” is optional, but in fact a “q” value is ‘required’.

(hp) (reson) and (areson) can have a sound for the hz parameter, so you could try something like:

;control f "medium frequency" int "[Hz]" 1000 100 4000
;control fl "lfo frequency" real "[Hz]" 1 0.1 5

(reson s (sum f (mult f 0.5 (lfo fl)))(/ f 2.0) 2)

Yes. See here:

You may be better to use (simrep)

I’d suggest leaving that one for a little while. It’s a lot more complicated that it appears.
Come back to it later, but read this section in the Nyquist manual about the “Transformation Environment” Behavioral Abstraction (I’ve read this section dozens of times, and sometimes I still get caught out by it).

Thanks so much Steve for your help. I’ll check out if I can make it work now and let you know how it went. Thanks again.

I have found another problem: I wanted to implement simple distortion, which looks like that:

;nyquist plug-in
;version 1
;type process
;name "Distortion"
;action "distortion effect..."
;info "autor: Tomasz Adamiak"

;control d "gain" int "[dB]" 20 0 100

(mult (loud d (cue s)) 0.8)

it’s very simple, the idea was to gain sound so much that it would be clipping and then scale it with mult. My problem is that as clipping itself works properly, the mult doesn’t, there is an error in nyquist and I have no idea why. Is there any way to do this differently or fix it?

(mult) operates on numbers and sounds, but your code is attempting to apply it on a “behaviour”.
In other words, you’re making it more complicated than it really is.

To amplify a sound, all you need is (mult number sound).
Note that this is identical to (mult sound number).

For (but not for multiplying two numbers) there is an alternative function: (scale)
However, if using (scale), the order of the arguments IS important: (scale number sound)
You can “scale”, by a “factor” a given sound.
(scale sound number) is not valid.

If you are using 32 bit audio in Audacity 1.3.12, you can amplify audio above 0 dB and it will not clip.
It will distort horribly if you play it due to the limitations of sound cards, but the data itself will not be truncated as the 32 bit (float) format can express numbers greater than +/- 1.

To “force” the sound to clip, use the function (clip) http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/manual/part6.html#index498

For example, to cause a sound to clip at +/- 0.8

(clip s 0.8)

I used the exact formula you typed, Steve (thx btw), it compiles and everything but the function itself has no effect whatsoever on the sound, it simply remains the same,I don’t know why. Have you tried using it? Oh, and I have another problem, I wanted to use pitshift function ( http://www-2.cs.cmu.edu/~rbd/doc/nyquist/part8.html#index464 ) both to make chorus and pitchshifter, but there is error that this function does not exist (I use the newest audacity version, 1.2.6) do I need to include or install some special libaries? if yes, where do I get them. I have similar problem with span function ( http://www-2.cs.cmu.edu/~rbd/doc/nyquist/part15.html#index1215 ), I wanted to use it, cause normal pan does not work with stereo sounds. Is there any other alternative?

That is probably the main cause of the problem.
There has been no official “stable” release of Audacity for many years. Audacity 1.2.6 was the last version to have the title “stable” attached to it, but the name is misleading because on most computers Audacity 1.3.12 is a lot more reliable than the 1.2.6 version (because Audacity 1.2.6 is now very old and does not work well on newer machines and modern operating systems).

All development over the past few years has been on the 1.3.x version of Audacity and Audacity 1.3.12 is the latest and best version.

Nyquist has been substantially updated in Audacity 1.3.12 and there are many Nyquist functions available in Audacity 1.3.12 that were either missing, or did not work correctly in Audacity 1.2.6. Also, Audacity 1.2.6 uses an obsolete version of Nyquist, so much of the current documentation does not apply to the version of Nyquist in Audacity 1.2.6.

We are hoping that the new Audacity 2.0 will be released in the near future. Audacity 2.0 will be based on the current 1.3.x series, so plug-ins created for Audacity 1.3.12 should work without modification in Audacity 2.0.

I would highly recommend that you update to Audacity 1.3.12 (available from here: Audacity ® | Downloads )