Trickle the delay to the MidiState
This commit is contained in:
parent
0994212718
commit
d94cc35c53
3 changed files with 20 additions and 22 deletions
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
sfz::MidiState::MidiState()
|
||||
{
|
||||
reset();
|
||||
reset(0);
|
||||
}
|
||||
|
||||
void sfz::MidiState::noteOnEvent(int noteNumber, uint8_t velocity) noexcept
|
||||
void sfz::MidiState::noteOnEvent(int delay, int noteNumber, uint8_t velocity) noexcept
|
||||
{
|
||||
ASSERT(noteNumber >= 0 && noteNumber <= 127);
|
||||
ASSERT(velocity >= 0 && velocity <= 127);
|
||||
|
|
@ -25,7 +25,7 @@ void sfz::MidiState::noteOnEvent(int noteNumber, uint8_t velocity) noexcept
|
|||
|
||||
}
|
||||
|
||||
void sfz::MidiState::noteOffEvent(int noteNumber, uint8_t velocity [[maybe_unused]]) noexcept
|
||||
void sfz::MidiState::noteOffEvent(int delay, int noteNumber, uint8_t velocity [[maybe_unused]]) noexcept
|
||||
{
|
||||
ASSERT(noteNumber >= 0 && noteNumber <= 127);
|
||||
ASSERT(velocity >= 0 && velocity <= 127);
|
||||
|
|
@ -57,7 +57,7 @@ uint8_t sfz::MidiState::getNoteVelocity(int noteNumber) const noexcept
|
|||
return lastNoteVelocities[noteNumber];
|
||||
}
|
||||
|
||||
void sfz::MidiState::pitchBendEvent(int pitchBendValue) noexcept
|
||||
void sfz::MidiState::pitchBendEvent(int delay, int pitchBendValue) noexcept
|
||||
{
|
||||
ASSERT(pitchBendValue >= -8192 && pitchBendValue <= 8192);
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ int sfz::MidiState::getPitchBend() const noexcept
|
|||
return pitchBend;
|
||||
}
|
||||
|
||||
void sfz::MidiState::ccEvent(int ccNumber, uint8_t ccValue) noexcept
|
||||
void sfz::MidiState::ccEvent(int delay, int ccNumber, uint8_t ccValue) noexcept
|
||||
{
|
||||
ASSERT(ccNumber >= 0 && ccNumber < config::numCCs);
|
||||
ASSERT(ccValue >= 0 && ccValue <= 127);
|
||||
|
|
@ -89,7 +89,7 @@ const sfz::SfzCCArray& sfz::MidiState::getCCArray() const noexcept
|
|||
return cc;
|
||||
}
|
||||
|
||||
void sfz::MidiState::reset() noexcept
|
||||
void sfz::MidiState::reset(int delay) noexcept
|
||||
{
|
||||
for (auto& velocity: lastNoteVelocities)
|
||||
velocity = 0;
|
||||
|
|
@ -101,7 +101,7 @@ void sfz::MidiState::reset() noexcept
|
|||
activeNotes = 0;
|
||||
}
|
||||
|
||||
void sfz::MidiState::resetAllControllers() noexcept
|
||||
void sfz::MidiState::resetAllControllers(int delay) noexcept
|
||||
{
|
||||
for (int idx = 0; idx < config::numCCs; idx++)
|
||||
cc[idx] = 0;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public:
|
|||
* @param noteNumber
|
||||
* @param velocity
|
||||
*/
|
||||
void noteOnEvent(int noteNumber, uint8_t velocity) noexcept;
|
||||
void noteOnEvent(int delay, int noteNumber, uint8_t velocity) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Update the state after a note off event
|
||||
|
|
@ -37,7 +37,7 @@ public:
|
|||
* @param noteNumber
|
||||
* @param velocity
|
||||
*/
|
||||
void noteOffEvent(int noteNumber, uint8_t velocity) noexcept;
|
||||
void noteOffEvent(int delay, int noteNumber, uint8_t velocity) noexcept;
|
||||
|
||||
int getActiveNotes() const noexcept { return activeNotes; }
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ public:
|
|||
*
|
||||
* @param pitchBendValue
|
||||
*/
|
||||
void pitchBendEvent(int pitchBendValue) noexcept;
|
||||
void pitchBendEvent(int delay, int pitchBendValue) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Get the pitch bend status
|
||||
|
|
@ -77,7 +77,7 @@ public:
|
|||
* @param ccNumber
|
||||
* @param ccValue
|
||||
*/
|
||||
void ccEvent(int ccNumber, uint8_t ccValue) noexcept;
|
||||
void ccEvent(int delay, int ccNumber, uint8_t ccValue) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Get the CC value for CC number
|
||||
|
|
@ -98,12 +98,12 @@ public:
|
|||
* @brief Reset the midi state (does not impact the last note on time)
|
||||
*
|
||||
*/
|
||||
void reset() noexcept;
|
||||
void reset(int delay) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Reset all the controllers
|
||||
*/
|
||||
void resetAllControllers() noexcept;
|
||||
void resetAllControllers(int delay) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Modulate a value using the last entered CCs in the midiState
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ void sfz::Synth::clear()
|
|||
fileTicket = -1;
|
||||
defaultSwitch = absl::nullopt;
|
||||
defaultPath = "";
|
||||
resources.midiState.reset();
|
||||
resources.midiState.reset(0);
|
||||
ccNames.clear();
|
||||
globalOpcodes.clear();
|
||||
masterOpcodes.clear();
|
||||
|
|
@ -167,7 +167,7 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
|
|||
case hash("set_cc&"):
|
||||
if (Default::ccNumberRange.containsWithEnd(member.parameters.back())) {
|
||||
const auto ccValue = readOpcode(member.value, Default::ccValueRange).value_or(0);
|
||||
resources.midiState.ccEvent(member.parameters.back(), ccValue);
|
||||
resources.midiState.ccEvent(0, member.parameters.back(), ccValue);
|
||||
}
|
||||
break;
|
||||
case hash("Label_cc&"): [[fallthrough]];
|
||||
|
|
@ -579,7 +579,7 @@ void sfz::Synth::noteOn(int delay, int noteNumber, uint8_t velocity) noexcept
|
|||
ASSERT(noteNumber >= 0);
|
||||
|
||||
ScopedTiming logger { dispatchDuration, ScopedTiming::Operation::addToDuration };
|
||||
resources.midiState.noteOnEvent(noteNumber, velocity);
|
||||
resources.midiState.noteOnEvent(delay, noteNumber, velocity);
|
||||
|
||||
AtomicGuard callbackGuard { inCallback };
|
||||
if (!canEnterCallback)
|
||||
|
|
@ -594,7 +594,7 @@ void sfz::Synth::noteOff(int delay, int noteNumber, uint8_t velocity [[maybe_unu
|
|||
ASSERT(noteNumber >= 0);
|
||||
|
||||
ScopedTiming logger { dispatchDuration, ScopedTiming::Operation::addToDuration };
|
||||
resources.midiState.noteOffEvent(noteNumber, velocity);
|
||||
resources.midiState.noteOffEvent(delay, noteNumber, velocity);
|
||||
|
||||
AtomicGuard callbackGuard { inCallback };
|
||||
if (!canEnterCallback)
|
||||
|
|
@ -650,8 +650,7 @@ void sfz::Synth::cc(int delay, int ccNumber, uint8_t ccValue) noexcept
|
|||
ASSERT(ccNumber >= 0);
|
||||
|
||||
ScopedTiming logger { dispatchDuration, ScopedTiming::Operation::addToDuration };
|
||||
|
||||
resources.midiState.ccEvent(ccNumber, ccValue);
|
||||
resources.midiState.ccEvent(delay, ccNumber, ccValue);
|
||||
|
||||
AtomicGuard callbackGuard { inCallback };
|
||||
if (!canEnterCallback)
|
||||
|
|
@ -682,8 +681,7 @@ void sfz::Synth::pitchWheel(int delay, int pitch) noexcept
|
|||
ASSERT(pitch >= -8192);
|
||||
|
||||
ScopedTiming logger { dispatchDuration, ScopedTiming::Operation::addToDuration };
|
||||
|
||||
resources.midiState.pitchBendEvent(pitch);
|
||||
resources.midiState.pitchBendEvent(delay, pitch);
|
||||
|
||||
for (auto& region: regions) {
|
||||
region->registerPitchWheel(pitch);
|
||||
|
|
@ -924,7 +922,7 @@ void sfz::Synth::resetAllControllers(int delay) noexcept
|
|||
if (!canEnterCallback)
|
||||
return;
|
||||
|
||||
resources.midiState.resetAllControllers();
|
||||
resources.midiState.resetAllControllers(delay);
|
||||
for (auto& voice: voices) {
|
||||
voice->registerPitchWheel(delay, 0);
|
||||
for (int cc = 0; cc < config::numCCs; ++cc)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue