Frequency listener

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.
Frequency-Listener.ny (2.5 KB)

“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?

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:

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

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

;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:

(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."))

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.

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:

(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:

;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.

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.
Frequency-Listener.ny (448 Bytes)
Frequency-Listener tone.ny (367 Bytes)

Would it be even more efficient to have a parametric eq effect that used numeric text input instead of the “magic” selection?

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.

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.