@@ -7,6 +7,6 @@ | |||||
#include "sfzero/SFZReader.cpp" | #include "sfzero/SFZReader.cpp" | ||||
#include "sfzero/SFZRegion.cpp" | #include "sfzero/SFZRegion.cpp" | ||||
#include "sfzero/SFZSample.cpp" | #include "sfzero/SFZSample.cpp" | ||||
// #include "sfzero/SFZSound.cpp" | |||||
#include "sfzero/SFZSound.cpp" | |||||
// #include "sfzero/SFZSynth.cpp" | // #include "sfzero/SFZSynth.cpp" | ||||
// #include "sfzero/SFZVoice.cpp" | // #include "sfzero/SFZVoice.cpp" |
@@ -95,9 +95,7 @@ void sfzero::Region::sf2ToSFZ() | |||||
{ | { | ||||
ampeg.sustain = 0.0f; | 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<int>(ampeg.release)); | ampeg.release = timecents2Secs(static_cast<int>(ampeg.release)); | ||||
// Pin very short EG segments. Timecents don't get to zero, and our EG is | // Pin very short EG segments. Timecents don't get to zero, and our EG is | ||||
@@ -20,10 +20,12 @@ sfzero::Sound::~Sound() | |||||
regions_.set(i, nullptr); | regions_.set(i, nullptr); | ||||
} | } | ||||
#if 0 | |||||
for (water::HashMap<water::String, sfzero::Sample *>::Iterator i(samples_); i.next();) | for (water::HashMap<water::String, sfzero::Sample *>::Iterator i(samples_); i.next();) | ||||
{ | { | ||||
delete i.getValue(); | delete i.getValue(); | ||||
} | } | ||||
#endif | |||||
} | } | ||||
bool sfzero::Sound::appliesToNote(int /*midiNoteNumber*/) | bool sfzero::Sound::appliesToNote(int /*midiNoteNumber*/) | ||||
@@ -34,6 +36,7 @@ bool sfzero::Sound::appliesToNote(int /*midiNoteNumber*/) | |||||
bool sfzero::Sound::appliesToChannel(int /*midiChannel*/) { return true; } | bool sfzero::Sound::appliesToChannel(int /*midiChannel*/) { return true; } | ||||
void sfzero::Sound::addRegion(sfzero::Region *region) { regions_.add(region); } | void sfzero::Sound::addRegion(sfzero::Region *region) { regions_.add(region); } | ||||
#if 0 | |||||
sfzero::Sample *sfzero::Sound::addSample(water::String path, water::String defaultPath) | sfzero::Sample *sfzero::Sound::addSample(water::String path, water::String defaultPath) | ||||
{ | { | ||||
path = path.replaceCharacter('\\', '/'); | path = path.replaceCharacter('\\', '/'); | ||||
@@ -57,9 +60,11 @@ sfzero::Sample *sfzero::Sound::addSample(water::String path, water::String defau | |||||
} | } | ||||
return sample; | return sample; | ||||
} | } | ||||
#endif | |||||
void sfzero::Sound::addError(const water::String &message) { errors_.add(message); } | void sfzero::Sound::addError(const water::String &message) { errors_.add(message); } | ||||
#if 0 | |||||
void sfzero::Sound::addUnsupportedOpcode(const water::String &opcode) | void sfzero::Sound::addUnsupportedOpcode(const water::String &opcode) | ||||
{ | { | ||||
if (!unsupportedOpcodes_.contains(opcode)) | if (!unsupportedOpcodes_.contains(opcode)) | ||||
@@ -70,6 +75,7 @@ void sfzero::Sound::addUnsupportedOpcode(const water::String &opcode) | |||||
warnings_.add(warning); | warnings_.add(warning); | ||||
} | } | ||||
} | } | ||||
#endif | |||||
void sfzero::Sound::loadRegions() | void sfzero::Sound::loadRegions() | ||||
{ | { | ||||
@@ -78,6 +84,7 @@ void sfzero::Sound::loadRegions() | |||||
reader.read(file_); | 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, water::Thread *thread) | ||||
{ | { | ||||
if (progressVar) | if (progressVar) | ||||
@@ -111,6 +118,7 @@ void sfzero::Sound::loadSamples(water::AudioFormatManager *formatManager, double | |||||
*progressVar = 1.0; | *progressVar = 1.0; | ||||
} | } | ||||
} | } | ||||
#endif | |||||
sfzero::Region *sfzero::Sound::getRegionFor(int note, int velocity, sfzero::Region::Trigger trigger) | 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"; | info << "no regions.\n"; | ||||
} | } | ||||
#if 0 | |||||
if (samples_.size() > 0) | if (samples_.size() > 0) | ||||
{ | { | ||||
info << samples_.size() << " samples: \n"; | info << samples_.size() << " samples: \n"; | ||||
@@ -188,6 +197,7 @@ water::String sfzero::Sound::dump() | |||||
} | } | ||||
} | } | ||||
else | else | ||||
#endif | |||||
{ | { | ||||
info << "no samples.\n"; | info << "no samples.\n"; | ||||
} | } | ||||
@@ -1,7 +1,8 @@ | |||||
/* | /* | ||||
* Carla misc utils based on Juce | * Carla misc utils based on Juce | ||||
* Copyright (C) 2013 Raw Material Software Ltd. | * Copyright (C) 2013 Raw Material Software Ltd. | ||||
* Copyright (C) 2013-2015 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (c) 2016 ROLI Ltd. | |||||
* Copyright (C) 2013-2018 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | * 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 | * or without fee is hereby granted, provided that the above copyright notice and this | ||||
@@ -26,6 +27,7 @@ | |||||
#include "CarlaUtils.hpp" | #include "CarlaUtils.hpp" | ||||
#include <algorithm> | #include <algorithm> | ||||
#include <cmath> | |||||
/** A good old-fashioned C macro concatenation helper. | /** A good old-fashioned C macro concatenation helper. | ||||
This combines two items (which may themselves be macros) into a single string, | This combines two items (which may themselves be macros) into a single string, | ||||
@@ -65,6 +67,17 @@ | |||||
CARLA_DECLARE_NON_COPY_CLASS(ClassName) | CARLA_DECLARE_NON_COPY_CLASS(ClassName) | ||||
#endif | #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 | Embedding an instance of this class inside another class can be used as a low-overhead | ||||