@@ -2160,3 +2160,46 @@ TEST_CASE("[Synth] Reuse offed voices in the last case scenario for new notes")
2160
2160
REQUIRE ( notes == std::vector<int > { i - 1 , i } );
2161
2161
}
2162
2162
}
2163
+
2164
+ TEST_CASE (" [Synth] Note on and off at the maximum delay" )
2165
+ {
2166
+ sfz::Synth synth;
2167
+ synth.setSampleRate (12800 );
2168
+ synth.setSamplesPerBlock (128 );
2169
+ sfz::AudioBuffer<float > buffer { 2 , static_cast <unsigned >(synth.getSamplesPerBlock ()) };
2170
+ synth.loadSfzString (fs::current_path () / " tests/TestFiles/noteonoff.sfz" , R"(
2171
+ <region> loop_start=4 loop_end=124 ampeg_release=0.5 sample=looped_flute.wav
2172
+ )" );
2173
+ synth.setNumVoices (128 );
2174
+ synth.noteOn (127 , 64 , 64 );
2175
+ CHECK (synth.getNumActiveVoices () == 1 );
2176
+ synth.noteOff (127 , 64 , 0 );
2177
+ CHECK (synth.getNumActiveVoices () == 1 );
2178
+ // Render for a while
2179
+ for (int i = 0 ; i < 100 ; ++i)
2180
+ synth.renderBlock (buffer);
2181
+ CHECK (synth.getNumActiveVoices () == 0 );
2182
+ }
2183
+
2184
+ TEST_CASE (" [Synth] Note on and off with delay" )
2185
+ {
2186
+ sfz::Synth synth;
2187
+ synth.setSampleRate (12800 );
2188
+ synth.setSamplesPerBlock (128 );
2189
+ sfz::AudioBuffer<float > buffer { 2 , static_cast <unsigned >(synth.getSamplesPerBlock ()) };
2190
+ synth.loadSfzString (fs::current_path () / " tests/TestFiles/noteonoff.sfz" , R"(
2191
+ <region> loop_start=4 loop_end=124 ampeg_release=0.5 sample=looped_flute.wav
2192
+ )" );
2193
+ synth.setNumVoices (128 );
2194
+
2195
+ int i;
2196
+ for (i = 0 ; i < 127 ; ++i) {
2197
+ synth.noteOn (i, i, 64 );
2198
+ synth.noteOff (i+1 , i, 0 );
2199
+ }
2200
+ CHECK (synth.getNumActiveVoices () == 127 );
2201
+ // Render for a while
2202
+ for (int i = 0 ; i < 100 ; ++i)
2203
+ synth.renderBlock (buffer);
2204
+ CHECK (synth.getNumActiveVoices () == 0 );
2205
+ }
0 commit comments