liamtoney / sonify

Sonification of seismic and infrasound signals
https://sonify.rtfd.io
MIT License
32 stars 2 forks source link

Implement an audio compression option #16

Open liamtoney opened 10 months ago

liamtoney commented 10 months ago

Some seismic or infrasound signals have a large dynamic range, which is not ideal for playback at low volumes or on small systems. The default Alaska avalanche signal is a good example of this, where the large-amplitude failure is much, much louder than the precursory seismicity. While applying audio compression (side note — in the field of seismology, automatic gain control does sort of the same thing) to "smooth" the loudness variations would make the mapping from physical amplitude to loudness less clear, it could help make some sonifications easier to hear.

Here's some Python source code for audio compression: https://github.com/jiaaro/pydub/blob/master/pydub/effects.py#L115-L187 — might be overkill?

liamtoney commented 10 months ago

Actually, FFmpeg can do dynamic range compression, see: https://medium.com/@jud.dagnall/dynamic-range-compression-for-audio-with-ffmpeg-and-compand-621fe2b1a892