How To Plot Magnitude Spectrum of Audio Signal with Python and Matplotlib | Tutorial for Beginners

preview_player
Показать описание
✅ Please subscribe to WolfSound to let the little Wolf 🐺 grow:

Hi, my name is Jan Wilczek. I am an audio programmer and a researcher. Welcome to WolfSound!

WolfSound enables everybody to learn about audio programming!

ABOUT THE VIDEO

In digital signal processing (DSP), we often compute the discrete Fourier transform (DFT) of an audio signal, for example, using the Fast Fourier Transform (FFT). This tutorial shows you how to easily display the magnitude of the DFT, the magnitude spectrum, using the Matplolib library in Python.

The script includes examples of how to include decibels full-scale (dBFS) scaling of the magnitude axis and a logarithmic frequency axis for a better interpretability of the graph.

In the video:

✅ Which libraries to use
✅ How to effortlessly compute the FFT of an audio signal
✅ Step-by-step writing of the plot_magnitude_spectrum functions
✅ How to plot the magnitude in decibels full-scale (dBFS)
✅ How to plot the frequency axis logarithmically which corresponds to our perception of pitch
✅ How to mark the frequency axis using the ISO-standardized octave band marks
✅ How to adjust the figure to your needs (colors, labels, font size, markersize and more)
✅ How to export your figure to a .png file with transparent background effortlessly
✅ How to adjust the limits of the plot properly for optimal readability

ABOUT ME

FOLLOW WOLFSOUND ONLINE

TIME CODES

00:00 Introduction
00:40 Installing necessary libraries using a virtual environment
02:12 Reading an example audio file with soundfile
04:07 Calculating the magnitude spectrum (absolute value of the FFT)
07:00 Plot magnitude spectrum with linear magnitude and frequency axis
12:46 How to save the figure as a file
16:20 Plot the magnitude in decibels
21:02 Plot the frequency axis logarithmically
24:44 Bonus: How to easily create audio plugins and musical apps

#audio #python
Рекомендации по теме
Комментарии
Автор

this is so strange i was literally researching how to do exactly this about a week ago haha. i figured it out but cant wait to see how to do it better lol

yzhkkhzy
Автор

Finally a tutorial that takes it all the way! Figuring every step out on your own is really time consuming and ChatGPT isn't amazing that these details. I only have one question: what if you don't want to normalize the amplitude, but rather show the "true" volume? Meaning if I plot a sine wave exported at -20dB it would show up at -20dB in the spectrum. Thanks!

LinusCorneliusson
Автор

Cześć! Mam do Ciebie zapytanie biznesowe, ale nie mogę nigdzie znaleźć emaila do Ciebie. Czy jest opcja na kontakt bezpośredni z Tobą? :)

k.pietras