0.40.0 (75): Sampler One-shot (Android and iOS)

- Sampler parameter oneShot (Off/On): note-offs don't release its pads; they
  play their whole slice. Transport stop/pause still releases (SampleVoice::
  release), panic kills
- Engine in core/ and the Kotlin reference both implement it; the golden
  Sampler "high" scenario covers it; oneshot_test checks MIDI, song, stop, panic
- ONE-SHOT toggle in both apps' Sampler editors; specs and layouts regenerated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-16 16:53:13 +01:00
co-authored by Claude Opus 5.5
parent 5240019b47
commit 7041f762e5
17 changed files with 182 additions and 16 deletions
+10
View File
@@ -5,6 +5,16 @@ version in `versions.properties`; versions before 0.28.0 are described in the gi
log (one commit per version). Since 0.37.0 Android and iOS share one version and log (one commit per version). Since 0.37.0 Android and iOS share one version and
one feature set; the iOS side of each version is in `ios/CHANGELOG.md`. one feature set; the iOS side of each version is in `ios/CHANGELOG.md`.
## 0.40.0 (versionCode 75)
- **Sampler One-shot:** a ONE-SHOT toggle at the top of the Sampler editor. On,
note-offs are ignored: releasing a MIDI key or pad, the tracker's `===` and a
new note on the same track no longer cut a pad, which plays its whole slice
(the bus's eight voices overlap). Stopping or pausing the song still fades the
pads it played, and MIDI PANIC silences everything. It's a Sampler setting, so
it's saved with the song and in presets, and the Sampler plugin offers it as a
parameter. (iOS has the same in 0.40.0.)
## 0.39.1 (versionCode 74) ## 0.39.1 (versionCode 74)
- Sampler, SF2/XI, Grain Cloud and Wavetable preset bundles now travel between - Sampler, SF2/XI, Grain Cloud and Wavetable preset bundles now travel between
@@ -86,6 +86,7 @@ class SampleVoice(private val engineSampleRate: Int) {
attack: Float = 0.002f, decay: Float = 0f, sustain: Float = 1f, release: Float = 0.02f, attack: Float = 0.002f, decay: Float = 0f, sustain: Float = 1f, release: Float = 0.02f,
loop: Boolean = false, crossfadeMs: Float = 0f, loop: Boolean = false, crossfadeMs: Float = 0f,
) { ) {
oneShot = false // the caller sets it again for a One-shot Sampler
// Carry the level we're interrupting so the new note starts continuously // Carry the level we're interrupting so the new note starts continuously
// (the new note fades in from ~0; without this the sum would jump from the // (the new note fades in from ~0; without this the sum would jump from the
// old voice's level straight to ~0 → a click when stealing a loud voice). // old voice's level straight to ~0 → a click when stealing a loud voice).
@@ -139,8 +140,15 @@ class SampleVoice(private val engineSampleRate: Int) {
endGain = 1f endGain = 1f
} }
/** Playing a One-shot Sampler pad: [noteOff] leaves it be (it plays to its slice
* end); [release] still fades it. Reset by [noteOn]. */
var oneShot = false
/** A note-off: the release stage, unless the voice is one-shot. */
fun noteOff() { if (!oneShot) release() }
/** Enter the release stage: fade from the current level to 0 over the release time. */ /** Enter the release stage: fade from the current level to 0 over the release time. */
fun noteOff() { fun release() {
val sr = engineSampleRate.toFloat() val sr = engineSampleRate.toFloat()
releaseInc = if (releaseSeconds <= 0f) 1f else env / (releaseSeconds * sr) releaseInc = if (releaseSeconds <= 0f) 1f else env / (releaseSeconds * sr)
if (releaseInc <= 0f) releaseInc = 1f if (releaseInc <= 0f) releaseInc = 1f
@@ -94,6 +94,10 @@ enum class ToolboxType(
ToolboxKind.INSTRUMENT, "Sampler", ToolboxKind.INSTRUMENT, "Sampler",
listOf( listOf(
ParamSpec("volume", "Volume", 0.8f, 0f, 1f), ParamSpec("volume", "Volume", 0.8f, 0f, 1f),
// On: note-offs (MIDI, the tracker's ===, a new note on the track) are
// ignored and every pad plays its whole slice. Stop / pause / panic still
// silence it. Played by the C++ engine (core/), not the Kotlin reference.
ParamSpec("oneShot", "One-shot", choices = listOf("Off", "On")),
// A 16-pad bank: each pad maps to a consecutive note from C2 (see // A 16-pad bank: each pad maps to a consecutive note from C2 (see
// [SamplerPads]) and stores its own sample id + slice as string params // [SamplerPads]) and stores its own sample id + slice as string params
// ("pad0", "pad0S", "pad0E", …). Edited by ui/toolbox/SamplerEditor. // ("pad0", "pad0S", "pad0E", …). Edited by ui/toolbox/SamplerEditor.
@@ -102,6 +102,24 @@ fun SamplerEditor(vm: AppViewModel, slot: ToolboxSlot, pad: Int, onSelectPad: (I
} }
Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) { Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) {
// ----- One-shot (the whole Sampler): note-offs don't cut the pads -----
val oneShot = slot.string("oneShot", "Off") == "On"
Row(
Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
RetroButton("ONE-SHOT", active = oneShot) {
slot.set("oneShot", if (oneShot) "Off" else "On")
vm.bumpForToolbar()
}
Text(
if (oneShot) "Pads play their whole slice; note-offs are ignored."
else "Pads stop on note-off (key release, ===).",
color = c.textDim, fontFamily = FontFamily.Monospace, fontSize = 11.sp,
)
}
// ----- Selected pad + source buttons (act on the selected pad) ----- // ----- Selected pad + source buttons (act on the selected pad) -----
Text( Text(
"Pad ${pad + 1} · ${Pitch.name(SamplerPads.noteFor(pad))}", "Pad ${pad + 1} · ${Pitch.name(SamplerPads.noteFor(pad))}",
@@ -166,6 +166,7 @@ class IosGoldenInstruments {
val s = SampleStore.get(slot.string(SamplerPads.key(pad))) ?: return val s = SampleStore.get(slot.string(SamplerPads.key(pad))) ?: return
v.noteOn(s, note, velocity, note, slot.float(SamplerPads.sliceStartKey(pad), 0f), v.noteOn(s, note, velocity, note, slot.float(SamplerPads.sliceStartKey(pad), 0f),
slot.float(SamplerPads.sliceEndKey(pad), 1f), slot.float(SamplerPads.volumeKey(pad), SamplerPads.DEFAULT_VOLUME)) slot.float(SamplerPads.sliceEndKey(pad), 1f), slot.float(SamplerPads.volumeKey(pad), SamplerPads.DEFAULT_VOLUME))
v.oneShot = slot.string("oneShot", "Off") == "On"
} else { } else {
val s = SampleStore.get(slot.string("sfSample")) ?: return val s = SampleStore.get(slot.string("sfSample")) ?: return
v.noteOn(s, note, velocity, slot.float("sfRoot", 60f).toInt(), 0f, 1f, slot.float("volume", 0.8f), v.noteOn(s, note, velocity, slot.float("sfRoot", 60f).toInt(), 0f, 1f, slot.float("volume", 0.8f),
@@ -1056,9 +1056,11 @@ class ReferenceEngine(
val vs = voiceSample(slot, note) val vs = voiceSample(slot, note)
when { when {
vs != null -> vs != null ->
allocSampleVoice(bus).also { it.ownerTrack = ownerTrack }.noteOn( allocSampleVoice(bus).also { it.ownerTrack = ownerTrack }.apply {
vs.sample, note, velocity, vs.root, vs.sliceStart, vs.sliceEnd, vs.volume, noteOn(vs.sample, note, velocity, vs.root, vs.sliceStart, vs.sliceEnd, vs.volume,
vs.attack, vs.decay, vs.sustain, vs.release, vs.loop, vs.crossfadeMs) vs.attack, vs.decay, vs.sustain, vs.release, vs.loop, vs.crossfadeMs)
oneShot = vs.oneShot
}
// Empty bus (no instrument — e.g. the default channel 0) or a Sampler // Empty bus (no instrument — e.g. the default channel 0) or a Sampler
// with an empty pad → silent, matching the live audition path. // with an empty pad → silent, matching the live audition path.
slot?.type == null || slot.type == ToolboxType.SAMPLER -> {} slot?.type == null || slot.type == ToolboxType.SAMPLER -> {}
@@ -1079,6 +1081,7 @@ class ReferenceEngine(
val attack: Float = 0.002f, val decay: Float = 0f, val attack: Float = 0.002f, val decay: Float = 0f,
val sustain: Float = 1f, val release: Float = 0.02f, val sustain: Float = 1f, val release: Float = 0.02f,
val loop: Boolean = false, val crossfadeMs: Float = 0f, val loop: Boolean = false, val crossfadeMs: Float = 0f,
val oneShot: Boolean = false,
) )
/** /**
@@ -1101,6 +1104,7 @@ class ReferenceEngine(
slot.float(SamplerPads.sliceStartKey(pad), 0f), slot.float(SamplerPads.sliceStartKey(pad), 0f),
slot.float(SamplerPads.sliceEndKey(pad), 1f), slot.float(SamplerPads.sliceEndKey(pad), 1f),
slot.float(SamplerPads.volumeKey(pad), SamplerPads.DEFAULT_VOLUME), slot.float(SamplerPads.volumeKey(pad), SamplerPads.DEFAULT_VOLUME),
oneShot = slot.string("oneShot", "Off") == "On",
) )
} }
} }
@@ -1282,6 +1286,7 @@ class ReferenceEngine(
val v = auditionSampleVoices.firstOrNull { !it.isActive } ?: auditionSampleVoices[0].also { it.kill() } val v = auditionSampleVoices.firstOrNull { !it.isActive } ?: auditionSampleVoices[0].also { it.kill() }
v.noteOn(vs.sample, midi, 110, vs.root, vs.sliceStart, vs.sliceEnd, vs.volume, v.noteOn(vs.sample, midi, 110, vs.root, vs.sliceStart, vs.sliceEnd, vs.volume,
vs.attack, vs.decay, vs.sustain, vs.release, vs.loop, vs.crossfadeMs) vs.attack, vs.decay, vs.sustain, vs.release, vs.loop, vs.crossfadeMs)
v.oneShot = vs.oneShot
return return
} }
// A Sampler with an empty pad stays silent (audition is a one-shot with no // A Sampler with an empty pad stays silent (audition is a one-shot with no
@@ -1337,6 +1342,7 @@ class ReferenceEngine(
val v = freeBusVoice(busSampleVoices, base) val v = freeBusVoice(busSampleVoices, base)
v.noteOn(vs.sample, midi, velocity, vs.root, vs.sliceStart, vs.sliceEnd, vs.volume, v.noteOn(vs.sample, midi, velocity, vs.root, vs.sliceStart, vs.sliceEnd, vs.volume,
vs.attack, vs.decay, vs.sustain, vs.release, vs.loop, vs.crossfadeMs) vs.attack, vs.decay, vs.sustain, vs.release, vs.loop, vs.crossfadeMs)
v.oneShot = vs.oneShot
} }
// Sampler with an empty pad → silent (no synth fallback). // Sampler with an empty pad → silent (no synth fallback).
type == ToolboxType.SAMPLER -> {} type == ToolboxType.SAMPLER -> {}
@@ -1559,7 +1565,7 @@ class ReferenceEngine(
private fun allSeqVoicesOff() { private fun allSeqVoicesOff() {
clouds.forEach { it.releaseSequenced() } clouds.forEach { it.releaseSequenced() }
seqVoices.forEach { it.noteOff() } seqVoices.forEach { it.noteOff() }
sampleVoices.forEach { it.noteOff() } sampleVoices.forEach { it.release() } // a stopped song stops One-shot pads too
arps.forEach { it.stop() } arps.forEach { it.stop() }
allMidiNotesOff() // release any notes we sent to external gear allMidiNotesOff() // release any notes we sent to external gear
} }
Binary file not shown.
+3 -1
View File
@@ -64,8 +64,10 @@ inline const ParamSpec NES_SYNTH_params[] = {
{"m3amt", "Mod4 Amt", 0.0f, -1.0f, 1.0f, false, nullptr}, {"m3amt", "Mod4 Amt", 0.0f, -1.0f, 1.0f, false, nullptr},
}; };
inline const char *const SAMPLER_c1[] = {"Off", "On", nullptr};
inline const ParamSpec SAMPLER_params[] = { inline const ParamSpec SAMPLER_params[] = {
{"volume", "Volume", 0.8f, 0.0f, 1.0f, false, nullptr}, {"volume", "Volume", 0.8f, 0.0f, 1.0f, false, nullptr},
{"oneShot", "One-shot", 0.0f, 0.0f, 1.0f, false, SAMPLER_c1},
}; };
inline const char *const SOUNDFONT_c6[] = {"Off", "On", nullptr}; inline const char *const SOUNDFONT_c6[] = {"Off", "On", nullptr};
@@ -309,7 +311,7 @@ inline const ParamSpec GRANULAR_params[] = {
inline const DeviceSpec devices[] = { inline const DeviceSpec devices[] = {
{"NES_SYNTH", "Synth", Kind::Instrument, NES_SYNTH_params, 43}, {"NES_SYNTH", "Synth", Kind::Instrument, NES_SYNTH_params, 43},
{"SAMPLER", "Sampler", Kind::Instrument, SAMPLER_params, 1}, {"SAMPLER", "Sampler", Kind::Instrument, SAMPLER_params, 2},
{"SOUNDFONT", "SF2 / XI Loader", Kind::Instrument, SOUNDFONT_params, 8}, {"SOUNDFONT", "SF2 / XI Loader", Kind::Instrument, SOUNDFONT_params, 8},
{"MORPH_PAD", "Morph Pad", Kind::Instrument, MORPH_PAD_params, 36}, {"MORPH_PAD", "Morph Pad", Kind::Instrument, MORPH_PAD_params, 36},
{"GRAIN_CLOUD", "Grain Cloud", Kind::Instrument, GRAIN_CLOUD_params, 24}, {"GRAIN_CLOUD", "Grain Cloud", Kind::Instrument, GRAIN_CLOUD_params, 24},
+4 -1
View File
@@ -855,6 +855,7 @@ void Engine::Impl::playNote(Project &proj, int bus, int note, int velocity, int
v.ownerTrack = ownerTrack; v.ownerTrack = ownerTrack;
v.noteOn(*vs.sample, note, velocity, vs.root, vs.sliceStart, vs.sliceEnd, vs.volume, v.noteOn(*vs.sample, note, velocity, vs.root, vs.sliceStart, vs.sliceEnd, vs.volume,
vs.attack, vs.decay, vs.sustain, vs.release, vs.loop, vs.crossfadeMs); vs.attack, vs.decay, vs.sustain, vs.release, vs.loop, vs.crossfadeMs);
v.oneShot = vs.oneShot;
} else if (!hasType(slot) || is(slot, "SAMPLER")) { } else if (!hasType(slot) || is(slot, "SAMPLER")) {
// Empty bus or a Sampler with an empty pad: silent. // Empty bus or a Sampler with an empty pad: silent.
} else if (is(slot, "GRAIN_CLOUD")) { } else if (is(slot, "GRAIN_CLOUD")) {
@@ -926,6 +927,7 @@ void Engine::Impl::auditionSlotOn(int slotIndex, int midi) {
if (!v) { v = auditionSampleVoices[0].get(); v->kill(); } if (!v) { v = auditionSampleVoices[0].get(); v->kill(); }
v->noteOn(*vs.sample, midi, 110, vs.root, vs.sliceStart, vs.sliceEnd, vs.volume, v->noteOn(*vs.sample, midi, 110, vs.root, vs.sliceStart, vs.sliceEnd, vs.volume,
vs.attack, vs.decay, vs.sustain, vs.release, vs.loop, vs.crossfadeMs); vs.attack, vs.decay, vs.sustain, vs.release, vs.loop, vs.crossfadeMs);
v->oneShot = vs.oneShot;
return; return;
} }
if (is(slot, "SAMPLER")) return; if (is(slot, "SAMPLER")) return;
@@ -972,6 +974,7 @@ void Engine::Impl::busNoteOn(int midiChannel, int midi, int velocity) {
if (!v) { v = busSampleVoices[base].get(); v->kill(); } if (!v) { v = busSampleVoices[base].get(); v->kill(); }
v->noteOn(*vs.sample, midi, velocity, vs.root, vs.sliceStart, vs.sliceEnd, vs.volume, v->noteOn(*vs.sample, midi, velocity, vs.root, vs.sliceStart, vs.sliceEnd, vs.volume,
vs.attack, vs.decay, vs.sustain, vs.release, vs.loop, vs.crossfadeMs); vs.attack, vs.decay, vs.sustain, vs.release, vs.loop, vs.crossfadeMs);
v->oneShot = vs.oneShot;
} else if (is(slot, "SAMPLER")) { } else if (is(slot, "SAMPLER")) {
} else if (is(slot, "GRAIN_CLOUD")) { } else if (is(slot, "GRAIN_CLOUD")) {
clouds[ch]->noteOn(midi, velocity, GrainCloud::OWNER_LIVE); clouds[ch]->noteOn(midi, velocity, GrainCloud::OWNER_LIVE);
@@ -1146,7 +1149,7 @@ void Engine::Impl::refreshSynthPatches(Project &proj) {
void Engine::Impl::allSeqVoicesOff() { void Engine::Impl::allSeqVoicesOff() {
for (auto &c : clouds) c->releaseSequenced(); for (auto &c : clouds) c->releaseSequenced();
for (auto &v : seqVoices) v->noteOff(); for (auto &v : seqVoices) v->noteOff();
for (auto &v : sampleVoices) v->noteOff(); for (auto &v : sampleVoices) v->release(); // a stopped song stops One-shot pads too
for (auto &a : arps) a.stop(); for (auto &a : arps) a.stop();
allMidiNotesOff(); allMidiNotesOff();
} }
+3 -1
View File
@@ -50,6 +50,7 @@ bool voiceSample(const char *type, const Params &slot, const SampleStore &store,
out.sliceStart = slot.f(SamplerPads::sliceStartKey(pad).s, 0.f); out.sliceStart = slot.f(SamplerPads::sliceStartKey(pad).s, 0.f);
out.sliceEnd = slot.f(SamplerPads::sliceEndKey(pad).s, 1.f); out.sliceEnd = slot.f(SamplerPads::sliceEndKey(pad).s, 1.f);
out.volume = slot.f(SamplerPads::volumeKey(pad).s, SamplerPads::DEFAULT_VOLUME); out.volume = slot.f(SamplerPads::volumeKey(pad).s, SamplerPads::DEFAULT_VOLUME);
out.oneShot = std::strcmp(slot.s("oneShot", "Off"), "On") == 0;
return true; return true;
} }
if (std::strcmp(type, "SOUNDFONT") == 0) { if (std::strcmp(type, "SOUNDFONT") == 0) {
@@ -93,6 +94,7 @@ void SampleVoice::noteOn(const Sample &s, int midi, int velocity, int root,
const int len = (int)s.data.size(); const int len = (int)s.data.size();
// An empty sample would make Kotlin's coerceIn(startIndex + 1, 0) throw; play nothing. // An empty sample would make Kotlin's coerceIn(startIndex + 1, 0) throw; play nothing.
if (len <= 0) return; if (len <= 0) return;
oneShot = false; // the caller sets it again for a One-shot Sampler
// Carry the level we're interrupting so the new note starts continuously. // Carry the level we're interrupting so the new note starts continuously.
declick += lastY; declick += lastY;
setSample(&s); setSample(&s);
@@ -142,7 +144,7 @@ void SampleVoice::noteOn(const Sample &s, int midi, int velocity, int root,
endGain = 1.f; endGain = 1.f;
} }
void SampleVoice::noteOff() { void SampleVoice::release() {
const float sr = (float)engineSampleRate; const float sr = (float)engineSampleRate;
releaseInc = releaseSeconds <= 0.f ? 1.f : env / (releaseSeconds * sr); releaseInc = releaseSeconds <= 0.f ? 1.f : env / (releaseSeconds * sr);
if (releaseInc <= 0.f) releaseInc = 1.f; if (releaseInc <= 0.f) releaseInc = 1.f;
+14 -4
View File
@@ -54,6 +54,8 @@ struct VoiceSample {
float sustain = 1.f, release = 0.02f; float sustain = 1.f, release = 0.02f;
bool loop = false; bool loop = false;
float crossfadeMs = 0.f; float crossfadeMs = 0.f;
/** A Sampler with One-shot on: note-offs don't release the voice. */
bool oneShot = false;
}; };
/** /**
@@ -83,6 +85,9 @@ public:
int pitch = -1; int pitch = -1;
/** Which tracker (lane,track) started this voice, or -1 if unowned. */ /** Which tracker (lane,track) started this voice, or -1 if unowned. */
int ownerTrack = -1; int ownerTrack = -1;
/** Playing a One-shot Sampler pad: noteOff() leaves it be, it plays to its slice
* end; release() (transport stop / pause) still fades it. Reset by noteOn. */
bool oneShot = false;
bool isActive() const { return sample != nullptr; } bool isActive() const { return sample != nullptr; }
/** Note is still held (not in its release stage). */ /** Note is still held (not in its release stage). */
@@ -98,11 +103,16 @@ public:
float attack = 0.002f, float decay = 0.f, float sustain = 1.f, float release = 0.02f, float attack = 0.002f, float decay = 0.f, float sustain = 1.f, float release = 0.02f,
bool loop = false, float crossfadeMs = 0.f); bool loop = false, float crossfadeMs = 0.f);
void noteOn(const VoiceSample &v, int midi, int velocity) { void noteOn(const VoiceSample &v, int midi, int velocity) {
if (v.sample) noteOn(*v.sample, midi, velocity, v.root, v.sliceStart, v.sliceEnd, v.volume, if (!v.sample) return;
v.attack, v.decay, v.sustain, v.release, v.loop, v.crossfadeMs); noteOn(*v.sample, midi, velocity, v.root, v.sliceStart, v.sliceEnd, v.volume,
v.attack, v.decay, v.sustain, v.release, v.loop, v.crossfadeMs);
oneShot = v.oneShot;
} }
/** Enter the release stage: fade from the current level to 0 over the release time. */ /** A note-off: enter the release stage (fade from the current level to 0 over
void noteOff(); * the release time), unless the voice is one-shot. */
void noteOff() { if (!oneShot) release(); }
/** Enter the release stage whatever the note (transport stop / pause). */
void release();
void kill(); void kill();
float render(); float render();
+79
View File
@@ -0,0 +1,79 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
// The Sampler's One-shot: a note-off (MIDI or the tracker) doesn't stop the pad,
// it plays its whole slice; with One-shot off it fades out; stopping the song
// stops it either way.
#include "sampler/SampleStore.hpp"
#include "sizzle/Engine.hpp"
#include "sizzle/Model.hpp"
#include <cmath>
#include <cstdio>
#include <vector>
using namespace sizzle;
static int failures = 0;
#define CHECK(c) do { if (!(c)) { std::printf("FAIL %s:%d %s\n", __FILE__, __LINE__, #c); ++failures; } } while (0)
constexpr int SR = 48000;
/// Peak of [frames] rendered frames.
static float peak(engine::Engine &e, int frames) {
std::vector<float> buf(192 * 2);
float p = 0;
for (int done = 0; done < frames; done += 192) {
e.fillBlock(buf.data(), 192);
for (float v : buf) p = std::max(p, std::fabs(v));
}
return p;
}
enum class Way { Midi, MidiThenPanic, Song, SongThenStop };
/// Pad 0 (C2, MIDI 36) holds a one-second tone; channel 1 plays the Sampler. The
/// pad starts and gets its note-off 125 ms later, from MIDI or from the song (a
/// note on line 0, "===" on line 1 at 120 BPM); returns the peak at 300..400 ms.
static float afterNoteOff(const char *oneShot, Way way) {
sampler::SampleStore store;
std::vector<float> tone(SR);
for (int i = 0; i < SR; ++i) tone[(size_t)i] = 0.5f * std::sin(i * 0.05f);
store.put("tone", Sample(std::move(tone), SR));
model::Project p;
p.toolbox[0].fill("SAMPLER");
p.toolbox[0].set("pad0", "tone");
p.toolbox[0].set("oneShot", oneShot);
p.mixer.channels[0].instrumentSlot = 0;
p.mixer.channels[0].midiChannel = 1;
p.patterns[0].tracks[0][0] = model::Cell{36, 127, 1};
p.patterns[0].tracks[0][1] = model::Cell{model::Cell::OFF, 127, 1};
engine::Engine e(SR, &store);
e.setProject(&p);
e.rebuildArrangement();
e.rebuildFxChains();
const bool song = way == Way::Song || way == Way::SongThenStop;
if (song) e.play(); else e.busNoteOn(1, 36, 127);
peak(e, SR / 8);
if (!song) e.busNoteOff(1, 36);
peak(e, SR / 16); // the song's "===" lands meanwhile
if (way == Way::SongThenStop) e.stop();
if (way == Way::MidiThenPanic) e.panic();
peak(e, SR / 8); // past any release
return peak(e, SR / 10); // ~300..400 ms: still inside the one-second tone
}
int main() {
const float midiOn = afterNoteOff("On", Way::Midi), midiOff = afterNoteOff("Off", Way::Midi);
const float songOn = afterNoteOff("On", Way::Song), songOff = afterNoteOff("Off", Way::Song);
const float stopped = afterNoteOff("On", Way::SongThenStop), panicked = afterNoteOff("On", Way::MidiThenPanic);
std::printf(" after a MIDI note-off: one-shot %.3f, normal %.3f\n", midiOn, midiOff);
std::printf(" after the song's ===: one-shot %.3f, normal %.3f\n", songOn, songOff);
std::printf(" one-shot after Stop %.3f, after panic %.3f\n", stopped, panicked);
CHECK(midiOn > 0.05f && songOn > 0.05f);
CHECK(midiOff < 1e-4f && songOff < 1e-4f);
CHECK(stopped < 1e-4f && panicked < 1e-4f);
std::printf(failures ? "oneshot_test: %d failure(s)\n" : "oneshot_test: ok\n", failures);
return failures ? 1 : 0;
}
+8
View File
@@ -5,6 +5,14 @@ Sizzle for iOS/iPadOS (`cc.tiredsysadmin.ios.sizzle`). One entry per version in
is shared with Android, continuing Android's numbering, and both apps ship the is shared with Android, continuing Android's numbering, and both apps ship the
same features; the Android side of each version is in `../CHANGELOG.md`. same features; the Android side of each version is in `../CHANGELOG.md`.
## 0.40.0 (build 75)
- Sampler One-shot: a ONE-SHOT toggle above the pad tools (also in the Sampler's
card and as the plugin's "One-shot" parameter). On, note-offs (key release,
`===`, the next note on the track) don't cut a pad; it plays its whole slice.
Stop / pause still fade the song's pads; MIDI PANIC silences everything.
(Android has the same in 0.40.0.)
## 0.39.1 (build 74) ## 0.39.1 (build 74)
- Fix: a Sampler preset shared from Android (a .zip with the preset and its - Fix: a Sampler preset shared from Android (a .zip with the preset and its
+6 -1
View File
@@ -90,6 +90,10 @@ build/core/bundle_test: $(CORE_SRC) $(CORE_HDR) ../core/tests/bundle_test.cpp
mkdir -p build/core mkdir -p build/core
$(CXX) $(CXXFLAGS) -o $@ $(CORE_SRC) ../core/tests/bundle_test.cpp $(CXX) $(CXXFLAGS) -o $@ $(CORE_SRC) ../core/tests/bundle_test.cpp
build/core/oneshot_test: $(CORE_SRC) $(CORE_HDR) ../core/tests/oneshot_test.cpp
mkdir -p build/core
$(CXX) $(CXXFLAGS) -o $@ $(CORE_SRC) ../core/tests/oneshot_test.cpp
build/core/midi_test: ../core/include/sizzle/Midi.hpp ../core/tests/midi_test.cpp build/core/midi_test: ../core/include/sizzle/Midi.hpp ../core/tests/midi_test.cpp
mkdir -p build/core mkdir -p build/core
$(CXX) $(CXXFLAGS) -o $@ ../core/tests/midi_test.cpp $(CXX) $(CXXFLAGS) -o $@ ../core/tests/midi_test.cpp
@@ -106,7 +110,7 @@ zip-test: build/core/zip_test
build/core/zip_test build/core/java.zip build/core/ours.zip build/core/zip_test build/core/java.zip build/core/ours.zip
unzip -tq build/core/ours.zip unzip -tq build/core/ours.zip
core-test: build/core/golden_test build/core/sampler_test build/core/engine_test build/core/io_test build/core/midi_test build/core/host_test build/core/midimap_test build/core/bundle_test zip-test core-test: build/core/golden_test build/core/sampler_test build/core/engine_test build/core/io_test build/core/midi_test build/core/host_test build/core/midimap_test build/core/bundle_test build/core/oneshot_test zip-test
@test -f $(GOLDEN)/input.f32 || $(MAKE) --no-print-directory golden @test -f $(GOLDEN)/input.f32 || $(MAKE) --no-print-directory golden
build/core/golden_test $(GOLDEN) $(TYPES) build/core/golden_test $(GOLDEN) $(TYPES)
build/core/sampler_test build/core/sampler_test
@@ -115,6 +119,7 @@ core-test: build/core/golden_test build/core/sampler_test build/core/engine_test
build/core/midi_test build/core/midi_test
build/core/host_test $(GOLDEN)/songs build/core/host_test $(GOLDEN)/songs
build/core/midimap_test ../app/src/test/resources/midimap/filter.szm build/core/midimap_test ../app/src/test/resources/midimap/filter.szm
build/core/oneshot_test
build/core/bundle_test $(GOLDEN)/bundles/android_sampler.zip ../app/src/test/resources/presetbundle/ios_sampler.zip build/core/bundle_test $(GOLDEN)/bundles/android_sampler.zip ../app/src/test/resources/presetbundle/ios_sampler.zip
# ------------------------------------------------------------------ app # ------------------------------------------------------------------ app
+1 -1
View File
@@ -6,7 +6,7 @@
], ],
"SAMPLER": [ "SAMPLER": [
{"title": "Sampler", "panels": [ {"title": "Sampler", "panels": [
{"title": "Sampler", "tone": "SOURCE", "keys": ["volume"]}]} {"title": "Sampler", "tone": "SOURCE", "keys": ["volume", "oneShot"]}]}
], ],
"SOUNDFONT": [ "SOUNDFONT": [
{"title": "SF2 / XI Loader", "panels": [ {"title": "SF2 / XI Loader", "panels": [
@@ -24,7 +24,17 @@ struct SamplerDetail: View {
var body: some View { var body: some View {
let session = SizzleSession.shared let session = SizzleSession.shared
let assigned = !session.value(ofSlot: slot, key: "pad\(pad)").isEmpty let assigned = !session.value(ofSlot: slot, key: "pad\(pad)").isEmpty
let oneShot = session.value(ofSlot: slot, key: "oneShot") == "On"
VStack(alignment: .leading, spacing: 8) { VStack(alignment: .leading, spacing: 8) {
// One-shot (the whole Sampler): note-offs don't cut the pads.
HStack(spacing: 8) {
MixKit.Button(label: "ONE-SHOT", active: oneShot) {
session.setValue(oneShot ? "Off" : "On", ofSlot: slot, key: "oneShot")
}
Text(oneShot ? "Pads play their whole slice; note-offs are ignored."
: "Pads stop on note-off (key release, ===).")
.font(Theme.mono(11)).foregroundColor(Theme.dim).lineLimit(2)
}
Text("Pad \(pad + 1) · \(MixKit.pitchName(SamplerPads.note(pad)))").font(Theme.mono(13)).foregroundColor(Theme.accent) Text("Pad \(pad + 1) · \(MixKit.pitchName(SamplerPads.note(pad)))").font(Theme.mono(13)).foregroundColor(Theme.accent)
MixKit.HScroll { MixKit.HScroll {
HStack(spacing: 8) { HStack(spacing: 8) {
+2 -2
View File
@@ -12,8 +12,8 @@
# or polish. versionCode is monotonic and bumps by 1 on every release, # or polish. versionCode is monotonic and bumps by 1 on every release,
# because F-Droid and the Android package manager order installs by it alone. # because F-Droid and the Android package manager order installs by it alone.
versionName = 0.39.1 versionName = 0.40.0
versionCode = 74 versionCode = 75
# Namespace for every platform: cc.tiredsysadmin.<os>.sizzle. Android: # Namespace for every platform: cc.tiredsysadmin.<os>.sizzle. Android:
# cc.tiredsysadmin.android.sizzle (app/), iOS/iPadOS: cc.tiredsysadmin.ios.sizzle # cc.tiredsysadmin.android.sizzle (app/), iOS/iPadOS: cc.tiredsysadmin.ios.sizzle