1

I need to extract the sound wave envelope from a set of audio files in a batch job on a headless Linux host.

I think this can be achieved using the Nyquist programming language, a variant of Lisp notably embedded in audacity, and dedicated to sound processing. However, if I have some familiarities with Lisp, I don't have any previous experience with Nyquist.

Is there some primitive in Nyquist to achieve that directly? Or how can I write a short Nyquist program to extract the envelope of a sound?


I tried using the snd-avg function. But it does not seem to produce a smooth envelope (upper half in the screenshot):

(snd-avg
  (aref *track* 0)                 ; first sound
  (truncate (/ *sound-srate* 50))  ; 50 Hz to samples
  1 op-peak)                       ; follow peak values

Envelope obtained using <code>snd-avg</code>

Sylvain Leroux
  • 50,096
  • 7
  • 103
  • 125
  • 1
    Maybe have a look over here: https://www.mathworks.com/help/signal/ug/envelope-extraction-using-the-analytic-signal.html I have no idea how you would do it in your language, but using the Hilbert transform (or a pair of Hilbert-transform-related filters) is the first thing I would try. – Matt Timmermans Nov 20 '19 at 02:56
  • Thanks a lot, @Matt, that was a very useful reading! – Sylvain Leroux Nov 20 '19 at 09:49

1 Answers1

0

I obtained decently good results by applying a low-pass filter after snd-avg in order to remove the staircase ripples:

(lp 
  (snd-avg
    (aref *track* 0)
    (truncate (/ *sound-srate* 1000)) ; 1kHz
    1 op-peak)
  50)                                 ; 50 Hz low-pass

enter image description here

Sylvain Leroux
  • 50,096
  • 7
  • 103
  • 125