diff audioio/AudioCallbackPlaySource.h @ 235:1fcee2a1c03e sonification

Add queueExampleNote method to AudioCallbackPlaySource, providing a way to add a note to a special model which is mixed in outside of the normal playback flow. Currently mixing & generation happen in the play thread, which doesn't work very well -- buffer pending.
author Chris Cannam
date Fri, 24 Jun 2011 16:44:02 +0100
parents 0b3aa9b702bb
children e8961a95b3d6
line wrap: on
line diff
--- a/audioio/AudioCallbackPlaySource.h	Fri Jun 24 15:39:00 2011 +0100
+++ b/audioio/AudioCallbackPlaySource.h	Fri Jun 24 16:44:02 2011 +0100
@@ -38,6 +38,7 @@
 }
 
 class Model;
+class NoteModel;
 class ViewManagerBase;
 class AudioGenerator;
 class PlayParameters;
@@ -227,6 +228,12 @@
     void setAuditioningEffect(Auditionable *plugin);
 
     /**
+     * Request spontaneous playback of a single short note of the
+     * given pitch.
+     */
+    void queueExampleNote(int midiPitch);
+
+    /**
      * Specify that only the given set of models should be played.
      */
     void setSoloModelSet(std::set<Model *>s);
@@ -305,6 +312,8 @@
     size_t                            m_playStartFrame;
     bool                              m_playStartFramePassed;
     RealTime                          m_playStartedAt;
+    NoteModel                        *m_exampleNotes;
+    size_t                            m_examplePlaybackFrame;
 
     RingBuffer<float> *getWriteRingBuffer(size_t c) {
 	if (m_writeBuffers && c < m_writeBuffers->size()) {
@@ -345,6 +354,11 @@
     // frame argument passed in, in the case of looping).
     size_t mixModels(size_t &frame, size_t count, float **buffers);
 
+    // Called from getSourceSamples, thus in play thread rather than
+    // fill thread.  Return the number of frames written, which will
+    // be count or fewer.
+    size_t mixExampleModel(size_t count, float **buffers);
+
     // Called from getSourceSamples.
     void applyAuditioningEffect(size_t count, float **buffers);