diff --git a/source/modules/sfzero/SFZero.cpp b/source/modules/sfzero/SFZero.cpp index 5015c467a..b7b95fd4c 100644 --- a/source/modules/sfzero/SFZero.cpp +++ b/source/modules/sfzero/SFZero.cpp @@ -7,6 +7,6 @@ #include "sfzero/SFZReader.cpp" #include "sfzero/SFZRegion.cpp" #include "sfzero/SFZSample.cpp" -// #include "sfzero/SFZSound.cpp" +#include "sfzero/SFZSound.cpp" // #include "sfzero/SFZSynth.cpp" // #include "sfzero/SFZVoice.cpp" diff --git a/source/modules/sfzero/sfzero/SFZRegion.cpp b/source/modules/sfzero/sfzero/SFZRegion.cpp index 2a2cfc581..318bd611d 100644 --- a/source/modules/sfzero/sfzero/SFZRegion.cpp +++ b/source/modules/sfzero/sfzero/SFZRegion.cpp @@ -95,9 +95,7 @@ void sfzero::Region::sf2ToSFZ() { ampeg.sustain = 0.0f; } -#if 0 - ampeg.sustain = 100.0f * water::Decibels::decibelsToGain(-ampeg.sustain / 10.0f); -#endif + ampeg.sustain = 100.0f * decibelsToGain(-ampeg.sustain / 10.0f); ampeg.release = timecents2Secs(static_cast(ampeg.release)); // Pin very short EG segments. Timecents don't get to zero, and our EG is diff --git a/source/modules/sfzero/sfzero/SFZSound.cpp b/source/modules/sfzero/sfzero/SFZSound.cpp index e02be4c00..4e0934b79 100644 --- a/source/modules/sfzero/sfzero/SFZSound.cpp +++ b/source/modules/sfzero/sfzero/SFZSound.cpp @@ -20,10 +20,12 @@ 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*/) @@ -34,6 +36,7 @@ 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('\\', '/'); @@ -57,9 +60,11 @@ 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)) @@ -70,6 +75,7 @@ void sfzero::Sound::addUnsupportedOpcode(const water::String &opcode) warnings_.add(warning); } } +#endif void sfzero::Sound::loadRegions() { @@ -78,6 +84,7 @@ void sfzero::Sound::loadRegions() reader.read(file_); } +#if 0 void sfzero::Sound::loadSamples(water::AudioFormatManager *formatManager, double *progressVar, water::Thread *thread) { if (progressVar) @@ -111,6 +118,7 @@ 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) { @@ -179,6 +187,7 @@ water::String sfzero::Sound::dump() info << "no regions.\n"; } +#if 0 if (samples_.size() > 0) { info << samples_.size() << " samples: \n"; @@ -188,6 +197,7 @@ water::String sfzero::Sound::dump() } } else +#endif { info << "no samples.\n"; } diff --git a/source/utils/CarlaJuceUtils.hpp b/source/utils/CarlaJuceUtils.hpp index 6f6543515..212da8f2d 100644 --- a/source/utils/CarlaJuceUtils.hpp +++ b/source/utils/CarlaJuceUtils.hpp @@ -1,7 +1,8 @@ /* * Carla misc utils based on Juce * Copyright (C) 2013 Raw Material Software Ltd. - * Copyright (C) 2013-2015 Filipe Coelho + * Copyright (c) 2016 ROLI Ltd. + * Copyright (C) 2013-2018 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -26,6 +27,7 @@ #include "CarlaUtils.hpp" #include +#include /** A good old-fashioned C macro concatenation helper. This combines two items (which may themselves be macros) into a single string, @@ -65,6 +67,17 @@ CARLA_DECLARE_NON_COPY_CLASS(ClassName) #endif +//===================================================================================================================== +/** Converts a dBFS value to its equivalent gain level. + + A gain of 1.0 = 0 dB, and lower gains map onto negative decibel values. Any + decibel value lower than minusInfinityDb will return a gain of 0. +*/ +static float decibelsToGain (const float decibels, const float minusInfinityDb = -100.0f) +{ + return decibels > minusInfinityDb ? std::pow (10.0f, decibels * 0.05f) : 0.0f; +} + //===================================================================================================================== /** Embedding an instance of this class inside another class can be used as a low-overhead