aubio  0.5.0-alpha
timestretch.h
Go to the documentation of this file.
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 */
56  uint_t * read);
57 
58 /** deletion of the time stretching object
59 
60  \param o time stretching object as returned by new_aubio_timestretch()
61 
62 */
64 
65 /** creation of the time stretching object
66 
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 */
76  smpl_t stretch, uint_t hop_size, uint_t samplerate);
77 
78 /** push length samples from in to time stretching object
79 
80  \param o time stretching object as returned by ::new_aubio_timestretch()
81  \param in input vector of new samples to push to time stretching object
82  \param length number of new samples to push from input vector
83 
84  \return number of currently available samples
85 
86  */
88  uint_t length);
89 
90 /** get number of currently available samples from time stretching object
91 
92  \param o time stretching object as returned by ::new_aubio_timestretch()
93 
94  \return number of currently available samples
95 
96  */
98 
99 /** get the latency of the time stretching object, in samples
100 
101  \param o time stretching object as returned by ::new_aubio_timestretch()
102 
103  \return latency of the time stretching object in samples
104 
105 */
107 
108 /** get the samplerate of the time stretching object
109 
110  Call after new_aubio_timestretch() was called with 0 to match the original
111  samplerate of the input file.
112 
113  \param o time stretching object as returned by new_aubio_timestretch()
114 
115  \return samplerate of the time stretching object
116 
117  */
119 
120 /** set the stretching ratio of the time stretching object
121 
122  \param o time stretching object as returned by new_aubio_timestretch()
123  \param stretch new time stretching ratio of the time stretching object
124  (should be in the range [0.025; 10.])
125 
126  \return 0 if successful, non-zero otherwise
127 
128 */
130 
131 /** get the transposition of the time stretching object, in semitones
132 
133  \param o time stretching object as returned by ::new_aubio_timestretch()
134 
135  \return time stretching ratio of the time stretching object, in the range
136  [0.025; 10.]
137 
138 */
140 
141 /** set the pitch scale of the time stretching object
142 
143  \param o time stretching object as returned by new_aubio_timestretch()
144  \param pitchscale new pitch scale of the time stretching object
145 
146  pitchscale is a frequency ratio. It should be in the range [0.25, 4].
147 
148  \return 0 if successful, non-zero otherwise
149 
150 */
152  smpl_t pitchscale);
153 
154 /** get the pitchscale of the time stretching object
155 
156  \param o time stretching object as returned by ::new_aubio_timestretch()
157 
158  \return pitchscale of the time stretching object
159 
160 */
162 
163 /** set the transposition of the time stretching object, in semitones
164 
165  \param o time stretching object as returned by new_aubio_timestretch()
166 
167  \param transpose new pitch transposition of the time stretching object,
168  expressed in semitones (should be in the range [-24;+24])
169 
170  \return 0 if successful, non-zero otherwise
171 
172 */
174  smpl_t transpose);
175 
176 /** get the transposition of the time stretching object, in semitones
177 
178  \param o time stretching object as returned by ::new_aubio_timestretch()
179 
180  \return transposition of the time stretching object, in semitones
181 
182 */
184 
185 /** reset the time stretching object
186 
187  \param o time stretching object as returned by ::new_aubio_timestretch()
188 
189  \return 0 on success, non-zero otherwise
190 
191 */
193 
194 #ifdef __cplusplus
195 }
196 #endif
197 
198 #endif /* AUBIO_TIMESTRETCH_H */
float smpl_t
short sample format (32 or 64 bits)
Definition: types.h:41
uint_t aubio_timestretch_set_transpose(aubio_timestretch_t *o, smpl_t transpose)
set the transposition of the time stretching object, in semitones
uint_t aubio_timestretch_set_pitchscale(aubio_timestretch_t *o, smpl_t pitchscale)
set the pitch scale of the time stretching object
sint_t aubio_timestretch_push(aubio_timestretch_t *o, fvec_t *in, uint_t length)
push length samples from in to time stretching object
int sint_t
signed integer
Definition: types.h:62
void aubio_timestretch_do(aubio_timestretch_t *o, fvec_t *out, uint_t *read)
execute time stretching on an input signal frame
uint_t aubio_timestretch_reset(aubio_timestretch_t *o)
reset the time stretching object
aubio_timestretch_t * new_aubio_timestretch(const char_t *method, smpl_t stretch, uint_t hop_size, uint_t samplerate)
creation of the time stretching object
smpl_t aubio_timestretch_get_pitchscale(aubio_timestretch_t *o)
get the pitchscale of the time stretching object
smpl_t aubio_timestretch_get_stretch(aubio_timestretch_t *o)
get the transposition of the time stretching object, in semitones
Buffer for real data.
Definition: fvec.h:67
struct _aubio_timestretch_t aubio_timestretch_t
time stretching object
Definition: timestretch.h:46
void del_aubio_timestretch(aubio_timestretch_t *o)
deletion of the time stretching object
uint_t aubio_timestretch_get_samplerate(aubio_timestretch_t *o)
get the samplerate of the time stretching object
unsigned int uint_t
unsigned integer
Definition: types.h:60
uint_t aubio_timestretch_get_latency(aubio_timestretch_t *o)
get the latency of the time stretching object, in samples
uint_t aubio_timestretch_set_stretch(aubio_timestretch_t *o, smpl_t stretch)
set the stretching ratio of the time stretching object
char char_t
character
Definition: types.h:64
smpl_t aubio_timestretch_get_transpose(aubio_timestretch_t *o)
get the transposition of the time stretching object, in semitones
sint_t aubio_timestretch_get_available(aubio_timestretch_t *o)
get number of currently available samples from time stretching object