First draft of decibel-detection code, imported from GDK Waveform example.