source: src/effects/timestretch.h @ 72d4e42

feature/crepe
Last change on this file since 72d4e42 was 124acfb, checked in by Paul Brossier <piem@piem.org>, 6 years ago

[effects] wrap long lines

  • Property mode set to 100644
File size: 5.8 KB
Line 
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
25extern "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 */
46typedef 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*/
55void aubio_timestretch_do (aubio_timestretch_t * o, fvec_t * out,
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*/
63void del_aubio_timestretch (aubio_timestretch_t * o);
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*/
75aubio_timestretch_t *new_aubio_timestretch (const char_t * method,
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 */
87sint_t aubio_timestretch_push(aubio_timestretch_t * o, fvec_t *in,
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 */
97sint_t aubio_timestretch_get_available(aubio_timestretch_t * o);
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*/
106uint_t aubio_timestretch_get_latency (aubio_timestretch_t * o);
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 */
118uint_t aubio_timestretch_get_samplerate (aubio_timestretch_t * o);
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 successfull, non-zero otherwise
127
128*/
129uint_t aubio_timestretch_set_stretch (aubio_timestretch_t * o, smpl_t stretch);
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*/
139smpl_t aubio_timestretch_get_stretch (aubio_timestretch_t * o);
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 successfull, non-zero otherwise
149
150*/
151uint_t aubio_timestretch_set_pitchscale (aubio_timestretch_t * o,
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*/
161smpl_t aubio_timestretch_get_pitchscale (aubio_timestretch_t * o);
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 successfull, non-zero otherwise
171
172*/
173uint_t aubio_timestretch_set_transpose (aubio_timestretch_t * o,
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*/
183smpl_t aubio_timestretch_get_transpose (aubio_timestretch_t * o);
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*/
192uint_t aubio_timestretch_reset(aubio_timestretch_t * o);
193
194#ifdef __cplusplus
195}
196#endif
197
198#endif /* AUBIO_TIMESTRETCH_H */
Note: See TracBrowser for help on using the repository browser.