plotWaveform

maelzel.snd.plotting.plotWaveform(samples, samplerate, profile='', saveas='', timelabels=True, figsize=(24, 4))[source]

Plot the waveform of a sound using pyplot

Parameters:
  • samples – a mono or multichannel audio array

  • samplerate (int) – the sr

  • profile – one of ‘low’, ‘medium’, ‘high’, ‘highest’. If not given a preset is chosen based on the duration and other parameters given

  • saveas – if given, the plot is saved and not displayed

  • timelabels – if True, the x axes’ labels are shown as MM:SS if needed

  • figsize – the figsize used

Return type:

list[Axes]

Returns:

the axes used (one per channel)

Example

>>> from maelzel.snd import plotting
>>> import sndfileio
>>> samples, info = sndfileio.sndget("snd/bach-presto-gmoll.mp3")
# In this case the preset used will be 'high'
>>> plotting.plotWaveform(samples, info.sr)
../_images/snd-plotting-plotWaveform-high.png
>>> plotting.plotWaveform(samples, info.sr, preset='low')
../_images/snd-plotting-plotWaveform-low.png
>>> plotting.plotWaveform(samples, info.sr, preset='medium')
../_images/snd-plotting-plotWaveform-medium.png
>>> plotting.plotWaveform(samples, info.sr, preset='high')
../_images/snd-plotting-plotWaveform-high.png
>>> plotting.plotWaveform(samples, info.sr, preset='highest')
../_images/snd-plotting-plotWaveform-highest.png