Skip to content

Commit

Permalink
Adjust release-by-note-id for ST modes (surge-synthesizer#7228)
Browse files Browse the repository at this point in the history
In ST modes release-by-note-id didn't work properly with
recycled note ids, and our tests didn't test this.

Now it does work it seems and our tests are a bit more comprehensive
but we really need to expand the coverage through that test set in
UnitTestsVOICE
  • Loading branch information
baconpaul authored Sep 30, 2023
1 parent d892ccb commit ba498ce
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 106 deletions.
9 changes: 9 additions & 0 deletions src/common/SurgeSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1762,11 +1762,20 @@ void SurgeSynthesizer::releaseNoteByHostNoteID(int32_t host_noteid, char velocit

for (int s = 0; s < n_scenes; ++s)
{
auto &ptS = storage.getPatch().scene[s];

// In the single trigger mode we can recycle ids
// so we need to portentialy kill the originating
// note also
bool recycleNoteID =
ptS.polymode.val.i == pm_mono_st_fp || ptS.polymode.val.i == pm_mono_st;
for (auto v : voices[s])
{
if (v->host_note_id == host_noteid)
{
done[v->state.key] |= 1 << v->state.channel;
if (recycleNoteID)
done[v->originating_host_key] |= 1 << v->state.channel;
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/common/dsp/effects/AudioInputEffect.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
* Surge XT - a free and open source hybrid synthesizer,
* built by Surge Synth Team
*
* Learn more at https://surge-synthesizer.github.io/
*
* Copyright 2018-2023, various authors, as described in the GitHub
* transaction log.
*
* Surge XT is released under the GNU General Public Licence v3
* or later (GPL-3.0-or-later). The license is found in the "LICENSE"
* file in the root of this repository, or at
* https://www.gnu.org/licenses/gpl-3.0.en.html
*
* Surge was a commercial product from 2004-2018, copyright and ownership
* held by Claes Johanson at Vember Audio during that period.
* Claes made Surge open source in September 2018.
*
* All source for Surge XT is available at
* https://github.com/surge-synthesizer/surge
*/

#include "AudioInputEffect.h"

Expand Down
38 changes: 24 additions & 14 deletions src/common/dsp/effects/AudioInputEffect.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
/*
** Surge Synthesizer is Free and Open Source Software
**
** Surge is made available under the Gnu General Public License, v3.0
** https://www.gnu.org/licenses/gpl-3.0.en.html
**
** Copyright 2004-2023 by various individuals as described by the Git transaction log
**
** All source at: https://github.com/surge-synthesizer/surge.git
**
** Surge was a commercial product from 2004-2018, with Copyright and ownership
** in that period held by Claes Johanson at Vember Audio. Claes made Surge
** open source in September 2018.
*/
#pragma once
* Surge XT - a free and open source hybrid synthesizer,
* built by Surge Synth Team
*
* Learn more at https://surge-synthesizer.github.io/
*
* Copyright 2018-2023, various authors, as described in the GitHub
* transaction log.
*
* Surge XT is released under the GNU General Public Licence v3
* or later (GPL-3.0-or-later). The license is found in the "LICENSE"
* file in the root of this repository, or at
* https://www.gnu.org/licenses/gpl-3.0.en.html
*
* Surge was a commercial product from 2004-2018, copyright and ownership
* held by Claes Johanson at Vember Audio during that period.
* Claes made Surge open source in September 2018.
*
* All source for Surge XT is available at
* https://github.com/surge-synthesizer/surge
*/
#ifndef SURGE_SRC_COMMON_DSP_EFFECTS_AUDIOINPUTEFFECT_H
#define SURGE_SRC_COMMON_DSP_EFFECTS_AUDIOINPUTEFFECT_H
#include "Effect.h"
class AudioInputEffect : public Effect
{
Expand Down Expand Up @@ -57,3 +65,5 @@ class AudioInputEffect : public Effect
void applySlidersControls(float *buffer[], const float &channel, const float &pan,
const float &levelDb);
};

#endif // SURGE_SRC_COMMON_DSP_EFFECTS_AUDIOINPUTEFFECT_H
1 change: 1 addition & 0 deletions src/surge-testrunner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ add_executable(${PROJECT_NAME}
UnitTestsPARAM.cpp
UnitTestsQUERY.cpp
UnitTestsTUN.cpp
UnitTestsVOICE.cpp
main.cpp
)

Expand Down
90 changes: 0 additions & 90 deletions src/surge-testrunner/UnitTestsMIDI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1723,93 +1723,3 @@ TEST_CASE("Latch in Dual MPE", "[midi]")
}
}
}

TEST_CASE("Release by Note ID", "[midi]")
{
SECTION("Simple Sine Case")
{
auto s = surgeOnSine();

auto proc = [&s]() {
for (int i = 0; i < 5; ++i)
{
s->process();
}
};

auto voicecount = [&s]() -> int {
int res{0};
for (auto sc = 0; sc < n_scenes; ++sc)
{
for (const auto &v : s->voices[sc])
{
if (v->state.gate)
res++;
}
}
return res;
};

proc();

s->playNote(0, 60, 127, 0, 173);
proc();
REQUIRE(voicecount() == 1);

s->playNote(0, 64, 127, 0, 177);
proc();
REQUIRE(voicecount() == 2);

s->releaseNoteByHostNoteID(173, 0);
proc();
REQUIRE(voicecount() == 1);

s->releaseNoteByHostNoteID(177, 0);
proc();
REQUIRE(voicecount() == 0);
}

SECTION("Playmode DUal Sine Case")
{
auto s = surgeOnSine();
s->storage.getPatch().scenemode.val.i = sm_dual;

auto proc = [&s]() {
for (int i = 0; i < 5; ++i)
{
s->process();
}
};

auto voicecount = [&s]() -> int {
int res{0};
for (auto sc = 0; sc < n_scenes; ++sc)
{
for (const auto &v : s->voices[sc])
{
if (v->state.gate)
res++;
}
}
return res;
};

proc();

s->playNote(0, 60, 127, 0, 173);
proc();
REQUIRE(voicecount() == 2);

s->playNote(0, 64, 127, 0, 177);
proc();
REQUIRE(voicecount() == 4);

s->releaseNoteByHostNoteID(173, 0);
proc();
REQUIRE(voicecount() == 2);

s->releaseNoteByHostNoteID(177, 0);
proc();
REQUIRE(voicecount() == 0);
}
}
Loading

0 comments on commit ba498ce

Please sign in to comment.