mirror of
https://codeberg.org/armin/justasample.git
synced 2026-09-01 04:10:48 +02:00
add ping-pong loop mode and crossfade length rotary
This commit is contained in:
parent
4bd1156835
commit
e9dc3a4d66
10 changed files with 67 additions and 17 deletions
|
|
@ -91,11 +91,17 @@ void CustomSamplerVoice::startNote(int midiNoteNumber, float velocity, juce::Syn
|
|||
|
||||
playUntilEnd = sampleSound.playUntilEnd->get();
|
||||
isLooping = sampleSound.isLooping->get() || wavetableMode;
|
||||
loopingHasStart = isLooping && sampleSound.loopingHasStart->get() && sampleSound.loopStart < sampleSound.sampleStart && !wavetableMode;
|
||||
isPingPong = isLooping && sampleSound.isPingPong->get() && !wavetableMode;
|
||||
loopingHasStart = isLooping && sampleSound.loopingHasStart->get() && sampleSound.loopStart < sampleSound.sampleStart && !wavetableMode && !isPingPong;
|
||||
loopStart = sampleSound.loopStart;
|
||||
loopingHasEnd = isLooping && sampleSound.loopingHasEnd->get() && sampleSound.loopEnd > sampleSound.sampleEnd && !wavetableMode;
|
||||
loopingHasEnd = isLooping && sampleSound.loopingHasEnd->get() && sampleSound.loopEnd > sampleSound.sampleEnd && !wavetableMode && !isPingPong;
|
||||
loopEnd = sampleSound.loopEnd;
|
||||
|
||||
if (isPingPong)
|
||||
playbackMode = PluginParameters::BASIC; // BungeeStretcher is forward-only
|
||||
|
||||
pingPongDirection = 1.0f;
|
||||
|
||||
effectiveStart = loopingHasStart ? loopStart : sampleStart;
|
||||
effectiveEnd = loopingHasEnd ? loopEnd : sampleEnd;
|
||||
|
||||
|
|
@ -264,6 +270,9 @@ void CustomSamplerVoice::renderNextBlock(juce::AudioBuffer<float>& outputBuffer,
|
|||
|
||||
updateSpeedAndPitch(getCurrentlyPlayingNote(), pitchWheel);
|
||||
|
||||
if (isPingPong && isLooping)
|
||||
speed *= pingPongDirection;
|
||||
|
||||
bool someFXEnabled{ false };
|
||||
for (const auto& effect : effects)
|
||||
{
|
||||
|
|
@ -350,7 +359,17 @@ void CustomSamplerVoice::renderNextBlock(juce::AudioBuffer<float>& outputBuffer,
|
|||
con.speedMovedSinceRelease += 1;
|
||||
|
||||
// Handle transitions
|
||||
if (con.state == PLAYING && isLooping && con.currentPosition >= sampleEnd - crossfade) // Loop crossfade
|
||||
if (con.state == PLAYING && isLooping && isPingPong && pingPongDirection > 0 && con.currentPosition >= sampleEnd) // Ping-pong: reverse at end
|
||||
{
|
||||
pingPongDirection = -1.0f;
|
||||
speed = std::abs(speed) * -1.0f;
|
||||
}
|
||||
else if (con.state == PLAYING && isLooping && isPingPong && pingPongDirection < 0 && con.currentPosition <= sampleStart) // Ping-pong: reverse at start
|
||||
{
|
||||
pingPongDirection = 1.0f;
|
||||
speed = std::abs(speed);
|
||||
}
|
||||
else if (con.state == PLAYING && isLooping && !isPingPong && con.currentPosition >= sampleEnd - crossfade) // Loop crossfade
|
||||
{
|
||||
con.currentPosition -= (sampleEnd - sampleStart + 1) - crossfade;
|
||||
con.isCrossfadingLoop = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue