# HG changeset patch # User Chris Cannam # Date 1139508112 0 # Node ID b6dc944128da264b0e9f27b268aaaf0610166d8e # Parent e71385792d9d9239a28b58475b281e729ef61d49 * Add basics of MIDI file import. Doesn't actually create the model yet. * Add rewind to start / ffwd to end. * Make zoom constraint default to sqrt(2) type if no constraint set diff -r e71385792d9d -r b6dc944128da audioio/AudioCallbackPlaySource.cpp --- a/audioio/AudioCallbackPlaySource.cpp Wed Feb 08 17:59:16 2006 +0000 +++ b/audioio/AudioCallbackPlaySource.cpp Thu Feb 09 18:01:52 2006 +0000 @@ -80,7 +80,7 @@ void AudioCallbackPlaySource::addModel(Model *model) { - m_audioGenerator->addModel(model); + bool canPlay = m_audioGenerator->addModel(model); m_mutex.lock(); @@ -122,7 +122,7 @@ clearRingBuffers(true, modelChannels); buffersChanged = true; } else { - clearRingBuffers(true); + if (canPlay) clearRingBuffers(true); } if (buffersChanged || srChanged) { diff -r e71385792d9d -r b6dc944128da audioio/AudioGenerator.cpp --- a/audioio/AudioGenerator.cpp Wed Feb 08 17:59:16 2006 +0000 +++ b/audioio/AudioGenerator.cpp Thu Feb 09 18:01:52 2006 +0000 @@ -38,7 +38,7 @@ { } -void +bool AudioGenerator::addModel(Model *model) { if (m_sourceSampleRate == 0) { @@ -52,12 +52,13 @@ if (dtvm) { m_sourceSampleRate = model->getSampleRate(); + return true; } } SparseOneDimensionalModel *sodm = dynamic_cast(model); - if (!sodm) return; // nothing else to initialise + if (!sodm) return false; // nothing else to initialise // QString pluginId = "dssi:/usr/lib/dssi/dssi-vst.so:FEARkILLERrev1.dll"; // QString pluginId = "dssi:/usr/lib/dssi/hexter.so:hexter"; @@ -71,7 +72,7 @@ if (!factory) { std::cerr << "Failed to get plugin factory" << std::endl; - return; + return false; } RealTimePluginInstance *instance = @@ -93,7 +94,10 @@ instance->setIdealChannelCount(m_targetChannelCount); // reset! } else { std::cerr << "Failed to instantiate plugin" << std::endl; + return false; } + + return true; } void diff -r e71385792d9d -r b6dc944128da audioio/AudioGenerator.h --- a/audioio/AudioGenerator.h Wed Feb 08 17:59:16 2006 +0000 +++ b/audioio/AudioGenerator.h Thu Feb 09 18:01:52 2006 +0000 @@ -30,8 +30,10 @@ /** * Add a data model to be played from and initialise any * necessary audio generation code. + * Returns true if the model is of a type that we know how to play. + * (The model will be added regardless.) */ - virtual void addModel(Model *model); + virtual bool addModel(Model *model); /** * Remove a model.