From: Paul Brossier Date: Sat, 9 Jan 2010 14:35:53 +0000 (+0100) Subject: merge from master, print beats once in demo_beat.py X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=37eb9ceb5cba5492740af27f78e914c43ecdb3b5;p=aubio.git merge from master, print beats once in demo_beat.py --- 37eb9ceb5cba5492740af27f78e914c43ecdb3b5 diff --cc examples/utils.c index 93b4cab1,6b6e00b6..dd6f91e8 --- a/examples/utils.c +++ b/examples/utils.c @@@ -253,9 -239,24 +237,24 @@@ examples_common_init (int argc, char ** } #endif /* HAVE_LASH */ - uint_t i; - woodblock = new_fvec (overlap_size, channels); ++ woodblock = new_fvec (overlap_size); + if (output_filename || usejack) { + /* dummy assignement to keep egcs happy */ + found_wood = (onsetfile = new_aubio_sndfile_ro (onset_filename)) || + (onsetfile = new_aubio_sndfile_ro ("sounds/woodblock.aiff")) || + (onsetfile = new_aubio_sndfile_ro ("../sounds/woodblock.aiff")); + if (onsetfile == NULL) { + outmsg ("Could not find woodblock.aiff\n"); + exit (1); + } + } + if (onsetfile) { + /* read the output sound once */ - aubio_sndfile_read (onsetfile, overlap_size, woodblock); ++ aubio_sndfile_read_mono (onsetfile, overlap_size, woodblock); + } + - ibuf = new_fvec (overlap_size, channels); - obuf = new_fvec (overlap_size, channels); + ibuf = new_fvec (overlap_size); + obuf = new_fvec (overlap_size); } diff --cc interfaces/python/demo_beat.py index f3c669c7,00000000..07374920 mode 100644,000000..100644 --- a/interfaces/python/demo_beat.py +++ b/interfaces/python/demo_beat.py @@@ -1,28 -1,0 +1,27 @@@ +#! /usr/bin/python + +import sys +from os.path import splitext, basename +from aubio import tempo +from aubioinput import aubioinput + +win_s = 512 # fft size +hop_s = win_s / 2 # hop size +beat = tempo("default", win_s, hop_s) + +beats = [] + +def process(samples, pos): + isbeat = beat(samples) + if isbeat: + thisbeat = (float(isbeat[0]) + pos * hop_s) / 44100. + print thisbeat + beats.append (thisbeat) + +if len(sys.argv) < 2: + print "Usage: %s " % sys.argv[0] +else: + filename = sys.argv[1] + a = aubioinput(filename, process = process, hopsize = hop_s, + caps = 'audio/x-raw-float, rate=44100, channels=1') + a.run() - print beats diff --cc tests/src/test-pitch.c index 00000000,c6d7dd35..e4e209e8 mode 000000,100644..100644 --- a/tests/src/test-pitch.c +++ b/tests/src/test-pitch.c @@@ -1,0 -1,23 +1,22 @@@ + #include + + int main(){ + /* allocate some memory */ - uint_t win_s = 1024; /* window size */ - uint_t channels = 1; /* number of channel */ - fvec_t * in = new_fvec (win_s, channels); /* input buffer */ - fvec_t * out = new_fvec (1, channels); /* input buffer */ - aubio_pitch_t *p = new_aubio_pitch ("default", win_s, win_s / 2, channels, 44100); ++ uint_t win_s = 1024; /* window size */ ++ fvec_t * in = new_fvec (win_s); /* input buffer */ ++ fvec_t * out = new_fvec (1); /* input buffer */ ++ aubio_pitch_t *p = new_aubio_pitch ("default", win_s, win_s / 2, 44100); + uint_t i = 0; + + while (i < 10) { + aubio_pitch_do (p, in, out); + i++; + }; + + del_fvec(in); + del_fvec(out); + aubio_cleanup(); + + return 0; + } +