source: src/effects/timestretch.h @ 8688797

sampler
Last change on this file since 8688797 was 8688797, checked in by Paul Brossier <piem@piem.org>, 7 years ago

src/effects/timestretch*: move out threaded file reading stuff, add _push and _available

  • Property mode set to 100644
File size: 5.7 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, 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*/
62void del_aubio_timestretch (aubio_timestretch_t * o);
63
64/** creation of the time stretching object
65
66  \param method time stretching algorithm ("default")
67  \param stretch initial time stretching factor
68  \param hop_size block size at which the frames should be produced
69  \param samplerate sampling rate of the signal
70
71  \return newly created ::aubio_timestretch_t
72
73*/
74aubio_timestretch_t *new_aubio_timestretch (const char_t * method,
75    smpl_t stretch, uint_t hop_size, uint_t samplerate);
76
77/** push length samples from in to time stretching object
78
79  \param o time stretching object as returned by ::new_aubio_timestretch()
80  \param in input vector of new samples to push to time stretching object
81  \param length number of new samples to push from input vector
82
83  \return number of currently available samples
84
85 */
86sint_t aubio_timestretch_push(aubio_timestretch_t * o, fvec_t *in, uint_t length);
87
88/** get number of currently available samples from time stretching object
89
90  \param o time stretching object as returned by ::new_aubio_timestretch()
91
92  \return number of currently available samples
93
94 */
95sint_t aubio_timestretch_get_available(aubio_timestretch_t * o);
96
97/** get the latency of the time stretching object, in samples
98
99  \param o time stretching object as returned by ::new_aubio_timestretch()
100
101  \return latency of the time stretching object in samples
102
103*/
104uint_t aubio_timestretch_get_latency (aubio_timestretch_t * o);
105
106/** get the samplerate of the time stretching object
107
108  Call after new_aubio_timestretch() was called with 0 to match the original
109  samplerate of the input file.
110
111  \param o time stretching object as returned by new_aubio_timestretch()
112
113  \return samplerate of the time stretching object
114
115 */
116uint_t aubio_timestretch_get_samplerate (aubio_timestretch_t * o);
117
118/** set the stretching ratio of the time stretching object
119
120  \param o time stretching object as returned by new_aubio_timestretch()
121  \param stretch new time stretching ratio of the time stretching object
122  (should be in the range [0.025; 10.])
123
124  \return 0 if successfull, non-zero otherwise
125
126*/
127uint_t aubio_timestretch_set_stretch (aubio_timestretch_t * o, smpl_t stretch);
128
129/** get the transposition of the time stretching object, in semitones
130
131  \param o time stretching object as returned by ::new_aubio_timestretch()
132
133  \return time stretching ratio of the time stretching object, in the range
134  [0.025; 10.]
135
136*/
137smpl_t aubio_timestretch_get_stretch (aubio_timestretch_t * o);
138
139/** set the pitch scale of the time stretching object
140
141  \param o time stretching object as returned by new_aubio_timestretch()
142  \param pitchscale new pitch scale of the time stretching object
143
144  \return 0 if successfull, non-zero otherwise
145
146*/
147uint_t aubio_timestretch_set_pitchscale (aubio_timestretch_t * o, smpl_t pitchscale);
148
149/** get the pitchscale of the time stretching object
150
151  \param o time stretching object as returned by ::new_aubio_timestretch()
152
153  \return pitchscale of the time stretching object
154
155*/
156smpl_t aubio_timestretch_get_pitchscale (aubio_timestretch_t * o);
157
158/** set the transposition of the time stretching object, in semitones
159
160  \param o time stretching object as returned by new_aubio_timestretch()
161  \param transpose new pitch transposition of the time stretching object, expressed
162  in semitones (should be in the range [-24;+24])
163
164  \return 0 if successfull, non-zero otherwise
165
166*/
167uint_t aubio_timestretch_set_transpose (aubio_timestretch_t * o, smpl_t transpose);
168
169/** get the transposition of the time stretching object, in semitones
170
171  \param o time stretching object as returned by ::new_aubio_timestretch()
172
173  \return transposition of the time stretching object, in semitones
174
175*/
176smpl_t aubio_timestretch_get_transpose (aubio_timestretch_t * o);
177
178/** reset the time stretching object
179
180  \param o time stretching object as returned by ::new_aubio_timestretch()
181
182  \return 0 on success, non-zero otherwise
183
184*/
185uint_t aubio_timestretch_reset(aubio_timestretch_t * o);
186
187#ifdef __cplusplus
188}
189#endif
190
191#endif /* AUBIO_TIMESTRETCH_H */
Note: See TracBrowser for help on using the repository browser.