1 | /* |
---|
2 | Copyright (C) 2016 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 | #ifndef AUBIO_TIMESTRETCH_H |
---|
22 | #define AUBIO_TIMESTRETCH_H |
---|
23 | |
---|
24 | #ifdef __cplusplus |
---|
25 | extern "C" { |
---|
26 | #endif |
---|
27 | |
---|
28 | /** \file |
---|
29 | |
---|
30 | time stretching object |
---|
31 | |
---|
32 | ::aubio_timestretch_t can be used to open a source file, read samples from |
---|
33 | it, time-stretch them, and write out the modified samples. |
---|
34 | |
---|
35 | The time-stretching factor can be changed at any time using |
---|
36 | aubio_timestretch_set_stretch(). |
---|
37 | |
---|
38 | A transposition can also be applied and changed at any time with |
---|
39 | aubio_timestretch_set_transpose(). |
---|
40 | |
---|
41 | \example effects/test-timestretch.c |
---|
42 | |
---|
43 | */ |
---|
44 | |
---|
45 | /** time stretching object */ |
---|
46 | typedef struct _aubio_timestretch_t aubio_timestretch_t; |
---|
47 | |
---|
48 | /** execute time stretching on an input signal frame |
---|
49 | |
---|
50 | \param o time stretching object as returned by new_aubio_timestretch() |
---|
51 | \param out timestretched output of size [hop_size] |
---|
52 | \param read number of frames actually wrote out |
---|
53 | |
---|
54 | */ |
---|
55 | void aubio_timestretch_do (aubio_timestretch_t * o, fvec_t * out, uint_t * read); |
---|
56 | |
---|
57 | /** deletion of the time stretching object |
---|
58 | |
---|
59 | \param o time stretching object as returned by new_aubio_timestretch() |
---|
60 | |
---|
61 | */ |
---|
62 | void del_aubio_timestretch (aubio_timestretch_t * o); |
---|
63 | |
---|
64 | /** creation of the time stretching object |
---|
65 | |
---|
66 | \param uri path to create the source from |
---|
67 | \param method time stretching algorithm ("default") |
---|
68 | \param stretch initial time stretching factor |
---|
69 | \param hop_size block size at which the frames should be produced |
---|
70 | \param samplerate sampling rate of the signal |
---|
71 | |
---|
72 | \return newly created ::aubio_timestretch_t |
---|
73 | |
---|
74 | */ |
---|
75 | aubio_timestretch_t *new_aubio_timestretch (const char_t * uri, |
---|
76 | const char_t * method, smpl_t stretch, uint_t hop_size, uint_t samplerate); |
---|
77 | |
---|
78 | /** get the latency of the time stretching object, in samples |
---|
79 | |
---|
80 | \param o time stretching object as returned by ::new_aubio_timestretch() |
---|
81 | |
---|
82 | \return latency of the time stretching object in samples |
---|
83 | |
---|
84 | */ |
---|
85 | uint_t aubio_timestretch_get_latency (aubio_timestretch_t * o); |
---|
86 | |
---|
87 | /** get the samplerate of the time stretching object |
---|
88 | |
---|
89 | Call after new_aubio_timestretch() was called with 0 to match the original |
---|
90 | samplerate of the input file. |
---|
91 | |
---|
92 | \param o time stretching object as returned by new_aubio_timestretch() |
---|
93 | |
---|
94 | \return samplerate of the time stretching object |
---|
95 | |
---|
96 | */ |
---|
97 | uint_t aubio_timestretch_get_samplerate (aubio_timestretch_t * o); |
---|
98 | |
---|
99 | /** set the stretching ratio of the time stretching object |
---|
100 | |
---|
101 | \param o time stretching object as returned by new_aubio_timestretch() |
---|
102 | \param stretch new time stretching ratio of the time stretching object |
---|
103 | (should be in the range [0.025; 10.]) |
---|
104 | |
---|
105 | \return 0 if successfull, non-zero otherwise |
---|
106 | |
---|
107 | */ |
---|
108 | uint_t aubio_timestretch_set_stretch (aubio_timestretch_t * o, smpl_t stretch); |
---|
109 | |
---|
110 | /** get the transposition of the time stretching object, in semitones |
---|
111 | |
---|
112 | \param o time stretching object as returned by ::new_aubio_timestretch() |
---|
113 | |
---|
114 | \return time stretching ratio of the time stretching object, in the range |
---|
115 | [0.025; 10.] |
---|
116 | |
---|
117 | */ |
---|
118 | smpl_t aubio_timestretch_get_stretch (aubio_timestretch_t * o); |
---|
119 | |
---|
120 | /** set the pitch scale of the time stretching object |
---|
121 | |
---|
122 | \param o time stretching object as returned by new_aubio_timestretch() |
---|
123 | \param pitchscale new pitch scale of the time stretching object |
---|
124 | |
---|
125 | \return 0 if successfull, non-zero otherwise |
---|
126 | |
---|
127 | */ |
---|
128 | uint_t aubio_timestretch_set_pitchscale (aubio_timestretch_t * o, smpl_t pitchscale); |
---|
129 | |
---|
130 | /** get the pitchscale of the time stretching object |
---|
131 | |
---|
132 | \param o time stretching object as returned by ::new_aubio_timestretch() |
---|
133 | |
---|
134 | \return pitchscale of the time stretching object |
---|
135 | |
---|
136 | */ |
---|
137 | smpl_t aubio_timestretch_get_pitchscale (aubio_timestretch_t * o); |
---|
138 | |
---|
139 | /** set the transposition of the time stretching object, in semitones |
---|
140 | |
---|
141 | \param o time stretching object as returned by new_aubio_timestretch() |
---|
142 | \param transpose new pitch transposition of the time stretching object, expressed |
---|
143 | in semitones (should be in the range [-24;+24]) |
---|
144 | |
---|
145 | \return 0 if successfull, non-zero otherwise |
---|
146 | |
---|
147 | */ |
---|
148 | uint_t aubio_timestretch_set_transpose (aubio_timestretch_t * o, smpl_t transpose); |
---|
149 | |
---|
150 | /** get the transposition of the time stretching object, in semitones |
---|
151 | |
---|
152 | \param o time stretching object as returned by ::new_aubio_timestretch() |
---|
153 | |
---|
154 | \return transposition of the time stretching object, in semitones |
---|
155 | |
---|
156 | */ |
---|
157 | smpl_t aubio_timestretch_get_transpose (aubio_timestretch_t * o); |
---|
158 | |
---|
159 | /** seek to a posisition the transposition of the time stretching object, in semitones |
---|
160 | |
---|
161 | \param o time stretching object as returned by ::new_aubio_timestretch() |
---|
162 | \param pos position to seek to, in frames |
---|
163 | |
---|
164 | \return transposition of the time stretching object, in semitones |
---|
165 | |
---|
166 | */ |
---|
167 | uint_t aubio_timestretch_seek(aubio_timestretch_t * o, uint_t pos); |
---|
168 | |
---|
169 | uint_t aubio_timestretch_queue (aubio_timestretch_t *p, const char_t *uri, uint_t samplerate); |
---|
170 | |
---|
171 | uint_t aubio_timestretch_get_opened (aubio_timestretch_t *p); |
---|
172 | |
---|
173 | #ifdef __cplusplus |
---|
174 | } |
---|
175 | #endif |
---|
176 | |
---|
177 | #endif /* AUBIO_TIMESTRETCH_H */ |
---|