Mercurial > hg > svapp
changeset 307:6eb15c3aee0a tonioni
More toward using clip mixer
author | Chris Cannam |
---|---|
date | Tue, 07 Jan 2014 13:10:35 +0000 |
parents | 64382d824bfe |
children | 289d65722123 |
files | audioio/AudioGenerator.cpp audioio/AudioGenerator.h audioio/ClipMixer.cpp svapp.pro |
diffstat | 4 files changed, 46 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/audioio/AudioGenerator.cpp Tue Jan 07 13:04:29 2014 +0000 +++ b/audioio/AudioGenerator.cpp Tue Jan 07 13:10:35 2014 +0000 @@ -27,6 +27,8 @@ #include "data/model/SparseOneDimensionalModel.h" #include "data/model/NoteData.h" +#include "ClipMixer.h" + #include <iostream> #include <cmath> @@ -115,14 +117,14 @@ return true; } } -/*!!! - RealTimePluginInstance *plugin = loadPluginFor(model); - if (plugin) { + + ClipMixer *mixer = makeClipMixerFor(model); + if (mixer) { QMutexLocker locker(&m_mutex); - m_synthMap[model] = plugin; + m_clipMixerMap[model] = mixer; return true; } -*/ + return false; } @@ -137,15 +139,14 @@ return; } - if (m_synthMap.find(model) == m_synthMap.end()) return; -/*!!! - RealTimePluginInstance *plugin = loadPluginFor(model); - if (plugin) { + if (m_clipMixerMap.find(model) == m_clipMixerMap.end()) return; + + ClipMixer *mixer = makeClipMixerFor(model); + if (mixer) { QMutexLocker locker(&m_mutex); - delete m_synthMap[model]; - m_synthMap[model] = plugin; + m_clipMixerMap[model] = mixer; + return true; } -*/ } /*!!! void @@ -180,11 +181,11 @@ plugin->configure("sampledir", m_sampleDir.toStdString()); } } - -RealTimePluginInstance * -AudioGenerator::loadPluginFor(const Model *model) +*/ +ClipMixer * +AudioGenerator::makeClipMixerFor(const Model *model) { - QString pluginId, configurationXml; + QString sampleId; const Playable *playable = model; if (!playable || !playable->canPlay()) return 0; @@ -192,17 +193,21 @@ PlayParameters *parameters = PlayParameterRepository::getInstance()->getPlayParameters(playable); if (parameters) { - pluginId = parameters->getPlaySampleId(); - configurationXml = parameters->getPlayPluginConfiguration(); + sampleId = parameters->getPlaySampleId(); } - std::cerr << "AudioGenerator::loadPluginFor(" << model << "): id = " << pluginId << std::endl; + std::cerr << "AudioGenerator::loadPluginFor(" << model << "): sample id = " << sampleId << std::endl; - if (pluginId == "") { - SVDEBUG << "AudioGenerator::loadPluginFor(" << model << "): parameters contain empty plugin ID, skipping" << endl; + if (sampleId == "") { + SVDEBUG << "AudioGenerator::loadPluginFor(" << model << "): no sample, skipping" << endl; return 0; } + + + + + RealTimePluginInstance *plugin = loadPlugin(pluginId, ""); if (!plugin) return 0;
--- a/audioio/AudioGenerator.h Tue Jan 07 13:04:29 2014 +0000 +++ b/audioio/AudioGenerator.h Tue Jan 07 13:10:35 2014 +0000 @@ -22,6 +22,7 @@ class DenseTimeValueModel; class SparseOneDimensionalModel; class Playable; +class ClipMixer; #include <QObject> #include <QMutex> @@ -115,22 +116,20 @@ }; }; -//!!! typedef std::map<const Model *, RealTimePluginInstance *> PluginMap; + + typedef std::map<const Model *, ClipMixer *> ClipMixerMap; typedef std::multiset<NoteOff, NoteOff::Comparator> NoteOffSet; typedef std::map<const Model *, NoteOffSet> NoteOffMap; QMutex m_mutex; -//!!! PluginMap m_synthMap; + ClipMixerMap m_clipMixerMap; NoteOffMap m_noteOffs; static QString m_sampleDir; -/*!!! - virtual RealTimePluginInstance *loadPluginFor(const Model *model); - virtual RealTimePluginInstance *loadPlugin(QString id, QString program); -*/ + ClipMixer *makeClipMixerFor(const Model *model); + static void initialiseSampleDir(); -//!!! static void setSampleDir(RealTimePluginInstance *plugin); virtual size_t mixDenseTimeValueModel (DenseTimeValueModel *model, size_t startFrame, size_t frameCount,
--- a/audioio/ClipMixer.cpp Tue Jan 07 13:04:29 2014 +0000 +++ b/audioio/ClipMixer.cpp Tue Jan 07 13:10:35 2014 +0000 @@ -36,7 +36,7 @@ ClipMixer::loadClipData(QString path, float f0) { if (m_clipData) { - cerr << "ClipPlayer::loadClipData: Already have clip loaded" << endl; + cerr << "ClipMixer::loadClipData: Already have clip loaded" << endl; return false; } @@ -49,14 +49,14 @@ info.format = 0; file = sf_open(path.toLocal8Bit().data(), SFM_READ, &info); if (!file) { - cerr << "ClipPlayer::loadClipData: Failed to open file " + cerr << "ClipMixer::loadClipData: Failed to open file " << path << ": " << sf_strerror(file) << endl; return false; } tmpFrames = (float *)malloc(info.frames * info.channels * sizeof(float)); if (!tmpFrames) { - cerr << "ClipPlayer::loadClipData: malloc(" << info.frames * info.channels * sizeof(float) << ") failed" << endl; + cerr << "ClipMixer::loadClipData: malloc(" << info.frames * info.channels * sizeof(float) << ") failed" << endl; return false; } @@ -65,7 +65,7 @@ m_clipData = (float *)malloc(info.frames * sizeof(float)); if (!m_clipData) { - cerr << "ClipPlayer::loadClipData: malloc(" << info.frames * sizeof(float) << ") failed" << endl; + cerr << "ClipMixer::loadClipData: malloc(" << info.frames * sizeof(float) << ") failed" << endl; free(tmpFrames); return false; } @@ -84,3 +84,12 @@ m_clipF0 = f0; m_clipRate = info.samplerate; } + +void +ClipMixer::mix(float **toBuffers, + std::vector<NoteStart> newNotes, + std::vector<NoteEnd> endingNotes) +{ + //!!! do this! +} +
--- a/svapp.pro Tue Jan 07 13:04:29 2014 +0000 +++ b/svapp.pro Tue Jan 07 13:10:35 2014 +0000 @@ -38,17 +38,15 @@ audioio/ClipMixer.h \ audioio/PlaySpeedRangeMapper.h - -#!!! todo: move ClipMixer down SOURCES += audioio/AudioCallbackPlaySource.cpp \ audioio/AudioCallbackPlayTarget.cpp \ audioio/AudioCoreAudioTarget.cpp \ - audioio/ClipMixer.cpp \ audioio/AudioGenerator.cpp \ audioio/AudioJACKTarget.cpp \ audioio/AudioPortAudioTarget.cpp \ audioio/AudioPulseAudioTarget.cpp \ audioio/AudioTargetFactory.cpp \ + audioio/ClipMixer.cpp \ audioio/PlaySpeedRangeMapper.cpp HEADERS += framework/Document.h \