Frequency listener

Share your Audacity/Nyquist plug-ins here, or test drive the latest plug-ins submitted by Audacity users.

After testing a plug-in from this forum, please post feedback for the plug-in author.
Post Reply
Felipe Zanabria
Posts: 116
Joined: Fri Mar 16, 2018 1:38 am
Operating System: Windows 7

Frequency listener

Post by Felipe Zanabria » Sun Dec 13, 2020 7:00 pm

Hello! I am visually impaired, but have still found a utility for Audacity's spectral view. I found that there are commands to select low and high frequency peaks, so I have assigned keyboard shortcuts to be more efficient. This helped me a lot when equalizing voices, as it is easier to find problem frequencies. Upon finding a peak, I open the spectral parametric eq effect, increase the gain, and listen to the preview to hear the frequency peak in question. This is a bit tedious because I have to go up to see what it is, and then go down to find the balance. I edited the plug-in file and did this: A one-second sine wave that reproduces the center frequency, also with a keyboard shortcut. The problem I have is in the audio of the track. When running the plug-in, the sound of the track is replaced by an unwanted sound, which I would like to avoid. The sine tone must be played and not modify the track. Thanks for the help.
Attachments
Frequency-Listener.ny
(2.5 KiB) Downloaded 104 times

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

Re: Frequency listener

Post by steve » Mon Dec 14, 2020 12:29 pm

"Preview" is only available for "Generate" and "Process" type plug-ins, and only available for plug-ins that have a GUI.

I'm not entirely certain what you are trying to do. Do you want an effect that can play a sine tone at the "spectral" centre frequency when you press a key? Do you want to hear just the sine tone, or the sine tone mixed with the selected audio?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Felipe Zanabria
Posts: 116
Joined: Fri Mar 16, 2018 1:38 am
Operating System: Windows 7

Re: Frequency listener

Post by Felipe Zanabria » Mon Dec 14, 2020 4:51 pm

I quickly edited the file and some parts of the code I don't understand. I want to play only the sine wave, without modifying the audio. It would be like writing this in nyquist:

Code: Select all

(play (hzosc 250)) [/ code] I would also like to avoid the window that appears after playin.

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

Re: Frequency listener

Post by steve » Mon Dec 14, 2020 6:44 pm

Try this:
Frequency-Listener.ny
(595 Bytes) Downloaded 35 times
This is the code:

Code: Select all

;nyquist plug-in
;version 4
;type process
;name "Frequency listener"
;copyright "Released under terms of the GNU General Public License version 2"

(cond
  ((get '*selection* 'center-hz)
    (play (extract-abs 0 1 (mult 0.5 (hzosc (get '*selection* 'center-hz)))))
    "")
  (t "Error.\nSpectral selection with upper and lower frequencies required."))

  • "center-hz" is only present when both the high and low bounds of the spectral selection are defined.
  • If "center-hz" is not present, then (get '*selection* 'center-hz) returns "NIL" and the "COND" returns the error message "Error.\nSpectral selection with upper and lower frequencies required."
  • If "center-hz" is present, then its value is used by HZOSC, and the function returns an empty string which acts as a valid "no-op" (the plug-in does nothing).
  • "MULT 0.5" reduces the level of the tone to about -6 dB.
  • "EXTRACT-ABS 0 1" restricts the length of the tone to a maximum of 1 second. Once the effect is run the sound cannot be stopped until it gets to the end. In the absence of the "EXTRACT-ABS" command, the sound would play for the duration of the selection.
I think that covers everything, but if you have any questions, feel free to ask.
Just for interest, this is the code that plays a mix of the selection and the centre frequency:

Code: Select all

(cond
  ((get '*selection* 'center-hz)
    (play (extract-abs 0 1 (mult 0.4 (sum (hzosc (get '*selection* 'center-hz)) *track*))))
    "")
  (t "Error.\nSpectral selection with upper and lower frequencies required."))

9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Felipe Zanabria
Posts: 116
Joined: Fri Mar 16, 2018 1:38 am
Operating System: Windows 7

Re: Frequency listener

Post by Felipe Zanabria » Mon Dec 14, 2020 6:54 pm

Perhaps your second code could be used with a band pass filter. Let's say I want to hear the problem frequency in question. Then the tone would be removed and the filtered signal would be added, perhaps with a duration of 6 or 10 seconds.

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

Re: Frequency listener

Post by steve » Mon Dec 14, 2020 7:14 pm

To adjust the maximum length that will be played, adjust the numbers in the "EXTRACT-ABS" command. The first number is the start time and should remain as zero, the second number is the end time and can be anything you like, but remember the sound cannot be stopped or paused.
Example: for 3 seconds duration:

Code: Select all

(play (extract-abs 0 3 ...
For more complex mixing options it would probably be best to move the mixing into a separate function. For example, to band-pass at the centre frequency and play for 5 seconds:

Code: Select all

;nyquist plug-in
;version 4
;type process
;name "Frequency listener"
;copyright "Released under terms of the GNU General Public License version 2"

(defun mymix (hz)
  (mult 0.4
      (sum (hzosc hz)
           (bandpass2 *track* hz 0.72))))

(cond
  ((setf cf (get '*selection* 'center-hz))
    (play (extract-abs 0 5 (mymix cf)))
    "")
  (t "Error.\nSpectral selection with upper and lower frequencies required."))

The width ("Q") of the bandpass filter is the final argument of BANDPASS2 (currently 0.72) higher numbers provide a narrower width.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Felipe Zanabria
Posts: 116
Joined: Fri Mar 16, 2018 1:38 am
Operating System: Windows 7

Re: Frequency listener

Post by Felipe Zanabria » Tue Dec 15, 2020 12:29 am

Hi Steve, your code doesn't work on stereo tracks. I have added a multichan-expand and the problem is fixed.
I know the extract-abs and bandpass2 function.
I don't want to hear the tone along with the audio, just the isolated center frequency.
Below I will leave the two plug-ins.
Attachments
Frequency-Listener tone.ny
(367 Bytes) Downloaded 29 times
Frequency-Listener.ny
(448 Bytes) Downloaded 31 times

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

Re: Frequency listener

Post by steve » Tue Dec 15, 2020 6:35 pm

Felipe Zanabria wrote:
Sun Dec 13, 2020 7:00 pm
I found that there are commands to select low and high frequency peaks, so I have assigned keyboard shortcuts to be more efficient.
Would it be even more efficient to have a parametric eq effect that used numeric text input instead of the "magic" selection?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Felipe Zanabria
Posts: 116
Joined: Fri Mar 16, 2018 1:38 am
Operating System: Windows 7

Re: Frequency listener

Post by Felipe Zanabria » Wed Dec 16, 2020 5:20 pm

It's efficient, I have even used the nyquist parametric eq from the Audacity wiki, but currently I use single band parametric eq from the ladspa 90 plug-in package, having the ability to search the frequency with realtime preview. The problem is that at low and mid frequencies, each keystroke to move the slider skips some frequencies. For example, I'm at 200hz, then I press a key to increase the value, the result I get can be 230hz, jumping 210, 220. It has a numeric text field, but I feel like I don't buy the center frequency right. At high frequencies it is easier for me since the changes are gradual. Likewise, I apply in few parts of the spectrum. I previously used the vst sh graphic eq, which is linear in phase, having the ability to adjust the controls while listening. Just a curiosity: does Nyquist have any variables that take the peak amplitude of the selected frequency in the spectrum? That is, do not do the calculation with your own functions, but just take the peak from somewhere.

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

Re: Frequency listener

Post by steve » Wed Dec 16, 2020 5:43 pm

Felipe Zanabria wrote:
Wed Dec 16, 2020 5:20 pm
does Nyquist have any variables that take the peak amplitude of the selected frequency in the spectrum?
No. Nyquist has access to the the peak and RMS amplitude of the time selection (all frequencies), but knows nothing about the frequency selection other than the upper / lower limits, centre frequency and bandwidth.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply