.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plotting/plot_waveform_and_spectrum.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plotting_plot_waveform_and_spectrum.py: Waveform, spectrum and spectrogram ================================== The three most used figures, drawn into one Matplotlib figure with ``ax=``. .. GENERATED FROM PYTHON SOURCE LINES 7-13 .. code-block:: Python import matplotlib.pyplot as plt import audio_samples as aus from audio_samples import mpl .. GENERATED FROM PYTHON SOURCE LINES 14-24 .. code-block:: Python sr = 22050 audio = aus.generation.compound_tone([(330.0, 0.6), (660.0, 0.3), (990.0, 0.1)], 1.0, sr).as_f32() audio.fade_in(0.1, aus.FadeCurve.linear) audio.fade_out(0.3, aus.FadeCurve.linear) fig, axes = plt.subplots(3, 1, figsize=(7, 7)) mpl.plot_waveform(audio, show_envelope=True, ax=axes[0]) mpl.plot_magnitude_spectrum(audio, freq_max=4000.0, ax=axes[1]) mpl.plot_spectrogram(audio, freq_max=4000.0, ax=axes[2]) fig.tight_layout() .. image-sg:: /gallery/plotting/images/sphx_glr_plot_waveform_and_spectrum_001.png :alt: Waveform, Magnitude Spectrum, Spectrogram :srcset: /gallery/plotting/images/sphx_glr_plot_waveform_and_spectrum_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.260 seconds) .. _sphx_glr_download_gallery_plotting_plot_waveform_and_spectrum.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_waveform_and_spectrum.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_waveform_and_spectrum.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_waveform_and_spectrum.zip `