[aubio-user] Onset detection in Python
piem at piem.org
Mon Mar 17 23:15:51 CET 2014
-----BEGIN PGP SIGNED MESSAGE-----
On 17/03/2014 18:13, Lukasz Tracewski wrote:
> I am using 0.4.1 release of aubio to do onset detection on monaural
> audio that is already in computer's memory. In essence, I am
> loading a WAVE file with scipy, doing some essential filtering and
> only then performing onset detection. What would be the best way?
why would you want to load the entire file in scipy, when you can use
aubio.source? :) it would avoid bloating your memory, and should be much
much faster. besides aubio.source knows how to read much more than wav
files, provided you compile aubio with libav or ExtAudioFileRef.
> Here is what I have:
> onset_detector = onset("energy", window_size, hop_size,
> sample_rate) onsets = 
you will want to use "default", "ernergy" is by far the worst method
> windowed_sample = numpy.array_split(sample, numpy.arange(hop_size,
> len(sample), hop_size)) for frame in windowed_sample: if
> onset_detector(frame): onsets.append(onset_detector.get_last())
that looks correct.
> So in fact it simulates reading file from a disc, following what is
> in examples. One of problems I have with this approach is that I
> am always detecting onset at zero. Is there a smarter solution?
if the file starts with a frame which level is higher than the silence
threshold, that first frame will be marked as an onset.
so you could try using onset_detector.set_silence(-60) for instance, just
after creating onset_detector. Default value is -70, in dB SPL.
> Thanks for the great work!
you're welcome! :)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.18 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
-----END PGP SIGNATURE-----
More information about the aubio-user