An audio effect to extend the sustain of a musical note in real-time is implemented on a fixed point, standalone processor. Onset detection is used to look for new musical notes, and once they decay to steady state, the audio is looped indefinitely until a new onset comes along. To properly loop the audio, pitch detection is performed to extract a period and the new output buffer is written in a phase aligned manner.
Guitar pedals are a ubiquitous part of a guitarist's repertoire and there exist a wide variety that have have been extensively researched and developed. While looping pedals are commonplace, we realised sustain pedals were less heard-of. So, we went about designing a cheap software implementation of an "infinite" sustain pedal on an embedded fixed point processor. We did this as a final project for EE 264 and used the DSP Shield board that has a dedicated TI C5535 DSP chip for development. The project report explaining the algorithm we used can be found here. A github repository containing all the code can be found here.
For onset detection, we use a one-pole leaky integrator with a very fast attack time and a slow decay time. This detector is also able to detect signals with small dynamic range. For pitch detection, we utilize the Average Magnitude Pitch Detection Function (AMDF) which dips periodically whenever the lag number is a multiple of the pitch period. We also use parabolic interpolation to find local minima more accurately. An overview can be found in this presentation.
Pitch detection does not work very well for notes on the lower E string. The buffer size of 1024 is too small for accurate pitch detection of low frequency notes. We need to adaptively increase the size of the signal stored for lower frequency notes. The flat amplitude envelope of the sustain is not musically interesting, and some amplitude modulation with a very small modulation index will make it sound much better. A sine function can be generated iteratively on the fixed point processor using the 'Magic Circle'.