Plot any audio signal using Python!

Code snippet to plot an audio signal in Python


  1. Function plot_signal() plots the given signal using the passed-in time base (if given).
  2. Function plot_signal_and_save() calls plot_signal() and then saves the figure to the disk while making sure that the output_path exists. You can show the figure with but when you use it, you won’t be able to save the figure as a file.
  3. The main() function generates an example waveform (with time), plots it and saves to the disk using plot_signal_and_save().

Code explanation video

Watch how this code was written and why I included particular lines in this explainer video:

Want to know what knowledge from digital signal processing in needed for audio programming? Check out my free Audio Plugin Developer Checklist!