Moved to larger CC arrays

This accodomates the extended sfz v2 CC
This commit is contained in:
Paul Ferrand 2019-12-17 12:32:01 +01:00
parent ced84dcd48
commit 85e6ccd81f
7 changed files with 19 additions and 20 deletions

View file

@ -77,7 +77,7 @@ struct EGDescription
* @param velocity
* @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;
}
@ -88,7 +88,7 @@ struct EGDescription
* @param velocity
* @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;
}
@ -99,7 +99,7 @@ struct EGDescription
* @param velocity
* @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;
}
@ -110,7 +110,7 @@ struct EGDescription
* @param velocity
* @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;
}
@ -121,7 +121,7 @@ struct EGDescription
* @param velocity
* @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;
}
@ -132,7 +132,7 @@ struct EGDescription
* @param velocity
* @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);
}
@ -143,7 +143,7 @@ struct EGDescription
* @param velocity
* @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;
}

View file

@ -58,7 +58,7 @@ int sfz::MidiState::getPitchBend(int channel) const noexcept
void sfz::MidiState::ccEvent(int channel, int ccNumber, uint8_t ccValue) noexcept
{
ASSERT(channel >= 0 && channel < 16);
ASSERT(ccNumber >= 0 && ccNumber <= 127);
ASSERT(ccNumber >= 0 && ccNumber <= 142);
ASSERT(ccValue >= 0 && ccValue <= 127);
cc[channel][ccNumber] = ccValue;
@ -72,7 +72,7 @@ uint8_t sfz::MidiState::getCCValue(int channel, int ccNumber) const noexcept
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);

View file

@ -80,9 +80,9 @@ public:
* @brief Get the full CC status for a specific 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)
@ -94,24 +94,24 @@ private:
template<class T>
using ChannelArray = std::array<T, 16>;
template<class T>
using MidiArray = std::array<T, 128>;
using MidiNoteArray = std::array<T, 128>;
using NoteOnTime = std::chrono::steady_clock::time_point;
/**
* @brief Stores the note on times.
*
*/
ChannelArray<MidiArray<NoteOnTime>> noteOnTimes { };
ChannelArray<MidiNoteArray<NoteOnTime>> noteOnTimes { };
/**
* @brief Stores the velocity of the note ons for currently
* depressed notes.
*
*/
ChannelArray<MidiArray<uint8_t>> lastNoteVelocities { };
ChannelArray<MidiNoteArray<uint8_t>> lastNoteVelocities { };
/**
* @brief Current known values for the CCs.
*
*/
ChannelArray<CCValueArray> cc;
ChannelArray<SfzCCArray> cc;
/**
* Pitch bend status
*/

View file

@ -749,7 +749,7 @@ float sfz::Region::getNoteGain(int noteNumber, uint8_t velocity) noexcept
return baseGain;
}
float sfz::Region::getCrossfadeGain(const sfz::CCValueArray& ccState) noexcept
float sfz::Region::getCrossfadeGain(const sfz::SfzCCArray& ccState) noexcept
{
float gain { 1.0f };

View file

@ -172,7 +172,7 @@ struct Region {
* @param ccState
* @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
* pressed to trigger the region.

View file

@ -31,7 +31,7 @@
namespace sfz
{
using CCValueArray = std::array<uint8_t, 128>;
using SfzCCArray = std::array<uint8_t, 142>;
using CCValuePair = std::pair<uint8_t, float> ;
using CCNamePair = std::pair<uint8_t, std::string>;
@ -109,7 +109,7 @@ constexpr float normalizeNegativePercents(T percentValue)
* @param value
* @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)
return value + ccSwitch->second * normalizeCC(ccValues[ccSwitch->first]);

View file

@ -336,7 +336,6 @@ TEST_CASE("[Synth] Testing channel 1")
REQUIRE( region->sample == "dummy1.wav" );
}
TEST_CASE("[Synth] Testing channel 2")
{
sfz::Synth synth;