How To Plot An Audio Signal In Python Using Matplotlib | Tutorial For Beginners

Posted by Jan Wilczek on February 01, 2024 · 1 min read

Plot any audio signal using Python!

Code snippet to plot an audio signal in Python

Explanation:

  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 plt.show() 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:

Please accept marketing cookies to access the video player.

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

Share this page on:

Comments powered by Talkyard.

Please accept marketing cookies to access the display and add comments.