That’s not quite the same task.
Addressing the first proposition - finding sounds that have a strong high frequency content would be quite a simple modification to “Sound Finder”.
All you would need to do is to apply a high pass filter to the audio that is being analysed.
Open “soundfinder.ny” in a plain text editor (if you use Windows I’d recommend Notepad++ )
At lines 16 to 18 you’ll see the following:
;Create a function to make the sum the two channels if they are stereo
(defun mono-s (s-in) (if (arrayp s-in) (snd-add (aref s-in 0) (aref s-in 1))
s-in))
This function provides the sound to be analysed and ensures that the audio being analysed is mono.
The function is not actually correct as it causes stereo tracks to be summed which makes the threshold level wrong for stereo tracks.
Better would be the maximum of left and right channels:
;;; Make signal mono
(defun mono-s (s-in)
(if (arrayp s-in)
(s-max
(snd-abs (aref s-in 0))
(snd-abs (aref s-in 1)))
s-in))
To detect high frequencies only, all we need to do is to filter this signal appropriately, for example:
;;; Make signal mono
(defun mono-s (s-in)
(let ((s-in (highpass8 s-in freq)))
(if (arrayp s-in)
(s-max
(snd-abs (aref s-in 0))
(snd-abs (aref s-in 1)))
s-in)))
Which will pre-filter the input signal with a steep (48 dB per octave) high pass filter at a frequency set by “freq”.
The variable “freq” needs to be global as we have not included it as an argument of the function, but that works fine if we want to make it adjustable.
We can add a frequency control with our other controls:
(lines 8 to 12)
;control sil-lev "Treat audio below this level as silence [ -dB]" real "" 26 0 100
;control sil-dur "Minimum duration of silence between sounds [seconds]" real "" 1.0 0.1 5.0
;control labelbeforedur "Label starting point [seconds before sound starts]" real "" 0.1 0.0 1.0
;control labelafterdur "Label ending point [seconds after sound ends]" real "" 0.1 0.0 1.0
;control finallabel "Add a label at the end of the track? [No=0, Yes=1]" int "" 0 0 1
Add the new control:
;control sil-lev "Treat audio below this level as silence [ -dB]" real "" 26 0 100
;control sil-dur "Minimum duration of silence between sounds [seconds]" real "" 1.0 0.1 5.0
;control labelbeforedur "Label starting point [seconds before sound starts]" real "" 0.1 0.0 1.0
;control labelafterdur "Label ending point [seconds after sound ends]" real "" 0.1 0.0 1.0
;control finallabel "Add a label at the end of the track? [No=0, Yes=1]" int "" 0 0 1
;control freq "Detects sounds above (Hz)" int "" 0 0 10000