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();
|
||||
}
|
||||
|
||||
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.setChannels(numChannels);
|
||||
this->description = &description;
|
||||
const auto normalizedVelocity = normalizeVelocity(velocity);
|
||||
|
||||
// Setup the base values
|
||||
baseFrequency = description.frequency + normalizedVelocity * description.vel2frequency;
|
||||
baseFrequency = description.frequency + velocity * description.vel2frequency;
|
||||
baseBandwidth = description.bandwidth;
|
||||
baseGain = description.gain + normalizedVelocity * description.vel2gain;
|
||||
baseGain = description.gain + velocity * description.vel2gain;
|
||||
|
||||
// Setup the modulated values
|
||||
lastFrequency = midiState.modulate(baseFrequency, description.frequencyCC, Default::eqFrequencyRange);
|
||||
|
|
@ -84,7 +84,7 @@ sfz::EQPool::EQPool(const MidiState& state, int 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 };
|
||||
if (!canGiveOutEQs)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public:
|
|||
* @param numChannels the number of channels for the EQ
|
||||
* @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
|
||||
*
|
||||
|
|
@ -90,7 +90,7 @@ public:
|
|||
* @param velocity the triggering note velocity/value
|
||||
* @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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -16,8 +16,10 @@ void sfz::FilterHolder::reset()
|
|||
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;
|
||||
filter.setType(description.type);
|
||||
filter.setChannels(numChannels);
|
||||
|
|
@ -30,7 +32,7 @@ void sfz::FilterHolder::setup(const FilterDescription& description, unsigned num
|
|||
}
|
||||
const auto keytrack = description.keytrack * (noteNumber - description.keycenter);
|
||||
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 = Default::filterCutoffRange.clamp(baseCutoff);
|
||||
|
||||
|
|
@ -83,7 +85,7 @@ sfz::FilterPool::FilterPool(const MidiState& state, int 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 };
|
||||
if (!canGiveOutFilters)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public:
|
|||
* @param noteNumber the triggering note number
|
||||
* @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
|
||||
*
|
||||
|
|
@ -94,7 +94,7 @@ public:
|
|||
* @param velocity the triggering note velocity
|
||||
* @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
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue