I'm wondering if I can extract a sequence of musical notes from a recorded sound using Python.
It is the first time I'm considering using Python for this.
Help would be truly awesome :)
open() This function opens a file to read/write audio data. The function needs two parameters - first the file name and second the mode. The mode can be 'wb' for writing audio data or 'rb' for reading.
After successful execution of the program, audio file will start playing. Now Click on terminal, once you see the cursor, type Ctrl+C , it will bring you out of the terminal and audio will also stop playing.
Recording AudioThe python-sounddevice and pyaudio libraries provide ways to record audio with Python. python-sounddevice records to NumPy arrays and pyaudio records to bytes objects. Both of these can be stored as WAV files using the scipy and wave libraries, respectively.
Play sound on Python is easy. There are several modules that can play a sound file (. wav).
What you would want to do is take your audio samples, convert them into the frequency domain with a Fast Fourier Transform (FFT), find the most powerful frequency in the sample, and convert that frequency into a note.
See FFT for Spectrograms in Python for pointers to libraries to help with the first two items. See http://80.68.92.234/sigproc.html for some sample code to get you started.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With