721
edits
Line 34: | Line 34: | ||
We want to code a so called envelope follower, it tracks the peaks of our audio signal and gets the rough volume shape. With the help of the volume (~loudness) of our signal we can detect wether there is vibration on our piezo or not. In rough terms we get the volume envelope in two steps: | We want to code a so called envelope follower, it tracks the peaks of our audio signal and gets the rough volume shape. With the help of the volume (~loudness) of our signal we can detect wether there is vibration on our piezo or not. In rough terms we get the volume envelope in two steps: | ||
# Get the maximum (peak) of the signal samples seen so far (this is also called a peak hold circuit [[File:peak_hold.png|800px]] | # Get the maximum (peak) of the signal samples seen so far (this is also called a peak hold or peak detector circuit [[File:peak_hold.png|800px]] | ||
# Multiply this maximum with a decay factor (<1) for every new sample, or sample block (envelope follower) [[File:envelope_follower.png|800px]] | # Multiply this maximum with a decay factor (<1) for every new sample, or sample block (envelope follower) [[File:envelope_follower.png|800px]] | ||