Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
C# audioaudio-unitavaloniacpp20cross-platformdawdigital-audio-workstationdspjucelinux-audiomcp-servermidimusicmusic-productionpiano-rollplugin-hostsequencersynthesizervstvst3
(fix) Play note from every place
Egor Khindikaynen9fd211fa0182
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a06e14c9..1c0d0a21 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -47,6 +47,10 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.bare R and M no longer flip them by accident while you play. The Mixer moves to **⌘⇧M**.### Fixed+- A MIDI note that is already held at the playhead now sounds when you press Play in the+ middle of it, drag the playhead onto it during playback, or loop back into it. Before,+ only the next note in the clip played. Dragging the playhead during playback also+ releases the notes that were sounding, so they no longer hang.- Sidechain and source pickers on devices (Compressor, Dynamic EQ-8, Ceiling, Shutter,Auto Filter, Auto Shift, Level, Prism, plugins with a sidechain input) and the Mixer's MIDIsource list now name tracks the same way as the arrangement — e.g. an instrument track youdiff --git a/src/native/nota.engine/src/Engine.h b/src/native/nota.engine/src/Engine.hindex 0dd35fe1..c931ce23 100644--- a/src/native/nota.engine/src/Engine.h+++ b/src/native/nota.engine/src/Engine.h@@ -1071,6 +1071,9 @@ private:std::vector<OverrideTarget> overrides_;bool wasPlaying_ = false; // poll() edge detection: stop ends latched writesbool renderWasPlaying_ = false; // audio-thread play→stop edge (flush stuck notes)+ bool seekedThisBlock_ = false; // a Seek command was drained this block (audio thread)+ bool seekedWhileRolling_ = false; // ...and it arrived while the transport was rolling+ bool chaseNotes_ = false; // this segment starts at a discontinuity: re-trigger held clip notes// session-slot recording target (M5-4). recordSessionScene_ >= 0 selects slot// mode; recordSlotPlayer_/recordSlotLen_ are read on the audio thread to timediff --git a/src/native/nota.engine/src/Engine_Render.cpp b/src/native/nota.engine/src/Engine_Render.cppindex a83cc360..c8eb789a 100644--- a/src/native/nota.engine/src/Engine_Render.cpp+++ b/src/native/nota.engine/src/Engine_Render.cpp@@ -227,7 +227,9 @@ void Engine::drainCommands() {case CommandType::SetTimeSignature: transport_.setTimeSignature(c.i0, c.i1); break;case CommandType::SetLoop: transport_.setLoop(c.i0 != 0, c.d0, c.d1); break;case CommandType::SetMetronome: transport_.setMetronome(c.i0 != 0); break;- case CommandType::Seek: transport_.seekBeats(c.d0); break;+ case CommandType::Seek:+ seekedWhileRolling_ |= transport_.isPlaying(); // a jump mid-playback, not Stop→Seek→Play+ transport_.seekBeats(c.d0); seekedThisBlock_ = true; break;case CommandType::None: break;}}@@ -311,6 +313,9 @@ int Engine::gatherInstrumentNotes(Track& t, MidiEv* evs, int n, int32_t frames,if (hasVel) vel *= std::clamp(clip.velocityEnvelope.valueAt(note.startBeat), 0.0f, 1.0f);if (clipActive && onS >= blockStart && onS < blockStart + frames && n < 1024)evs[n++] = {static_cast<int32_t>(onS - blockStart), true, note.pitch, vel};+ // Chase: a note already held at the jump point starts sounding right here.+ if (chaseNotes_ && clipActive && onS < blockStart && offS > blockStart && n < 1024)+ evs[n++] = {0, true, note.pitch, vel};if (offS >= blockStart && offS < blockStart + frames && n < 1024)evs[n++] = {static_cast<int32_t>(offS - blockStart), false, note.pitch, 0.0f};}@@ -692,14 +697,23 @@ void Engine::processBlock(float* out, int32_t numFrames) {Graph* g = liveGraph_.load(std::memory_order_acquire);- // Flush stuck instrument voices on a play→stop edge (pause/stop): otherwise a- // held note keeps ringing forever since its note-off never arrives.- if (!playing && renderWasPlaying_ && g)- for (auto& tptr : g->tracks)+ auto flushArrangementVoices = [&] {+ if (g) for (auto& tptr : g->tracks)if (tptr->instrument && !sessionActiveOf(*tptr)) {tptr->instrument->allNotesOff();for (auto& md : tptr->midiEffects) if (md) md->reset(); // flush arp held/pending}+ };+ // Flush stuck instrument voices on a play→stop edge (pause/stop), or on a seek while+ // rolling: otherwise a held note keeps ringing forever since its note-off never arrives.+ const bool seeked = seekedThisBlock_, seekedRolling = seekedWhileRolling_;+ seekedThisBlock_ = seekedWhileRolling_ = false;+ if ((!playing && renderWasPlaying_) || (playing && renderWasPlaying_ && seekedRolling))+ flushArrangementVoices();+ // Note chase: when playback starts, the playhead jumps (seek) or the loop wraps, clip+ // notes that began before the playhead but are still held get re-triggered at the+ // jump point — otherwise a note you start in the middle of stays silent.+ bool chase = playing && (!renderWasPlaying_ || seeked);renderWasPlaying_ = playing;// Split the block at loop boundaries so the loop is sample-accurate: nothing@@ -711,11 +725,8 @@ void Engine::processBlock(float* out, int32_t numFrames) {if (playing && transport_.isLooping()&& transport_.playheadSamples() >= transport_.loopEndSamples() - 0.5) {transport_.wrapToLoopStart();- if (g) for (auto& tptr : g->tracks)- if (tptr->instrument && !sessionActiveOf(*tptr)) {- tptr->instrument->allNotesOff();- for (auto& md : tptr->midiEffects) if (md) md->reset();- }+ flushArrangementVoices();+ chase = true;if (nLoopSeams < 16) loopSeams[nLoopSeams++] = done; // declick this seam below}int32_t seg = std::min(numFrames - done, kMaxBlock);@@ -724,7 +735,9 @@ void Engine::processBlock(float* out, int32_t numFrames) {if (toEnd > 0.5 && toEnd < seg) seg = std::max(1, static_cast<int32_t>(std::lround(toEnd)));}const double segStart = transport_.playheadSamples();+ chaseNotes_ = chase;if (g && sr > 0.0) mixGraph(g, out + done * 2, seg, segStart, playing, spb);+ chaseNotes_ = chase = false;if (playing) renderMetronome(out + done * 2, seg, segStart);transport_.advanceBy(seg);done += seg;diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex 51f87c2d..b8cff7f0 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -1365,6 +1365,28 @@ Console.WriteLine("-- Nota Aurora --");var b2 = new float[8192 * 2]; ae.Seek(0.0); ae.Play(); ae.RenderOffline(b2, 8192); ae.StopTransport();Check(Rms(b2, 8192) > 0.001f, $"Aurora osc2-only patch is audible (RMS {Rms(b2, 8192):F3})");}+ {+ // Note chase: a clip note already held at the playhead must sound when playback starts+ // mid-note, after a seek while rolling, and after a loop wrap into it.+ static float RmsFrom(float[] b, int from, int to) { double sum = 0; for (int i = from * 2; i < to * 2; i++) sum += b[i] * (double)b[i]; return (float)Math.Sqrt(sum / Math.Max(1, (to - from) * 2)); }+ using var ce = new NotaEngine();+ ce.SetBpm(120); // 22050 samples per beat @ 44.1k+ int tc = ce.AddWavetableSynthTrack();+ ce.AddMidiClip(tc, 0.0, 8.0);+ ce.SetClipNotes(tc, 0, new[] { new NotaNote(60, 0.0, 4.0, 0.9f), new NotaNote(64, 5.0, 3.0, 0.9f) });+ var cb = new float[22050 * 2];+ ce.Seek(1.0); ce.Play(); ce.RenderOffline(cb, 22050); ce.StopTransport();+ Check(Rms(cb, 22050) > 0.001f, $"note chase: play from mid-note sounds (RMS {Rms(cb, 22050):F3})");++ ce.Seek(4.25); ce.Play(); ce.RenderOffline(cb, 11025); // gap between notes: silence+ ce.Seek(6.0); ce.RenderOffline(cb, 22050); ce.StopTransport(); // seek into note 2 while rolling+ Check(Rms(cb, 22050) > 0.001f, $"note chase: seek into a held note while playing sounds (RMS {Rms(cb, 22050):F3})");++ var lb = new float[44100 * 2];+ ce.SetLoop(true, 1.0, 2.0); ce.Seek(1.0); ce.Play(); ce.RenderOffline(lb, 44100); ce.StopTransport();+ ce.SetLoop(false, 0.0, 0.0);+ Check(RmsFrom(lb, 24000, 44100) > 0.001f, $"note chase: held note re-sounds after the loop wraps (RMS {RmsFrom(lb, 24000, 44100):F3})");+ }// v3 (almanac rework): the wheels, the output pan, LFO 2's sync and the three FX// blocks' switches and characters all exist and all act.