Mercurial > hg > sonic-visualiser
comparison audioio/AudioCallbackPlaySource.h @ 41:fbd7a497fd89
* Audition effects plugins during playback
author | Chris Cannam |
---|---|
date | Wed, 04 Oct 2006 11:01:39 +0000 |
parents | e3b32dc5180b |
children | c0ae41c72421 |
comparison
equal
deleted
inserted
replaced
40:75c5951cf9d7 | 41:fbd7a497fd89 |
---|---|
35 class Model; | 35 class Model; |
36 class ViewManager; | 36 class ViewManager; |
37 class AudioGenerator; | 37 class AudioGenerator; |
38 class PlayParameters; | 38 class PlayParameters; |
39 class PhaseVocoderTimeStretcher; | 39 class PhaseVocoderTimeStretcher; |
40 class RealTimePluginInstance; | |
40 | 41 |
41 /** | 42 /** |
42 * AudioCallbackPlaySource manages audio data supply to callback-based | 43 * AudioCallbackPlaySource manages audio data supply to callback-based |
43 * audio APIs such as JACK or CoreAudio. It maintains one ring buffer | 44 * audio APIs such as JACK or CoreAudio. It maintains one ring buffer |
44 * per channel, filled during playback by a non-realtime thread, and | 45 * per channel, filled during playback by a non-realtime thread, and |
190 * Set the resampler quality, 0 - 2 where 0 is fastest and 2 is | 191 * Set the resampler quality, 0 - 2 where 0 is fastest and 2 is |
191 * highest quality. | 192 * highest quality. |
192 */ | 193 */ |
193 void setResampleQuality(int q); | 194 void setResampleQuality(int q); |
194 | 195 |
196 /** | |
197 * Set a single real-time plugin as a processing effect for | |
198 * auditioning during playback. | |
199 * | |
200 * The plugin must have been initialised with | |
201 * getTargetChannelCount() channels and a getTargetBlockSize() | |
202 * sample frame processing block size. | |
203 * | |
204 * This playback source takes ownership of the plugin, which will | |
205 * be deleted at some point after the following call to | |
206 * setAuditioningPlugin (depending on real-time constraints). | |
207 * | |
208 * Pass a null pointer to remove the current auditioning plugin, | |
209 * if any. | |
210 */ | |
211 void setAuditioningPlugin(RealTimePluginInstance *plugin); | |
212 | |
195 signals: | 213 signals: |
196 void modelReplaced(); | 214 void modelReplaced(); |
197 | 215 |
198 void playStatusChanged(bool isPlaying); | 216 void playStatusChanged(bool isPlaying); |
199 | 217 |
218 erase(begin()); | 236 erase(begin()); |
219 } | 237 } |
220 } | 238 } |
221 }; | 239 }; |
222 | 240 |
223 std::set<Model *> m_models; | 241 std::set<Model *> m_models; |
224 RingBufferVector *m_readBuffers; | 242 RingBufferVector *m_readBuffers; |
225 RingBufferVector *m_writeBuffers; | 243 RingBufferVector *m_writeBuffers; |
226 size_t m_readBufferFill; | 244 size_t m_readBufferFill; |
227 size_t m_writeBufferFill; | 245 size_t m_writeBufferFill; |
228 Scavenger<RingBufferVector> m_bufferScavenger; | 246 Scavenger<RingBufferVector> m_bufferScavenger; |
229 size_t m_sourceChannelCount; | 247 size_t m_sourceChannelCount; |
230 size_t m_blockSize; | 248 size_t m_blockSize; |
231 size_t m_sourceSampleRate; | 249 size_t m_sourceSampleRate; |
232 size_t m_targetSampleRate; | 250 size_t m_targetSampleRate; |
233 size_t m_playLatency; | 251 size_t m_playLatency; |
234 bool m_playing; | 252 bool m_playing; |
235 bool m_exiting; | 253 bool m_exiting; |
236 size_t m_lastModelEndFrame; | 254 size_t m_lastModelEndFrame; |
237 static const size_t m_ringBufferSize; | 255 static const size_t m_ringBufferSize; |
238 float m_outputLeft; | 256 float m_outputLeft; |
239 float m_outputRight; | 257 float m_outputRight; |
258 RealTimePluginInstance *m_auditioningPlugin; | |
259 Scavenger<RealTimePluginInstance> m_pluginScavenger; | |
240 | 260 |
241 RingBuffer<float> *getWriteRingBuffer(size_t c) { | 261 RingBuffer<float> *getWriteRingBuffer(size_t c) { |
242 if (m_writeBuffers && c < m_writeBuffers->size()) { | 262 if (m_writeBuffers && c < m_writeBuffers->size()) { |
243 return (*m_writeBuffers)[c]; | 263 return (*m_writeBuffers)[c]; |
244 } else { | 264 } else { |
269 // which will be count or fewer. Return in the frame argument the | 289 // which will be count or fewer. Return in the frame argument the |
270 // new buffered frame position (which may be earlier than the | 290 // new buffered frame position (which may be earlier than the |
271 // frame argument passed in, in the case of looping). | 291 // frame argument passed in, in the case of looping). |
272 size_t mixModels(size_t &frame, size_t count, float **buffers); | 292 size_t mixModels(size_t &frame, size_t count, float **buffers); |
273 | 293 |
294 // Called from getSourceSamples. | |
295 void applyAuditioningEffect(size_t count, float **buffers); | |
296 | |
274 class AudioCallbackPlaySourceFillThread : public Thread | 297 class AudioCallbackPlaySourceFillThread : public Thread |
275 { | 298 { |
276 public: | 299 public: |
277 AudioCallbackPlaySourceFillThread(AudioCallbackPlaySource &source) : | 300 AudioCallbackPlaySourceFillThread(AudioCallbackPlaySource &source) : |
278 Thread(Thread::NonRTThread), | 301 Thread(Thread::NonRTThread), |