source: examples/aubionotes.c @ a1bf01d

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5sampleryinfft+
Last change on this file since a1bf01d was 61a1e5d, checked in by Paul Brossier <piem@piem.org>, 8 years ago

examples/: return 1 if object creation failed

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2  Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org>
3
4  This file is part of aubio.
5
6  aubio is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10
11  aubio is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15
16  You should have received a copy of the GNU General Public License
17  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#include "utils.h"
22#define PROG_HAS_PITCH 1
23#define PROG_HAS_ONSET 1
24#define PROG_HAS_SILENCE 1
25#define PROG_HAS_JACK 1
26// TODO add PROG_HAS_OUTPUT
27#include "parse_args.h"
28
29aubio_notes_t *notes;
30smpl_t lastmidi = 0.;
31
32void process_block (fvec_t *ibuf, fvec_t *obuf)
33{
34  aubio_notes_do (notes, ibuf, obuf);
35  // did we get a note off?
36  if (obuf->data[2] != 0) {
37    lastmidi = aubio_freqtomidi (obuf->data[2]) + .5;
38    send_noteon(lastmidi, 0);
39  }
40  // did we get a note on?
41  if (obuf->data[0] != 0) {
42    lastmidi = aubio_freqtomidi (obuf->data[0]) + .5;
43    send_noteon(lastmidi, obuf->data[1]);
44  }
45}
46
47void process_print (void)
48{
49  //if (verbose) outmsg("%f\n",pitch_obuf->data[0]);
50}
51
52int main(int argc, char **argv) {
53  int ret = 0;
54
55  examples_common_init(argc,argv);
56
57  verbmsg ("using source: %s at %dHz\n", source_uri, samplerate);
58
59  verbmsg ("onset method: %s, ", onset_method);
60  verbmsg ("buffer_size: %d, ", buffer_size);
61  verbmsg ("hop_size: %d, ", hop_size);
62  verbmsg ("threshold: %f\n", onset_threshold);
63
64  verbmsg ("pitch method: %s, ", pitch_method);
65  verbmsg ("buffer_size: %d, ", buffer_size * 4);
66  verbmsg ("hop_size: %d, ", hop_size);
67  verbmsg ("tolerance: %f\n", pitch_tolerance);
68
69  notes = new_aubio_notes ("default", buffer_size, hop_size, samplerate);
70  if (notes == NULL) { ret = 1; goto beach; }
71
72  examples_common_process((aubio_process_func_t)process_block, process_print);
73
74  // send a last note off
75  send_noteon (lastmidi, 0);
76
77  del_aubio_notes (notes);
78
79beach:
80  examples_common_del();
81  return ret;
82}
Note: See TracBrowser for help on using the repository browser.