Part One: Identifying a Note
It is not straight forward to decode wave/signal data into a musical note. Rather than a simple measure of frequency, a more complex algorithm is required that takes into account the changing nature of sound data across a sample (e.g. harmonics), a process called autocorrection.
Controller Board: Arduino MKR 1010 – https://store.arduino.cc/products/arduino-mkr-wifi-1010
Implement and expand example found on Arduino & Instructables site. Original code and project by http://www.akellyirl.com/. Adapting this base code to run on Arduino MKR1010.
Arduino forum (https://forum.arduino.cc/t/arduino-pitch-detection-in-realtime-using-autocorrelation-and-peak-detection/519783), Instructables (https://www.instructables.com/Reliable-Frequency-Detection-Using-DSP-Techniques/), Reference GitHub Code (https://github.com/akellyirl/AutoCorr_Freq_detect).
- Download the code from GitHub.
- Insert into sketch files (remember headers which contains example data).
- Add additional code to give a lettered output – e.g. ‘C4’.
Serial Baud-rate was not compatible with different hardware. Set to 19200 instead.
Input test file correctly identified.
Part 2: Getting audio from a sensor (microphone)
Sampling audio data requires a microphone component. In this case I used the MAX9814, a common basic microphone component.
- Controller Board: Arduino MKR 1010 – https://store.arduino.cc/products/arduino-mkr-wifi-1010
The microphone component needs to be wired to 0v and 5 v for power, and uses a single anologue pin for output: https://electropeak.com/learn/interfacing-max9814-electret-microphone-amplifier-module-with-arduino/
Wire and code as in above exmaple and audio it output into the serial monitor.