From 08901df28f8950ea290d8f31b4347d2779333973 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 15 Aug 2018 19:18:14 +0200 Subject: [PATCH] sfzero Sound class almost done --- source/modules/sfzero/Makefile | 2 +- source/modules/sfzero/sfzero/SFZSound.cpp | 18 +++++------------- source/modules/sfzero/sfzero/SFZSound.h | 12 ++++-------- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/source/modules/sfzero/Makefile b/source/modules/sfzero/Makefile index f8e4db054..fdc0624cc 100644 --- a/source/modules/sfzero/Makefile +++ b/source/modules/sfzero/Makefile @@ -10,7 +10,7 @@ include ../Makefile.mk # ---------------------------------------------------------------------------------------------------------------------------- -BUILD_CXX_FLAGS += -I$(CWD)/modules +BUILD_CXX_FLAGS += -I$(CWD)/modules -Wno-unused-variable -Wno-unused-parameter # ---------------------------------------------------------------------------------------------------------------------------- diff --git a/source/modules/sfzero/sfzero/SFZSound.cpp b/source/modules/sfzero/sfzero/SFZSound.cpp index 4e0934b79..7007f1b6d 100644 --- a/source/modules/sfzero/sfzero/SFZSound.cpp +++ b/source/modules/sfzero/sfzero/SFZSound.cpp @@ -20,12 +20,10 @@ sfzero::Sound::~Sound() regions_.set(i, nullptr); } -#if 0 for (water::HashMap::Iterator i(samples_); i.next();) { delete i.getValue(); } -#endif } bool sfzero::Sound::appliesToNote(int /*midiNoteNumber*/) @@ -36,7 +34,6 @@ bool sfzero::Sound::appliesToNote(int /*midiNoteNumber*/) bool sfzero::Sound::appliesToChannel(int /*midiChannel*/) { return true; } void sfzero::Sound::addRegion(sfzero::Region *region) { regions_.add(region); } -#if 0 sfzero::Sample *sfzero::Sound::addSample(water::String path, water::String defaultPath) { path = path.replaceCharacter('\\', '/'); @@ -60,11 +57,9 @@ sfzero::Sample *sfzero::Sound::addSample(water::String path, water::String defau } return sample; } -#endif void sfzero::Sound::addError(const water::String &message) { errors_.add(message); } -#if 0 void sfzero::Sound::addUnsupportedOpcode(const water::String &opcode) { if (!unsupportedOpcodes_.contains(opcode)) @@ -75,7 +70,6 @@ void sfzero::Sound::addUnsupportedOpcode(const water::String &opcode) warnings_.add(warning); } } -#endif void sfzero::Sound::loadRegions() { @@ -84,8 +78,7 @@ void sfzero::Sound::loadRegions() reader.read(file_); } -#if 0 -void sfzero::Sound::loadSamples(water::AudioFormatManager *formatManager, double *progressVar, water::Thread *thread) +void sfzero::Sound::loadSamples(water::AudioFormatManager* formatManager, double* progressVar, CarlaThread* thread) { if (progressVar) { @@ -96,18 +89,20 @@ void sfzero::Sound::loadSamples(water::AudioFormatManager *formatManager, double for (water::HashMap::Iterator i(samples_); i.next();) { sfzero::Sample *sample = i.getValue(); +#if 0 bool ok = sample->load(formatManager); if (!ok) { addError("Couldn't load sample \"" + sample->getShortName() + "\""); } +#endif numSamplesLoaded += 1.0; - if (progressVar) + if (progressVar != nullptr) { *progressVar = numSamplesLoaded / numSamples; } - if (thread && thread->threadShouldExit()) + if (thread != nullptr && thread->shouldThreadExit()) { return; } @@ -118,7 +113,6 @@ void sfzero::Sound::loadSamples(water::AudioFormatManager *formatManager, double *progressVar = 1.0; } } -#endif sfzero::Region *sfzero::Sound::getRegionFor(int note, int velocity, sfzero::Region::Trigger trigger) { @@ -187,7 +181,6 @@ water::String sfzero::Sound::dump() info << "no regions.\n"; } -#if 0 if (samples_.size() > 0) { info << samples_.size() << " samples: \n"; @@ -197,7 +190,6 @@ water::String sfzero::Sound::dump() } } else -#endif { info << "no samples.\n"; } diff --git a/source/modules/sfzero/sfzero/SFZSound.h b/source/modules/sfzero/sfzero/SFZSound.h index fa5a67603..7a5e68c2c 100644 --- a/source/modules/sfzero/sfzero/SFZSound.h +++ b/source/modules/sfzero/sfzero/SFZSound.h @@ -9,10 +9,12 @@ #include "SFZRegion.h" +#include "water/containers/HashMap.h" #include "water/memory/ReferenceCountedObject.h" #include "water/text/StringArray.h" #include "CarlaJuceUtils.hpp" +#include "CarlaThread.hpp" #if 1 namespace water { @@ -46,10 +48,8 @@ public: void addUnsupportedOpcode(const water::String &opcode); virtual void loadRegions(); -#if 0 - virtual void loadSamples(water::AudioFormatManager *formatManager, double *progressVar = nullptr, - water::Thread *thread = nullptr); -#endif + virtual void loadSamples(water::AudioFormatManager* formatManager, double* progressVar = nullptr, + CarlaThread* thread = nullptr); Region *getRegionFor(int note, int velocity, Region::Trigger trigger = Region::attack); int getNumRegions(); @@ -70,14 +70,10 @@ public: private: water::File file_; water::Array regions_; -#if 0 water::HashMap samples_; -#endif water::StringArray errors_; water::StringArray warnings_; -#if 0 water::HashMap unsupportedOpcodes_; -#endif CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Sound) };