Question regarding narrowband noise

Help for Audacity on macOS.
Forum rules
ImageThis forum is for Audacity on macOS 10.4 and later.
Please state which version of macOS you are using,
and the exact three-section version number of Audacity from "Audacity menu > About Audacity".


Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
Post Reply
ottoaudacity
Posts: 4
Joined: Wed Nov 04, 2015 12:19 am
Operating System: macOS 10.15 Catalina or later

Question regarding narrowband noise

Post by ottoaudacity » Wed Nov 04, 2015 12:22 am

So I have a dilemma and after attempting a few different options I am stumped and am hoping somebody on this forum can assist me.

Here is what I would like to do: Create a 300 ms narrowband noise with center frequency x, a 1/4 octave bandwidth, and a cosine squared rise/fall envelope.

Any help is greatly appreciated!

steve
Site Admin
Posts: 80751
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Question regarding narrowband noise

Post by steve » Wed Nov 04, 2015 1:19 am

Add a new track ("Tracks" menu).
Select part of the track where you want to make the noise,
then copy and paste this code into the Nyquist Prompt effect (See: http://manual.audacityteam.org/o/man/ny ... rompt.html)

Code: Select all

(setf cf 1000) ;centre frequency
(setf bw 0.25) ;bandwidth in octaves

(defun raised-cosine ()
  (mult 0.5
    (sum 1
      (osc (hz-to-step (get-duration 1)) 1 *table* -90))))

(defun bandpass (sig hz width)
  (let ((high-hz (* hz (power 2.0 (* 0.5 width))))
        (low-hz (/ hz (power 2.0 (* 0.5 width)))))
    (highpass8
      (lowpass8 sig high-hz)
      low-hz)))

(mult (bandpass (noise) cf bw)(raised-cosine))
The first line sets the centre frequency and the second line sets the bandwidth in octaves.
The filter is an 8th order Butterworth highpass / lowpass in series, which should give pretty good narrowband performance.
Apply the Amplify effect as required after generating the noise (see: http://manual.audacityteam.org/o/man/amplify.html).

For more information about Nyquist scripts, see: http://wiki.audacityteam.org/wiki/Nyqui ... _Reference
Note that we also have a forum board specifically for discussion about Nyquist: http://forum.audacityteam.org/viewforum.php?f=39
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Robert J. H.
Posts: 3633
Joined: Thu May 31, 2012 8:33 am
Operating System: Windows 10

Re: Question regarding narrowband noise

Post by Robert J. H. » Wed Nov 04, 2015 4:39 am

steve wrote:Add a new track ("Tracks" menu).
Select part of the track where you want to make the noise,
then copy and paste this code into the Nyquist Prompt effect (See: http://manual.audacityteam.org/o/man/ny ... rompt.html)

Code: Select all

(setf cf 1000) ;centre frequency
(setf bw 0.25) ;bandwidth in octaves

(defun raised-cosine ()
  (mult 0.5
    (sum 1
      (osc (hz-to-step (get-duration 1)) 1 *table* -90))))

(defun bandpass (sig hz width)
  (let ((high-hz (* hz (power 2.0 (* 0.5 width))))
        (low-hz (/ hz (power 2.0 (* 0.5 width)))))
    (highpass8
      (lowpass8 sig high-hz)
      low-hz)))

(mult (bandpass (noise) cf bw)(raised-cosine))
The first line sets the centre frequency and the second line sets the bandwidth in octaves.
The filter is an 8th order Butterworth highpass / lowpass in series, which should give pretty good narrowband performance.
Apply the Amplify effect as required after generating the noise (see: http://manual.audacityteam.org/o/man/amplify.html).

For more information about Nyquist scripts, see: http://wiki.audacityteam.org/wiki/Nyqui ... _Reference
Note that we also have a forum board specifically for discussion about Nyquist: http://forum.audacityteam.org/viewforum.php?f=39

If the raised cosine has to be squared, just duplicate the variable in the last line like so:

Code: Select all

(mult (bandpass (noise) cf bw)(raised-cosine) (raised-cosine))

ottoaudacity
Posts: 4
Joined: Wed Nov 04, 2015 12:19 am
Operating System: macOS 10.15 Catalina or later

Re: Question regarding narrowband noise

Post by ottoaudacity » Sun Feb 21, 2016 6:06 pm

Hello again,

I was hoping to get some help with the previous Nyquist script that you have written me. Just as a catch up (and some more detail than I provided last time) I am hoping to create a 300 ms NBN signal centered around a given frequency with a 1/4 octave bandwidth. I would like to apply a cosine squared envelope with a rise time of 10 ms at the onset of the stimulus (0-10 ms) and a fall time of 1 ms (299-300 ms) at the offset of the stimulus.

My original plan was to then enter in a silent gap of variable duration immediately following the 300 ms NBN signal and then another 300 ms NBN signal following the silent gap which is the exact same as the previously described signal except with a rise time of 1 ms and a fall time of 10 ms. I have been playing around with Nyquist (in addition to attempting to learn LISP) and Audacity for some time but cannot figure out just the right solution. It seems my complete lack of knowledge of computer languages has halted my progress.

When I enter the Nyquist script in this thread for 1000 Hz (as an example) and amplify the result I end up with something looking like the attached file.
1000 Hz.aup
(1.43 KiB) Downloaded 46 times
It appears that the Nyquist script applies one long rise envelope such that it takes the entire 300 ms for the signal to reach peak amplitude.

Is there any way that I can alter the Nyquist script to meet my needs? Any help would be greatly appreciated. Thank you.

Post Reply