Mercurial > hg > svcore
diff plugin/plugins/SamplePlayer.cpp @ 75:163f3428bbe0
* Create temporary directory, cleaned up on exit, and use it to store
(inter alia) audio samples for the sample-player plugin.
* Ensure newly added layers always have unique names
* Make sure configure pairs for real-time plugins are stored in the
configuration Xml along with parameter & program settings
author | Chris Cannam |
---|---|
date | Mon, 10 Apr 2006 13:52:32 +0000 |
parents | d397ea0a79f5 |
children | f277a171749d |
line wrap: on
line diff
--- a/plugin/plugins/SamplePlayer.cpp Fri Apr 07 17:50:33 2006 +0000 +++ b/plugin/plugins/SamplePlayer.cpp Mon Apr 10 13:52:32 2006 +0000 @@ -96,7 +96,7 @@ { 2, // DSSI API version &ladspaDescriptor, - 0, // Configure + configure, getProgram, selectProgram, getMidiController, @@ -128,6 +128,7 @@ m_sampleCount(0), m_sampleRate(sampleRate), m_sampleNo(0), + m_samplePath("samples"), m_sampleSearchComplete(false), m_pendingProgramChange(-1) { @@ -207,6 +208,28 @@ delete (SamplePlayer *)handle; } +char * +SamplePlayer::configure(LADSPA_Handle handle, const char *key, const char *value) +{ + if (key && !strcmp(key, "samplepath")) { + + SamplePlayer *player = (SamplePlayer *)handle; + + QMutexLocker locker(&player->m_mutex); + + player->m_samplePath = value; + + if (player->m_sampleSearchComplete) { + player->m_sampleSearchComplete = false; + player->searchSamples(); + } + + return 0; + } + + return strdup("Unknown configure key"); +} + const DSSI_Program_Descriptor * SamplePlayer::getProgram(LADSPA_Handle handle, unsigned long program) { @@ -317,22 +340,25 @@ { if (m_sampleSearchComplete) return; - //!!! -// QString path = "/usr/share/hydrogen/data/drumkits/EasternHop-1"; - std::cerr << "Current working directory is \"" << getcwd(0, 0) << "\"" << std::endl; - QString path = "samples"; - std::cerr << "SamplePlayer::searchSamples: Path is \"" - << path.toLocal8Bit().data() << "\"" << std::endl; + << m_samplePath.toLocal8Bit().data() << "\"" << std::endl; - QDir dir(path, "*.wav"); - for (unsigned int i = 0; i < dir.count(); ++i) { - QFileInfo file(dir.filePath(dir[i])); - m_samples.push_back(std::pair<QString, QString> - (file.baseName(), file.filePath())); - std::cerr << "Found: " << dir[i].toLocal8Bit().data() << std::endl; + QStringList dirList = m_samplePath.split(QRegExp("[:;]")); + + for (QStringList::iterator i = dirList.begin(); i != dirList.end(); ++i) { + + QDir dir(*i, "*.wav"); + + for (unsigned int i = 0; i < dir.count(); ++i) { + QFileInfo file(dir.filePath(dir[i])); + if (file.isReadable()) { + m_samples.push_back(std::pair<QString, QString> + (file.baseName(), file.filePath())); + std::cerr << "Found: " << dir[i].toLocal8Bit().data() << std::endl; + } + } } m_sampleSearchComplete = true;