[aubio-user] Onset detection in Python

Paul Brossier piem at piem.org
Mon Mar 17 23:15:51 CET 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 17/03/2014 18:13, Lukasz Tracewski wrote:
> Hi,
> 
> 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?

Hi Lukasz,

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
of all.

> 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! :)

Paul
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.18 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlMndBcACgkQkuC958YALL1vBgCgrS4TL3QbsEIewOsavSxaxObB
Ap4AoKhB5qqadVdbCXpMJnOkpF6u+q8w
=9NVU
-----END PGP SIGNATURE-----



More information about the aubio-user mailing list