Note: this widget is not currently available on Android devices
This widget reads performs signal processing to determine the pitch of audio entering the microphone. There are two different algorithms to determine pitch: counting zero-crossings and using the harmonic product spectrum. Harmonic product spectrum will normally give the best results. Neither method, as implemented currently, is incredibly accurate. If you have some DSP chops and would like to improve the algorithms or implement another, please have at it! Here is a page that describes various techniques for pitch detection, including harmonic product spectrum:
https://ccrma.stanford.edu/~pdelac/154/m154paper.htm
Additional JSON Attributes
- mode : determines the algorithm used to calculate pitch (as described above). The default value is “hps”, the other option is “zero”.
Scripting
Properties
- pitch – the MIDI note number corresponding to the last calculated pitch
- octave – the octave containing the pitch
- number – the number of the note where C = 0 and B = 11
- note name – the combined octave and the number of the pitch represented as a string. For example, “C#4”
- freq – the calculated frequency in Hz
- freqs – an array of the frequencies calculated that can be used to obtain an average result over time
- maxFreqs – the maximum length of the freqs array. The default value is 4. Note this cannot currently be assigned via JSON, it must be changed via scripting.
Methods
- start – begin examining microphone input and generating pitch output
- stop – stop generating output
Simple JSON
{ "name": "pitch", "type": "AudioPitch", "mode": "hps", "min": 0, "max": 1, },