These instructions are for the official Python distribution, which is what I use. You can use whatever distribution you like (Brew, Anaconda, etc.) however I won’t be able to help you with any issues. On the other hand, I’m not a heavy Python user so my help would likely be of limited value anyway.
As of this writing I recommend Python 3.10.9 as 3.11.1 is not supported by Numba, which is a dependency for librosa. You should do your own research on which version you want to run as I won’t necessarily always keep this information current. The good news is you can simply remove and reinstall a different version if you run into package compatibility issues.
To get 3.10.9, go to
https://python.org/downloads. Scroll to the section titled “Looking for a specific release?” and click the download link for Python 3.10.9.
On the next page scroll down to “Files” and choose the macOS 64-bit universal2 installer.
Double-click the installer package from your Downloads folder and follow the defaults to complete installation.
It’s a good idea to keep all the files in the same directory as the script so that you don’t have to worry about specifying paths. For our purposes here we’ll name this folder Plots and place it in the Documents folder. You can name it and put it wherever suits you.
Next we need to install a few libraries. To do this, open Terminal and run the following three commands:
Code:
pip3 install --upgrade pip
pip3 install librosa
pip3 install matplotlib
You’ll want to ensure these processes complete successfully. Installing librosa will install two other required libraries, NumPy and SciPy, so there’s no need to do these separately.
Next launch IDLE, and select File, New File.
Copy and paste the script code from this post in to the “untitled” window, and select File, Save As.
Name the script something that makes sense to you, such as FR14.py – FR for Frequency Response, and 14 as example of the version. It doesn’t really matter, but make the extension .py, and be sure to save it in the folder you created above, which is ~Documents/Plots in our example.
At this point everything should be set for your first plot. Details of the file requirements for what you want to measure will be at the top of the script file, as will be an explanation of all the settings.
Copy your wav file in to the Plots folder and specify its name in the _FILE variable of the script. Don’t forget to update the Infoline to describe your plot. Then simply select Run, Run Module. You’ll be prompted to save the modified script file, after which the script will run.
The next time you run IDLE, simply select File, Open, and select the saved script file.