# HG changeset patch # User Chris Cannam # Date 1143128981 0 # Node ID 7f32bb07629ab89132d6da64649a8ce917166e4f # Parent ebe07d3560e6fee6c15286cc4592494f55abf60d * Add editing for auralisation plugin parameters and programs * Rename and reorganise the sample plugin sample set diff -r ebe07d3560e6 -r 7f32bb07629a audioio/AudioGenerator.cpp --- a/audioio/AudioGenerator.cpp Mon Mar 20 15:10:07 2006 +0000 +++ b/audioio/AudioGenerator.cpp Thu Mar 23 15:49:41 2006 +0000 @@ -41,6 +41,15 @@ m_sourceSampleRate(0), m_targetChannelCount(1) { + connect(PlayParameterRepository::instance(), + SIGNAL(playPluginIdChanged(const Model *, QString)), + this, + SLOT(playPluginIdChanged(const Model *, QString))); + + connect(PlayParameterRepository::instance(), + SIGNAL(playPluginConfigurationChanged(const Model *, QString)), + this, + SLOT(playPluginConfigurationChanged(const Model *, QString))); } AudioGenerator::~AudioGenerator() @@ -77,37 +86,108 @@ } } - SparseOneDimensionalModel *sodm = - dynamic_cast(model); - if (sodm) { - QString pluginId = QString("dssi:%1:sample_player"). - arg(PluginIdentifier::BUILTIN_PLUGIN_SONAME); - RealTimePluginInstance *plugin = loadPlugin(pluginId, "cowbell"); - if (plugin) { - QMutexLocker locker(&m_mutex); - m_synthMap[sodm] = plugin; - return true; - } else { - return false; - } + RealTimePluginInstance *plugin = loadPluginFor(model); + if (plugin) { + QMutexLocker locker(&m_mutex); + m_synthMap[model] = plugin; + return true; } - NoteModel *nm = dynamic_cast(model); + return false; +} + +void +AudioGenerator::playPluginIdChanged(const Model *model, QString) +{ + if (m_synthMap.find(model) == m_synthMap.end()) return; + + RealTimePluginInstance *plugin = loadPluginFor(model); + if (plugin) { + QMutexLocker locker(&m_mutex); + delete m_synthMap[model]; + m_synthMap[model] = plugin; + } +} + +void +AudioGenerator::playPluginConfigurationChanged(const Model *model, + QString configurationXml) +{ + if (m_synthMap.find(model) == m_synthMap.end()) return; + + RealTimePluginInstance *plugin = m_synthMap[model]; + if (plugin) { + QMutexLocker locker(&m_mutex); + plugin->setParametersFromXml(configurationXml); + } +} + +QString +AudioGenerator::getDefaultPlayPluginId(const Model *model) +{ + const SparseOneDimensionalModel *sodm = + dynamic_cast(model); + if (sodm) { + return QString("dssi:%1:sample_player"). + arg(PluginIdentifier::BUILTIN_PLUGIN_SONAME); + } + + const NoteModel *nm = dynamic_cast(model); if (nm) { - QString pluginId = QString("dssi:%1:sample_player"). - arg(PluginIdentifier::BUILTIN_PLUGIN_SONAME); - RealTimePluginInstance *plugin = loadPlugin(pluginId, "piano"); - if (plugin) { - QMutexLocker locker(&m_mutex); - m_synthMap[nm] = plugin; - return true; - } else { - return false; - } + return QString("dssi:%1:sample_player"). + arg(PluginIdentifier::BUILTIN_PLUGIN_SONAME); + } + + return ""; +} + +QString +AudioGenerator::getDefaultPlayPluginConfiguration(const Model *model) +{ + const SparseOneDimensionalModel *sodm = + dynamic_cast(model); + if (sodm) { + return ""; } - - return false; + const NoteModel *nm = dynamic_cast(model); + if (nm) { + return ""; + } + + return ""; +} + +RealTimePluginInstance * +AudioGenerator::loadPluginFor(const Model *model) +{ + QString pluginId, configurationXml; + + PlayParameters *parameters = + PlayParameterRepository::instance()->getPlayParameters(model); + if (parameters) { + pluginId = parameters->getPlayPluginId(); + configurationXml = parameters->getPlayPluginConfiguration(); + } + + if (pluginId == "") { + pluginId = getDefaultPlayPluginId(model); + configurationXml = getDefaultPlayPluginConfiguration(model); + } + + if (pluginId == "") return 0; + + RealTimePluginInstance *plugin = loadPlugin(pluginId, ""); + if (configurationXml != "") { + plugin->setParametersFromXml(configurationXml); + } + + if (parameters) { + parameters->setPlayPluginId(pluginId); + parameters->setPlayPluginConfiguration(configurationXml); + } + + return plugin; } RealTimePluginInstance * diff -r ebe07d3560e6 -r 7f32bb07629a audioio/AudioGenerator.h --- a/audioio/AudioGenerator.h Mon Mar 20 15:10:07 2006 +0000 +++ b/audioio/AudioGenerator.h Thu Mar 23 15:49:41 2006 +0000 @@ -23,13 +23,16 @@ class SparseOneDimensionalModel; class RealTimePluginInstance; +#include #include #include #include -class AudioGenerator +class AudioGenerator : public QObject { + Q_OBJECT + public: AudioGenerator(ViewManager *); virtual ~AudioGenerator(); @@ -42,6 +45,9 @@ */ static bool canPlay(const Model *model); + static QString getDefaultPlayPluginId(const Model *model); + static QString getDefaultPlayPluginConfiguration(const Model *model); + /** * Add a data model to be played from and initialise any necessary * audio generation code. Returns true if the model will be @@ -85,6 +91,10 @@ virtual size_t mixModel(Model *model, size_t startFrame, size_t frameCount, float **buffer, size_t fadeIn = 0, size_t fadeOut = 0); +protected slots: + void playPluginIdChanged(const Model *, QString); + void playPluginConfigurationChanged(const Model *, QString); + protected: ViewManager *m_viewManager; size_t m_sourceSampleRate; @@ -102,15 +112,16 @@ }; }; - typedef std::map PluginMap; + typedef std::map PluginMap; typedef std::set NoteOffSet; - typedef std::map NoteOffMap; + typedef std::map NoteOffMap; QMutex m_mutex; PluginMap m_synthMap; NoteOffMap m_noteOffs; + virtual RealTimePluginInstance *loadPluginFor(const Model *model); virtual RealTimePluginInstance *loadPlugin(QString id, QString program); virtual size_t mixDenseTimeValueModel