3732b80c932d7224cdc154982ff66a8f62cb7823
[aubio.git] / src / notes / notes.h
1 /*
2   Copyright (C) 2003-2014 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 /** \file
22
23   Note detection object
24
25 */
26
27 #ifndef _AUBIO_NOTES_H
28 #define _AUBIO_NOTES_H
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /** notes detection object */
35 typedef struct _aubio_notes_t aubio_notes_t;
36
37 /** create notes detection object
38
39   \param method notes detection type as specified in specdesc.h
40   \param buf_size buffer size for phase vocoder
41   \param hop_size hop size for phase vocoder
42   \param samplerate sampling rate of the input signal
43
44   \return newly created ::aubio_notes_t
45
46 */
47 aubio_notes_t * new_aubio_notes (const char_t * method,
48     uint_t buf_size, uint_t hop_size, uint_t samplerate);
49
50 /** delete notes detection object
51
52   \param o notes detection object to delete
53
54 */
55 void del_aubio_notes(aubio_notes_t * o);
56
57 /** execute note detection on an input signal frame
58
59   \param o note detection object as returned by new_aubio_notes()
60   \param input input signal of size [hop_size]
61   \param output output notes, fvec of length 3
62
63   The notes output is a vector of length 3 containing:
64    - 0. the midi note value, or 0 if no note was found
65    - 1. the note velocity
66    - 2. the midi note to turn off
67
68 */
69 void aubio_notes_do (aubio_notes_t *o, const fvec_t * input, fvec_t * output);
70
71 /** set notes detection silence threshold
72
73   \param o notes detection object as returned by new_aubio_notes()
74   \param silence new silence detection threshold
75
76 */
77 uint_t aubio_notes_set_silence(aubio_notes_t * o, smpl_t silence);
78
79 /** get notes detection silence threshold
80
81   \param o notes detection object as returned by new_aubio_notes()
82
83   \return current silence threshold
84
85 */
86 smpl_t aubio_notes_get_silence(const aubio_notes_t * o);
87
88 #ifdef __cplusplus
89 }
90 #endif
91
92 #endif /* _AUBIO_NOTES_H */