Moved to larger CC arrays
This accodomates the extended sfz v2 CC
This commit is contained in:
parent
ced84dcd48
commit
85e6ccd81f
7 changed files with 19 additions and 20 deletions
|
|
@ -77,7 +77,7 @@ struct EGDescription
|
||||||
* @param velocity
|
* @param velocity
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
float getAttack(const CCValueArray &ccValues, uint8_t velocity) const noexcept
|
float getAttack(const SfzCCArray &ccValues, uint8_t velocity) const noexcept
|
||||||
{
|
{
|
||||||
return ccSwitchedValue(ccValues, ccAttack, attack) + normalizeCC(velocity)*vel2attack;
|
return ccSwitchedValue(ccValues, ccAttack, attack) + normalizeCC(velocity)*vel2attack;
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +88,7 @@ struct EGDescription
|
||||||
* @param velocity
|
* @param velocity
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
float getDecay(const CCValueArray &ccValues, uint8_t velocity) const noexcept
|
float getDecay(const SfzCCArray &ccValues, uint8_t velocity) const noexcept
|
||||||
{
|
{
|
||||||
return ccSwitchedValue(ccValues, ccDecay, decay) + normalizeCC(velocity)*vel2decay;
|
return ccSwitchedValue(ccValues, ccDecay, decay) + normalizeCC(velocity)*vel2decay;
|
||||||
}
|
}
|
||||||
|
|
@ -99,7 +99,7 @@ struct EGDescription
|
||||||
* @param velocity
|
* @param velocity
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
float getDelay(const CCValueArray &ccValues, uint8_t velocity) const noexcept
|
float getDelay(const SfzCCArray &ccValues, uint8_t velocity) const noexcept
|
||||||
{
|
{
|
||||||
return ccSwitchedValue(ccValues, ccDelay, delay) + normalizeCC(velocity)*vel2delay;
|
return ccSwitchedValue(ccValues, ccDelay, delay) + normalizeCC(velocity)*vel2delay;
|
||||||
}
|
}
|
||||||
|
|
@ -110,7 +110,7 @@ struct EGDescription
|
||||||
* @param velocity
|
* @param velocity
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
float getHold(const CCValueArray &ccValues, uint8_t velocity) const noexcept
|
float getHold(const SfzCCArray &ccValues, uint8_t velocity) const noexcept
|
||||||
{
|
{
|
||||||
return ccSwitchedValue(ccValues, ccHold, hold) + normalizeCC(velocity)*vel2hold;
|
return ccSwitchedValue(ccValues, ccHold, hold) + normalizeCC(velocity)*vel2hold;
|
||||||
}
|
}
|
||||||
|
|
@ -121,7 +121,7 @@ struct EGDescription
|
||||||
* @param velocity
|
* @param velocity
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
float getRelease(const CCValueArray &ccValues, uint8_t velocity) const noexcept
|
float getRelease(const SfzCCArray &ccValues, uint8_t velocity) const noexcept
|
||||||
{
|
{
|
||||||
return ccSwitchedValue(ccValues, ccRelease, release) + normalizeCC(velocity)*vel2release;
|
return ccSwitchedValue(ccValues, ccRelease, release) + normalizeCC(velocity)*vel2release;
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +132,7 @@ struct EGDescription
|
||||||
* @param velocity
|
* @param velocity
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
float getStart(const CCValueArray &ccValues, uint8_t velocity [[maybe_unused]]) const noexcept
|
float getStart(const SfzCCArray &ccValues, uint8_t velocity [[maybe_unused]]) const noexcept
|
||||||
{
|
{
|
||||||
return ccSwitchedValue(ccValues, ccStart, start);
|
return ccSwitchedValue(ccValues, ccStart, start);
|
||||||
}
|
}
|
||||||
|
|
@ -143,7 +143,7 @@ struct EGDescription
|
||||||
* @param velocity
|
* @param velocity
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
float getSustain(const CCValueArray &ccValues, uint8_t velocity) const noexcept
|
float getSustain(const SfzCCArray &ccValues, uint8_t velocity) const noexcept
|
||||||
{
|
{
|
||||||
return ccSwitchedValue(ccValues, ccSustain, sustain) + normalizeCC(velocity)*vel2sustain;
|
return ccSwitchedValue(ccValues, ccSustain, sustain) + normalizeCC(velocity)*vel2sustain;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ int sfz::MidiState::getPitchBend(int channel) const noexcept
|
||||||
void sfz::MidiState::ccEvent(int channel, int ccNumber, uint8_t ccValue) noexcept
|
void sfz::MidiState::ccEvent(int channel, int ccNumber, uint8_t ccValue) noexcept
|
||||||
{
|
{
|
||||||
ASSERT(channel >= 0 && channel < 16);
|
ASSERT(channel >= 0 && channel < 16);
|
||||||
ASSERT(ccNumber >= 0 && ccNumber <= 127);
|
ASSERT(ccNumber >= 0 && ccNumber <= 142);
|
||||||
ASSERT(ccValue >= 0 && ccValue <= 127);
|
ASSERT(ccValue >= 0 && ccValue <= 127);
|
||||||
|
|
||||||
cc[channel][ccNumber] = ccValue;
|
cc[channel][ccNumber] = ccValue;
|
||||||
|
|
@ -72,7 +72,7 @@ uint8_t sfz::MidiState::getCCValue(int channel, int ccNumber) const noexcept
|
||||||
return cc[channel][ccNumber];
|
return cc[channel][ccNumber];
|
||||||
}
|
}
|
||||||
|
|
||||||
const sfz::CCValueArray& sfz::MidiState::getCCArray(int channel) const noexcept
|
const sfz::SfzCCArray& sfz::MidiState::getCCArray(int channel) const noexcept
|
||||||
{
|
{
|
||||||
ASSERT(channel >= 0 && channel < 16);
|
ASSERT(channel >= 0 && channel < 16);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,9 @@ public:
|
||||||
* @brief Get the full CC status for a specific channel
|
* @brief Get the full CC status for a specific channel
|
||||||
*
|
*
|
||||||
* @param channel
|
* @param channel
|
||||||
* @return const CCValueArray&
|
* @return const SfzCCArray&
|
||||||
*/
|
*/
|
||||||
const CCValueArray& getCCArray(int channel) const noexcept;
|
const SfzCCArray& getCCArray(int channel) const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reset the midi state (does not impact the last note on time)
|
* @brief Reset the midi state (does not impact the last note on time)
|
||||||
|
|
@ -94,24 +94,24 @@ private:
|
||||||
template<class T>
|
template<class T>
|
||||||
using ChannelArray = std::array<T, 16>;
|
using ChannelArray = std::array<T, 16>;
|
||||||
template<class T>
|
template<class T>
|
||||||
using MidiArray = std::array<T, 128>;
|
using MidiNoteArray = std::array<T, 128>;
|
||||||
using NoteOnTime = std::chrono::steady_clock::time_point;
|
using NoteOnTime = std::chrono::steady_clock::time_point;
|
||||||
/**
|
/**
|
||||||
* @brief Stores the note on times.
|
* @brief Stores the note on times.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
ChannelArray<MidiArray<NoteOnTime>> noteOnTimes { };
|
ChannelArray<MidiNoteArray<NoteOnTime>> noteOnTimes { };
|
||||||
/**
|
/**
|
||||||
* @brief Stores the velocity of the note ons for currently
|
* @brief Stores the velocity of the note ons for currently
|
||||||
* depressed notes.
|
* depressed notes.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
ChannelArray<MidiArray<uint8_t>> lastNoteVelocities { };
|
ChannelArray<MidiNoteArray<uint8_t>> lastNoteVelocities { };
|
||||||
/**
|
/**
|
||||||
* @brief Current known values for the CCs.
|
* @brief Current known values for the CCs.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
ChannelArray<CCValueArray> cc;
|
ChannelArray<SfzCCArray> cc;
|
||||||
/**
|
/**
|
||||||
* Pitch bend status
|
* Pitch bend status
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -749,7 +749,7 @@ float sfz::Region::getNoteGain(int noteNumber, uint8_t velocity) noexcept
|
||||||
return baseGain;
|
return baseGain;
|
||||||
}
|
}
|
||||||
|
|
||||||
float sfz::Region::getCrossfadeGain(const sfz::CCValueArray& ccState) noexcept
|
float sfz::Region::getCrossfadeGain(const sfz::SfzCCArray& ccState) noexcept
|
||||||
{
|
{
|
||||||
float gain { 1.0f };
|
float gain { 1.0f };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ struct Region {
|
||||||
* @param ccState
|
* @param ccState
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
float getCrossfadeGain(const CCValueArray& ccState) noexcept;
|
float getCrossfadeGain(const SfzCCArray& ccState) noexcept;
|
||||||
/**
|
/**
|
||||||
* @brief Get the base volume of the region depending on which note has been
|
* @brief Get the base volume of the region depending on which note has been
|
||||||
* pressed to trigger the region.
|
* pressed to trigger the region.
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
namespace sfz
|
namespace sfz
|
||||||
{
|
{
|
||||||
|
|
||||||
using CCValueArray = std::array<uint8_t, 128>;
|
using SfzCCArray = std::array<uint8_t, 142>;
|
||||||
using CCValuePair = std::pair<uint8_t, float> ;
|
using CCValuePair = std::pair<uint8_t, float> ;
|
||||||
using CCNamePair = std::pair<uint8_t, std::string>;
|
using CCNamePair = std::pair<uint8_t, std::string>;
|
||||||
|
|
||||||
|
|
@ -109,7 +109,7 @@ constexpr float normalizeNegativePercents(T percentValue)
|
||||||
* @param value
|
* @param value
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
inline float ccSwitchedValue(const CCValueArray& ccValues, const absl::optional<CCValuePair>& ccSwitch, float value) noexcept
|
inline float ccSwitchedValue(const SfzCCArray& ccValues, const absl::optional<CCValuePair>& ccSwitch, float value) noexcept
|
||||||
{
|
{
|
||||||
if (ccSwitch)
|
if (ccSwitch)
|
||||||
return value + ccSwitch->second * normalizeCC(ccValues[ccSwitch->first]);
|
return value + ccSwitch->second * normalizeCC(ccValues[ccSwitch->first]);
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,6 @@ TEST_CASE("[Synth] Testing channel 1")
|
||||||
REQUIRE( region->sample == "dummy1.wav" );
|
REQUIRE( region->sample == "dummy1.wav" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("[Synth] Testing channel 2")
|
TEST_CASE("[Synth] Testing channel 2")
|
||||||
{
|
{
|
||||||
sfz::Synth synth;
|
sfz::Synth synth;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue