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