plotOnsets¶
- maelzel.snd.features.plotOnsets(samples, sr, onsets, onsetbpf=None, samplesgain=20, envalpha=0.8, samplesalpha=0.4, onsetsalpha=0.3, figsize=None, offsets=None)[source]¶
Plot the results of onsets detection
- Parameters:
samples (
ndarray
) – the samples from which onsets were detectedsr (
int
) – the sr of samplesonsets (
ndarray
) – the onsets as returned via onsetsRositaonsetbpf (
Optional
[BpfBase
]) – the onsetbpf as returned via onsetsRositasamplesgain – a gain to apply to the samples for plotting
envalpha – alpha channel for onsets strength
samplesalpha – alpha channel for samples plot
onsetsalpha – alpha channel for onsets
offsets (
Union
[ndarray
,list
[float
],None
]) – if given, a region is plotted instead of a line. An offset of 0 indicates that the given onset has no offset and in this case also a line will be plotted
- Return type:
None
Example
>>> from maelzel.snd.audiosample import Sample >>> from maelzel.snd import features >>> s = Sample("/path/to/sndfile.wav").getChannel(0) >>> onsets, onsetstrength = features.onsets(s.samples, s.sr) >>> features.plotOnsets(samples=s.samples, sr=s.sr, onsets=onsets, ... onsetbpf=onsetstrength)