Use float velocity in filters and EQ
This commit is contained in:
parent
4c2e0ab6b9
commit
de0d86fa09
4 changed files with 14 additions and 12 deletions
|
|
@ -15,17 +15,17 @@ void sfz::EQHolder::reset()
|
||||||
eq.clear();
|
eq.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfz::EQHolder::setup(const EQDescription& description, unsigned numChannels, uint8_t velocity)
|
void sfz::EQHolder::setup(const EQDescription& description, unsigned numChannels, float velocity)
|
||||||
{
|
{
|
||||||
|
ASSERT(velocity >= 0.0f && velocity <= 1.0f);
|
||||||
eq.setType(description.type);
|
eq.setType(description.type);
|
||||||
eq.setChannels(numChannels);
|
eq.setChannels(numChannels);
|
||||||
this->description = &description;
|
this->description = &description;
|
||||||
const auto normalizedVelocity = normalizeVelocity(velocity);
|
|
||||||
|
|
||||||
// Setup the base values
|
// Setup the base values
|
||||||
baseFrequency = description.frequency + normalizedVelocity * description.vel2frequency;
|
baseFrequency = description.frequency + velocity * description.vel2frequency;
|
||||||
baseBandwidth = description.bandwidth;
|
baseBandwidth = description.bandwidth;
|
||||||
baseGain = description.gain + normalizedVelocity * description.vel2gain;
|
baseGain = description.gain + velocity * description.vel2gain;
|
||||||
|
|
||||||
// Setup the modulated values
|
// Setup the modulated values
|
||||||
lastFrequency = midiState.modulate(baseFrequency, description.frequencyCC, Default::eqFrequencyRange);
|
lastFrequency = midiState.modulate(baseFrequency, description.frequencyCC, Default::eqFrequencyRange);
|
||||||
|
|
@ -84,7 +84,7 @@ sfz::EQPool::EQPool(const MidiState& state, int numEQs)
|
||||||
setnumEQs(numEQs);
|
setnumEQs(numEQs);
|
||||||
}
|
}
|
||||||
|
|
||||||
sfz::EQHolderPtr sfz::EQPool::getEQ(const EQDescription& description, unsigned numChannels, uint8_t velocity)
|
sfz::EQHolderPtr sfz::EQPool::getEQ(const EQDescription& description, unsigned numChannels, float velocity)
|
||||||
{
|
{
|
||||||
AtomicGuard guard { givingOutEQs };
|
AtomicGuard guard { givingOutEQs };
|
||||||
if (!canGiveOutEQs)
|
if (!canGiveOutEQs)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ public:
|
||||||
* @param numChannels the number of channels for the EQ
|
* @param numChannels the number of channels for the EQ
|
||||||
* @param description the triggering velocity/value
|
* @param description the triggering velocity/value
|
||||||
*/
|
*/
|
||||||
void setup(const EQDescription& description, unsigned numChannels, uint8_t velocity);
|
void setup(const EQDescription& description, unsigned numChannels, float velocity);
|
||||||
/**
|
/**
|
||||||
* @brief Process a block of stereo inputs
|
* @brief Process a block of stereo inputs
|
||||||
*
|
*
|
||||||
|
|
@ -90,7 +90,7 @@ public:
|
||||||
* @param velocity the triggering note velocity/value
|
* @param velocity the triggering note velocity/value
|
||||||
* @return EQHolderPtr release this when done with the filter; no deallocation will be done
|
* @return EQHolderPtr release this when done with the filter; no deallocation will be done
|
||||||
*/
|
*/
|
||||||
EQHolderPtr getEQ(const EQDescription& description, unsigned numChannels, uint8_t velocity);
|
EQHolderPtr getEQ(const EQDescription& description, unsigned numChannels, float velocity);
|
||||||
/**
|
/**
|
||||||
* @brief Get the number of active EQs
|
* @brief Get the number of active EQs
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,10 @@ void sfz::FilterHolder::reset()
|
||||||
filter.clear();
|
filter.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfz::FilterHolder::setup(const FilterDescription& description, unsigned numChannels, int noteNumber, uint8_t velocity)
|
void sfz::FilterHolder::setup(const FilterDescription& description, unsigned numChannels, int noteNumber, float velocity)
|
||||||
{
|
{
|
||||||
|
ASSERT(velocity >= 0.0f && velocity <= 1.0f);
|
||||||
|
|
||||||
this->description = &description;
|
this->description = &description;
|
||||||
filter.setType(description.type);
|
filter.setType(description.type);
|
||||||
filter.setChannels(numChannels);
|
filter.setChannels(numChannels);
|
||||||
|
|
@ -30,7 +32,7 @@ void sfz::FilterHolder::setup(const FilterDescription& description, unsigned num
|
||||||
}
|
}
|
||||||
const auto keytrack = description.keytrack * (noteNumber - description.keycenter);
|
const auto keytrack = description.keytrack * (noteNumber - description.keycenter);
|
||||||
baseCutoff *= centsFactor(keytrack);
|
baseCutoff *= centsFactor(keytrack);
|
||||||
const auto veltrack = static_cast<float>(description.veltrack) * normalizeVelocity(velocity);
|
const auto veltrack = static_cast<float>(description.veltrack) * velocity;
|
||||||
baseCutoff *= centsFactor(veltrack);
|
baseCutoff *= centsFactor(veltrack);
|
||||||
baseCutoff = Default::filterCutoffRange.clamp(baseCutoff);
|
baseCutoff = Default::filterCutoffRange.clamp(baseCutoff);
|
||||||
|
|
||||||
|
|
@ -83,7 +85,7 @@ sfz::FilterPool::FilterPool(const MidiState& state, int numFilters)
|
||||||
setNumFilters(numFilters);
|
setNumFilters(numFilters);
|
||||||
}
|
}
|
||||||
|
|
||||||
sfz::FilterHolderPtr sfz::FilterPool::getFilter(const FilterDescription& description, unsigned numChannels, int noteNumber, uint8_t velocity)
|
sfz::FilterHolderPtr sfz::FilterPool::getFilter(const FilterDescription& description, unsigned numChannels, int noteNumber, float velocity)
|
||||||
{
|
{
|
||||||
AtomicGuard guard { givingOutFilters };
|
AtomicGuard guard { givingOutFilters };
|
||||||
if (!canGiveOutFilters)
|
if (!canGiveOutFilters)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ public:
|
||||||
* @param noteNumber the triggering note number
|
* @param noteNumber the triggering note number
|
||||||
* @param velocity the triggering note velocity/value
|
* @param velocity the triggering note velocity/value
|
||||||
*/
|
*/
|
||||||
void setup(const FilterDescription& description, unsigned numChannels, int noteNumber = static_cast<int>(Default::filterKeycenter), uint8_t velocity = 0);
|
void setup(const FilterDescription& description, unsigned numChannels, int noteNumber = static_cast<int>(Default::filterKeycenter), float velocity = 0);
|
||||||
/**
|
/**
|
||||||
* @brief Process a block of stereo inputs
|
* @brief Process a block of stereo inputs
|
||||||
*
|
*
|
||||||
|
|
@ -94,7 +94,7 @@ public:
|
||||||
* @param velocity the triggering note velocity
|
* @param velocity the triggering note velocity
|
||||||
* @return FilterHolderPtr release this when done with the filter; no deallocation will be done
|
* @return FilterHolderPtr release this when done with the filter; no deallocation will be done
|
||||||
*/
|
*/
|
||||||
FilterHolderPtr getFilter(const FilterDescription& description, unsigned numChannels, int noteNumber = static_cast<int>(Default::filterKeycenter), uint8_t velocity = 0);
|
FilterHolderPtr getFilter(const FilterDescription& description, unsigned numChannels, int noteNumber = static_cast<int>(Default::filterKeycenter), float velocity = 0);
|
||||||
/**
|
/**
|
||||||
* @brief Get the number of active filters
|
* @brief Get the number of active filters
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue