comparison audioio/AudioCallbackPlaySource.h @ 16:3715efc38f95

* substantial enhancements to time stretcher: -- use putInput/getOutput methods to ensure the audio source always feeds it enough input, avoiding underruns due to rounding error -- add a percussion detector and an optional "Sharpen" toggle to the main window, which invokes a very basic variable speed timestretcher
author Chris Cannam
date Wed, 13 Sep 2006 17:17:42 +0000
parents cc566264c935
children d88d117e0c34
comparison
equal deleted inserted replaced
15:cc566264c935 16:3715efc38f95
175 * audio data, in all channels. This may safely be called from a 175 * audio data, in all channels. This may safely be called from a
176 * realtime thread. 176 * realtime thread.
177 */ 177 */
178 size_t getSourceSamples(size_t count, float **buffer); 178 size_t getSourceSamples(size_t count, float **buffer);
179 179
180 void setSlowdownFactor(float factor); 180 void setSlowdownFactor(float factor, bool sharpen);
181 181
182 signals: 182 signals:
183 void modelReplaced(); 183 void modelReplaced();
184 184
185 void playStatusChanged(bool isPlaying); 185 void playStatusChanged(bool isPlaying);
242 } 242 }
243 243
244 void clearRingBuffers(bool haveLock = false, size_t count = 0); 244 void clearRingBuffers(bool haveLock = false, size_t count = 0);
245 void unifyRingBuffers(); 245 void unifyRingBuffers();
246 246
247 class TimeStretcherData 247 PhaseVocoderTimeStretcher *m_timeStretcher;
248 { 248 Scavenger<PhaseVocoderTimeStretcher> m_timeStretcherScavenger;
249 public:
250 TimeStretcherData(size_t channels, float factor, size_t blockSize);
251 ~TimeStretcherData();
252
253 float getFactor() const { return m_factor; }
254 PhaseVocoderTimeStretcher *getStretcher(size_t channel);
255 // float *getOutputBuffer(size_t channel);
256 // float *getInputBuffer();
257
258 // void run(size_t channel);
259
260 protected:
261 TimeStretcherData(const TimeStretcherData &); // not provided
262 TimeStretcherData &operator=(const TimeStretcherData &); // not provided
263
264 std::map<size_t, PhaseVocoderTimeStretcher *> m_stretcher;
265 float m_factor;
266 size_t m_blockSize;
267 };
268
269 size_t m_slowdownCounter;
270 TimeStretcherData *m_timeStretcher;
271 Scavenger<TimeStretcherData> m_timeStretcherScavenger;
272 249
273 // Called from fill thread, m_playing true, mutex held 250 // Called from fill thread, m_playing true, mutex held
274 // Return true if work done 251 // Return true if work done
275 bool fillBuffers(); 252 bool fillBuffers();
276 253