[audacity4blind] Re: Noise Generator

  • From: Steve the Fiddle <stevethefiddle@xxxxxxxxx>
  • To: audacity4blind@xxxxxxxxxxxxx
  • Date: Mon, 19 Oct 2015 11:58:35 +0100

That code works OK for me.
Ensure that you have pasted the full 16 lines (that's 16 lines
including line 5 which is an empty line).
If you still get the error, try running it using the Debug button
instead of the OK button.

Steve

On 19 October 2015 at 02:30, Annabelle Susan Morison
<foristnights@xxxxxxxxxxx> wrote:

I've tried this code in Audacity, and I get a message that says. "Nyquist
returned the value 0.100000". I'm confused! Is this some sort of error? Am I
forgetting something?


(setq low-freq 440) ; initial frequency - Hz
(setq hi-freq 1320) ; final frequency - Hz
(setq initial-amp 0.8) ; initial amplitude on a scale 0 to 1
(setq final-amp 0.1) ; final amplitude on a scale 0 to 1

(setq hz1 (min low-freq hi-freq))
(setq hz2 (max low-freq hi-freq))
(setq iamp (max (min initial-amp 1) 0))
(setq famp (max (min final-amp 1) 0))
(mult (pwlv iamp 1 famp)
(fmosc 0
(sum
hz1
(mult
(- hz1 hz2)
(sum -1 (pwev 1 1 0.01))))*saw-table*))

-----Original Message-----
From: audacity4blind-bounce@xxxxxxxxxxxxx
[mailto:audacity4blind-bounce@xxxxxxxxxxxxx] On Behalf Of Steve the Fiddle
Sent: Sunday, October 18, 2015 4:18 PM
To: audacity4blind@xxxxxxxxxxxxx
Subject: [audacity4blind] Re: Noise Generator

You can't just reverse the number in the first two lines because note
these two lines:

(setq hz1 (min low-freq hi-freq))
(setq hz2 (max low-freq hi-freq))

The first of these two lines sets HZ1 to the minimum of LOW-FREQ and HI-FREQ.
Similarly the second sets HZ2 to the maximum of LOW-FREQ and HI-FREQ.

That code overall is rather more complicated than it really needs to
be, but was written like that so that it could be developed into a
more complex plug-in.

This is a simplified version of that perhaps makes it a bit clearer
what is going on:

(setf start-hz 440)
(setf end-hz 1320)
(setf start-amp 0.8)
(setf end-amp 0.1)
(setf mod (pwev start-hz 1 end-hz))
(setf envelope (pwlv start-amp 1 end-amp))
(mult envelope (fmosc 0 mod))

In the above code,:
start-hz is the initial frequency
end-hz is the final frequency
start-amp is the initial amplitude
end-amp is the final amplitude
mod is the modulation signal, which uses start-hz and end-hz.
envelope is the amplitude envelope which uses start-amp and end-amp.
The final line amplifies the FMOSC generator by the amplitude envelope.

In this version you can change the numbers around as you wish. For
example to create a sweep from 1320 Hz down to 440 Hz and the
amplitude increasing from 0.1 to 0.8:

(setf start-hz 1320)
(setf end-hz 440)
(setf start-amp 0.1)
(setf end-amp 0.8)
(setf mod (pwev start-hz 1 end-hz))
(setf envelope (pwlv start-amp 1 end-amp))
(mult envelope (fmosc 0 mod))

Steve

On 18 October 2015 at 23:41, Annabelle Susan Morison
<foristnights@xxxxxxxxxxx> wrote:
Would that be the same if I were to use this code? I think this is one you
previously showed me.

(setq low-freq 440) ; initial frequency - Hz
(setq hi-freq 1320) ; final frequency - Hz
(setq initial-amp 0.8) ; initial amplitude on a scale 0 to 1
(setq final-amp 0.1) ; final amplitude on a scale 0 to 1

(setq hz1 (min low-freq hi-freq))
(setq hz2 (max low-freq hi-freq))
(setq iamp (max (min initial-amp 1) 0))
(setq famp (max (min final-amp 1) 0))
(mult (pwlv iamp 1 famp)
(fmosc 0
(sum
hz1
(mult
(- hz1 hz2)
(sum -1 (pwev 1 1 0.01))))))

-----Original Message-----
From: audacity4blind-bounce@xxxxxxxxxxxxx
[mailto:audacity4blind-bounce@xxxxxxxxxxxxx] On Behalf Of Steve the Fiddle
Sent: Sunday, October 18, 2015 3:31 PM
To: audacity4blind@xxxxxxxxxxxxx
Subject: [audacity4blind] Re: Noise Generator

The part of the code that generates the sound is the function FMOSC.
This function is described in the Nyquist manual here:
http://www.cs.cmu.edu/~rbd/doc/nyquist/part8.html#index378

In our example we don't use the optional "table" or "phase"
parameters. Most of the code is to create the modulation signal.

If you want to create a tone that goes up and down between say 100 Hz
and 1000 Hz, then you need to create a modulation signal that goes up
and down between values of 100 and 1000.

The HZOSC function produces a sine wav that goes up and down between +/- 1.
HZOSC is described here:
http://www.cs.cmu.edu/~rbd/doc/nyquist/part8.html#index368

As you will see from the above link, to make a signal that goes up and
down repeatedly once every 4 seconds, we can use this code:

(hzosc (/ 1.0 4.0))

You wont be able to hear this because the "note" has a frequency of
0.25 Hz, which is far too low to hear, but it is part way to creating
a suitable modulation signal. All that we need to do is to scale it so
that rather than going between +/- 1 it will go between 100 and 1000.

Adding "1" will make it go between 0 and 2.
(sum 1 (hzosc (/ 1.0 4.0)))

Then if we multiply by 450 it will go between 0 and 900
(mult 450 (sum 1 (hzosc (/ 1.0 4.0))))

Then if we add 100, it will be shifted up to go between 100 and 1000.
(sum 100 (mult 450 (sum 1 (hzosc (/ 1.0 4.0)))))

We now have a modulation signal that goes between 100 and 1000.
To make it easier to use, we can assign this as the value of a variable:
(setf mod (sum 100 (mult 450 (sum 1 (hzosc (/ 1.0 4.0))))))

We can now use the variable "mod" in the FMOSC function like this:

(setf mod (sum 100 (mult 450 (sum 1 (hzosc (/ 1.0 4.0))))))
(fmosc 0 mod)


Try substituting different numbers to get a different pitch and
different high/low speed.

Hope that helps to get you started.

Steve

On 18 October 2015 at 20:33, Annabelle Susan Morison
<foristnights@xxxxxxxxxxx> wrote:
I got it to work, however, it only does the windup side of the siren. How
would I make the wind-down of the siren? Would I reverse the order of
frequencies? How about the yelp and piercer tones? Would they be made with
the
same code?

-----Original Message-----
From: audacity4blind-bounce@xxxxxxxxxxxxx
[mailto:audacity4blind-bounce@xxxxxxxxxxxxx] On Behalf Of Steve the Fiddle
Sent: Thursday, June 04, 2015 12:10 PM
To: audacity4blind@xxxxxxxxxxxxx
Subject: [audacity4blind] Re: Noise Generator

That code is written for the Nyquist Prompt.

Steve

On 4 June 2015 at 18:53, Annabelle Susan Morison
<foristnights@xxxxxxxxxxx> wrote:
And I would put this in the Nyquist Prompt? Or would that be the Nyquist
Generate Prompt?

-----Original Message-----
From: audacity4blind-bounce@xxxxxxxxxxxxx
[mailto:audacity4blind-bounce@xxxxxxxxxxxxx] On Behalf Of Steve the Fiddle
Sent: Thursday, June 04, 2015 10:47 AM
To: audacity4blind@xxxxxxxxxxxxx
Subject: [audacity4blind] Re: Noise Generator

Attached is some code that may help to get you started.
The code came from this forum topic and there is additional information
there:
http://forum.audacityteam.org/viewtopic.php?p=159187

Steve

On 4 June 2015 at 17:24, Annabelle Susan Morison
<foristnights@xxxxxxxxxxx>
wrote:
Hi, it's Annabelle.
I know this might sound strange but, I wonder if there's a way for me
to make a noise generator that generates the four common siren tones,
wail, yelp, hyperyelp, and hi-lo? If there is, what would be the code
for me to make these? Also, being blind, how would I make this into a
plugin?



The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe


The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe



The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe


The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe



The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe


The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe



The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe


The audacity4blind web site is at
//www.freelists.org/webpage/audacity4blind

Subscribe and unsubscribe information, message archives,
Audacity keyboard commands, and more...

To unsubscribe from audacity4blind, send an email to
audacity4blind-request@xxxxxxxxxxxxx
with subject line
unsubscribe

Other related posts: