Reset to default CC values
This commit is contained in:
parent
f8c498b227
commit
4defdce04a
5 changed files with 32 additions and 29 deletions
|
|
@ -230,14 +230,6 @@ void sfz::MidiState::reset() noexcept
|
||||||
absl::c_fill(noteOffTimes, 0);
|
absl::c_fill(noteOffTimes, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfz::MidiState::resetAllControllers(int delay) noexcept
|
|
||||||
{
|
|
||||||
for (int ccIdx = 0; ccIdx < config::numCCs; ++ccIdx)
|
|
||||||
ccEvent(delay, ccIdx, 0.0f);
|
|
||||||
|
|
||||||
pitchBendEvent(delay, 0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
const sfz::EventVector& sfz::MidiState::getCCEvents(int ccIdx) const noexcept
|
const sfz::EventVector& sfz::MidiState::getCCEvents(int ccIdx) const noexcept
|
||||||
{
|
{
|
||||||
if (ccIdx < 0 || ccIdx >= config::numCCs)
|
if (ccIdx < 0 || ccIdx >= config::numCCs)
|
||||||
|
|
|
||||||
|
|
@ -180,11 +180,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void reset() noexcept;
|
void reset() noexcept;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Reset all the controllers
|
|
||||||
*/
|
|
||||||
void resetAllControllers(int delay) noexcept;
|
|
||||||
|
|
||||||
const EventVector& getCCEvents(int ccIdx) const noexcept;
|
const EventVector& getCCEvents(int ccIdx) const noexcept;
|
||||||
const EventVector& getPolyAftertouchEvents(int noteNumber) const noexcept;
|
const EventVector& getPolyAftertouchEvents(int noteNumber) const noexcept;
|
||||||
const EventVector& getPitchEvents() const noexcept;
|
const EventVector& getPitchEvents() const noexcept;
|
||||||
|
|
|
||||||
|
|
@ -1926,18 +1926,21 @@ void Synth::disableFreeWheeling() noexcept
|
||||||
|
|
||||||
void Synth::Impl::resetAllControllers(int delay) noexcept
|
void Synth::Impl::resetAllControllers(int delay) noexcept
|
||||||
{
|
{
|
||||||
resources_.getMidiState().resetAllControllers(delay);
|
MidiState& midiState = resources_.getMidiState();
|
||||||
|
midiState.pitchBendEvent(delay, 0.0f);
|
||||||
|
for (int cc = 0; cc < config::numCCs; ++cc)
|
||||||
|
midiState.ccEvent(delay, cc, defaultCCValues_[cc]);
|
||||||
|
|
||||||
for (auto& voice : voiceManager_) {
|
for (auto& voice : voiceManager_) {
|
||||||
voice.registerPitchWheel(delay, 0);
|
voice.registerPitchWheel(delay, 0);
|
||||||
for (int cc = 0; cc < config::numCCs; ++cc)
|
for (int cc = 0; cc < config::numCCs; ++cc)
|
||||||
voice.registerCC(delay, cc, 0.0f);
|
voice.registerCC(delay, cc, defaultCCValues_[cc]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const LayerPtr& layerPtr : layers_) {
|
for (const LayerPtr& layerPtr : layers_) {
|
||||||
Layer& layer = *layerPtr;
|
Layer& layer = *layerPtr;
|
||||||
for (int cc = 0; cc < config::numCCs; ++cc)
|
for (int cc = 0; cc < config::numCCs; ++cc)
|
||||||
layer.registerCC(cc, 0.0f);
|
layer.registerCC(cc, defaultCCValues_[cc]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,19 +57,6 @@ TEST_CASE("[MidiState] Reset")
|
||||||
REQUIRE(state.getCCValue(123) == 0_norm);
|
REQUIRE(state.getCCValue(123) == 0_norm);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("[MidiState] Reset all controllers")
|
|
||||||
{
|
|
||||||
sfz::MidiState state;
|
|
||||||
state.pitchBendEvent(20, 0.7f);
|
|
||||||
state.ccEvent(10, 122, 124_norm);
|
|
||||||
REQUIRE(state.getPitchBend() == 0.7f);
|
|
||||||
REQUIRE(state.getCCValue(122) == 124_norm);
|
|
||||||
state.resetAllControllers(30);
|
|
||||||
REQUIRE(state.getPitchBend() == 0.0f);
|
|
||||||
REQUIRE(state.getCCValue(122) == 0_norm);
|
|
||||||
REQUIRE(state.getCCValue(4) == 0_norm);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("[MidiState] Set and get note velocities")
|
TEST_CASE("[MidiState] Set and get note velocities")
|
||||||
{
|
{
|
||||||
sfz::MidiState state;
|
sfz::MidiState state;
|
||||||
|
|
|
||||||
|
|
@ -1828,3 +1828,29 @@ TEST_CASE("[Synth] Short empty files are turned into *silence")
|
||||||
};
|
};
|
||||||
REQUIRE(messageList == expected);
|
REQUIRE(messageList == expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST_CASE("[Synth] Resets all controllers to default values")
|
||||||
|
{
|
||||||
|
sfz::Synth synth;
|
||||||
|
std::vector<std::string> messageList;
|
||||||
|
sfz::Client client(&messageList);
|
||||||
|
client.setReceiveCallback(&simpleMessageReceiver);
|
||||||
|
sfz::AudioBuffer<float> buffer { 2, static_cast<unsigned>(synth.getSamplesPerBlock()) };
|
||||||
|
synth.loadSfzString(fs::current_path() / "tests/TestFiles/default_cc.sfz", R"(
|
||||||
|
<control> set_cc56=64
|
||||||
|
<region> sample=*sine
|
||||||
|
)");
|
||||||
|
REQUIRE( synth.getHdcc(56) == 64_norm );
|
||||||
|
REQUIRE( synth.getHdcc(78) == 0.0f );
|
||||||
|
synth.cc(0, 56, 10);
|
||||||
|
synth.cc(0, 78, 100);
|
||||||
|
synth.renderBlock(buffer);
|
||||||
|
REQUIRE( synth.getHdcc(56) == 10_norm );
|
||||||
|
REQUIRE( synth.getHdcc(78) == 100_norm );
|
||||||
|
synth.cc(0, 121, 127);
|
||||||
|
synth.cc(0, 121, 0);
|
||||||
|
synth.renderBlock(buffer);
|
||||||
|
REQUIRE( synth.getHdcc(56) == 64_norm );
|
||||||
|
REQUIRE( synth.getHdcc(78) == 0.0f );
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue