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) Release 0.59.1 review: pedal lead-in, retry keeps track edits, copied comps flatten
Egor Khindikaynen9efea761b9ad
diff --git a/src/managed/Nota.App/PianoRollView.Controllers.cs b/src/managed/Nota.App/PianoRollView.Controllers.csindex 901a46f3..1da63173 100644--- a/src/managed/Nota.App/PianoRollView.Controllers.cs+++ b/src/managed/Nota.App/PianoRollView.Controllers.cs@@ -267,7 +267,7 @@ public sealed partial class PianoRollViewif (IsSwitch && outp.Count > 0 && outp[^1].Value == p.Value) continue;outp.Add(p);}- return outp;+ return IsSwitch ? ControllerStroke.SwitchLeadIn(outp) : outp;}// ---- switch blocks ----diff --git a/src/managed/Nota.Application/Editing/ControllerStroke.cs b/src/managed/Nota.Application/Editing/ControllerStroke.csindex 50aa6eae..778dadda 100644--- a/src/managed/Nota.Application/Editing/ControllerStroke.cs+++ b/src/managed/Nota.Application/Editing/ControllerStroke.cs@@ -41,6 +41,17 @@ public static class ControllerStrokereturn (float)(a.Value + (b.Value - a.Value) * Shape((beat - a.Beat) / span, a.Curve));}+ /// <summary>A switch lane (sustain, sostenuto…) as the engine will play it: the engine+ /// holds the first point's value back to the clip start, while the lane shows the pedal up+ /// until its first block. When the first point is down and later than the start, an up+ /// point at beat 0 makes playback match.</summary>+ public static List<AutomationPoint> SwitchLeadIn(List<AutomationPoint> p)+ {+ if (p.Count > 0 && p[0].Value >= 0.5f && p[0].Beat > 1e-9)+ p.Insert(0, new AutomationPoint(0, 0f));+ return p;+ }+/// <summary>The curve after drawing <paramref name="samples"/> over <paramref name="orig"/>./// Samples are in clip-local beats. With nothing after the stroke, the drawn value holds.</summary>public static List<AutomationPoint> Apply(diff --git a/src/native/nota.engine/src/engine/Engine_TakeRetry.cpp b/src/native/nota.engine/src/engine/Engine_TakeRetry.cppindex 4e41223e..e95c0106 100644--- a/src/native/nota.engine/src/engine/Engine_TakeRetry.cpp+++ b/src/native/nota.engine/src/engine/Engine_TakeRetry.cpp@@ -103,11 +103,19 @@ void Engine::discardTake() {if (b.first == id) return b.second;return nullptr;};+ // An Arrangement take restores only what recording writes — the clips, the loop passes and+ // the automation lanes — so a rename, a fader move or a device added meanwhile stays.auto restoreTrack = [&](const std::shared_ptr<Track>& cur) -> std::shared_ptr<Track> {auto base = cur ? baseOf(cur->id()) : nullptr;- if (!base) return cur;- if (!a.session || cur->id() != a.sessionTrackId) return base;+ if (!base || cur == base) return cur;auto nt = cloneTrack(*cur);+ if (!a.session || cur->id() != a.sessionTrackId) {+ nt->clips = base->clips;+ nt->takes = base->takes;+ nt->midiClips = base->midiClips;+ nt->automation = base->automation;+ return nt;+ }const int32_t sc = a.sessionScene;if (sc < 0) return nt;if (static_cast<int32_t>(nt->sessionSlots.size()) <= sc) nt->sessionSlots.resize(sc + 1);@@ -151,11 +159,15 @@ void Engine::discardTake() {}// A checkpoint the take made before part of it was kept (wasTake) may now step between two// identical states — its content was the part just discarded: an Undo that changes nothing.- // Drop those (track-only edits, so comparing the tracks is enough).- auto sameTracks = [](const Graph& x, const Graph& y) {- if (x.masterTrack != y.masterTrack || x.tracks.size() != y.tracks.size()) return false;+ // Drop those (track-only edits, so comparing the tracks is enough). Such a step holds only+ // the take's writes, so on a track the retry restored both sides count as the same.+ auto sameTrack = [&](const std::shared_ptr<Track>& x, const std::shared_ptr<Track>& y) {+ return x == y || (x && y && x->id() == y->id() && baseOf(x->id()));+ };+ auto sameTracks = [&](const Graph& x, const Graph& y) {+ if (!sameTrack(x.masterTrack, y.masterTrack) || x.tracks.size() != y.tracks.size()) return false;for (size_t k = 0; k < x.tracks.size(); ++k)- if (x.tracks[k] != y.tracks[k]) return false;+ if (!sameTrack(x.tracks[k], y.tracks[k])) return false;return true;};std::shared_ptr<Graph> next = authoring_;diff --git a/src/native/nota.engine/src/engine/Engine_Tracks.cpp b/src/native/nota.engine/src/engine/Engine_Tracks.cppindex 51ddb0c9..4156ed7c 100644--- a/src/native/nota.engine/src/engine/Engine_Tracks.cpp+++ b/src/native/nota.engine/src/engine/Engine_Tracks.cpp@@ -2552,13 +2552,15 @@ bool Engine::duplicateSectionWithContent(int32_t index) {g->masterVolume = authoring_->masterVolume;laneDuplicate(g->masterVolume, a, b);// Take lanes: later ones move with the song; one starting in the section gets a copy (a new- // id and number) under the copied section, and the copied comp clips point at it so the+ // id, number and recording group) under the copied section, and the copied comp clips point at it so the// copy can be comped on its own (specs/067).auto takeStart = [](const AudioTake& k) { return k.originBeat + k.sourceOffsetFrames * k.beatsPerFrame; };for (auto& t : g->tracks) {if (t->takes.empty()) continue;auto nt = cloneTrack(*t);std::map<int32_t, int32_t> copied; // old take id -> its copy's+ std::map<int32_t, int32_t> groups; // old recording group -> its copy's: Flatten reads a+ // group's origin from its first takeint32_t number = 0;for (const auto& k : nt->takes) number = std::max(number, k.number);std::vector<AudioTake> copies;@@ -2570,6 +2572,9 @@ bool Engine::duplicateSectionWithContent(int32_t index) {c.id = ++nextTakeId_;c.number = ++number;c.originBeat += len;+ auto [git, fresh] = groups.try_emplace(k.group, 0);+ if (fresh) git->second = ++nextTakeGroup_;+ c.group = git->second;copied[k.id] = c.id;copies.push_back(std::move(c));}diff --git a/tests/Nota.SmokeTest/ControllerStrokeTests.cs b/tests/Nota.SmokeTest/ControllerStrokeTests.csindex c5c32e16..85fdbe9f 100644--- a/tests/Nota.SmokeTest/ControllerStrokeTests.cs+++ b/tests/Nota.SmokeTest/ControllerStrokeTests.cs@@ -91,5 +91,21 @@ internal static class ControllerStrokeTestsfloat at3 = Oracle(early, 3);yield return (Math.Abs(at3 - 1f) < 1e-3f,$"drawing before the first point leaves the later value (read {at3:0.00} at beat 3)");++ // A sustain block drawn over beats 2–3 of an empty lane must not hold the pedal from+ // beat 0: the engine reads the first point's value back to the clip start.+ var block = ControllerStroke.SwitchLeadIn(new List<AutomationPoint> { new(2, 1f), new(3, 0f) });+ // A switch steps: it holds the earlier point's value (ControllerCurve::valueAt).+ static float Step(IReadOnlyList<AutomationPoint> p, double beat)+ {+ if (p.Count == 0) return 0;+ float v = p[0].Value;+ foreach (var q in p) if (q.Beat <= beat) v = q.Value;+ return v;+ }+ yield return (Step(block, 0) < 0.5f && Step(block, 1.9) < 0.5f && Step(block, 2.5) >= 0.5f && Step(block, 3.5) < 0.5f,+ "a switch block plays only where it is drawn");+ var atStart = ControllerStroke.SwitchLeadIn(new List<AutomationPoint> { new(0, 1f), new(3, 0f) });+ yield return (atStart.Count == 2, "a block from the clip start needs no lead-in point");}}diff --git a/tests/Nota.SmokeTest/RetryTakeTests.cs b/tests/Nota.SmokeTest/RetryTakeTests.csindex 4d448ad1..a7104eda 100644--- a/tests/Nota.SmokeTest/RetryTakeTests.cs+++ b/tests/Nota.SmokeTest/RetryTakeTests.cs@@ -33,6 +33,7 @@ internal static class RetryTakeTestsforeach (var r in SessionCountIn()) yield return r;foreach (var r in AutomationOnAnotherTrack()) yield return r;foreach (var r in EditsMadeMeanwhile()) yield return r;+ foreach (var r in RecordingTrackEditedMeanwhile()) yield return r;foreach (var r in DisarmedTakeIsKept()) yield return r;foreach (var r in SessionHeldIntoRelaunch()) yield return r;foreach (var r in SessionToggleSlot()) yield return r;@@ -179,6 +180,34 @@ internal static class RetryTakeTests$"retry: an edit made meanwhile keeps its undo step, without the discarded take in it (kept {kept}, take undone {takeGone}, edit undone {editGone})");}+ // Renaming the recording track mid-take: the retry drops the recording, not the rename,+ // and the rename keeps its own undo step.+ private static IEnumerable<(bool, string)> RecordingTrackEditedMeanwhile()+ {+ using var e = Armed(out int t);+ e.SetTrackName(t, "Before");+ e.SetCountIn(0);+ e.Seek(0.0);+ Beats(e, 0.01);+ e.ClearUndoHistory();+ e.SetRecording(true);+ Beats(e, 0.5);+ Tap(e, 60, 0.5);+ e.SetTrackName(t, "Renamed"); // the user's own edit on the recording track+ e.RetryTake();+ Beats(e, 0.01);+ bool named = e.GetTrackName(t) == "Renamed";+ bool dropped = Notes(e, t).All(n => n.Note.Pitch != 60);+ e.SetRecording(false);+ e.Poll();+ e.StopTransport();+ e.Undo(); // the kept take+ e.Undo(); // the rename+ bool renameUndone = e.GetTrackName(t) == "Before" && Notes(e, t).All(n => n.Note.Pitch != 60);+ yield return (named && dropped && renameUndone,+ $"retry keeps a rename of the recording track (name kept {named}, take dropped {dropped}, rename undoes to the old name without the take {renameUndone})");+ }+// Disarming the track ends (and keeps) its take: a retry afterwards has nothing to discard.private static IEnumerable<(bool, string)> DisarmedTakeIsKept(){diff --git a/tests/Nota.SmokeTest/TakeLaneTests.cs b/tests/Nota.SmokeTest/TakeLaneTests.csindex 1acd586a..94b700b5 100644--- a/tests/Nota.SmokeTest/TakeLaneTests.cs+++ b/tests/Nota.SmokeTest/TakeLaneTests.cs@@ -32,6 +32,7 @@ internal static class TakeLaneTestsforeach (var r in MoveToTrackFadesExposedEdge()) yield return r;foreach (var r in DeactivatedSideFades()) yield return r;foreach (var r in UndoKeepsJoins()) yield return r;+ foreach (var r in DuplicatedCompFlattens()) yield return r;foreach (var r in NoTakes()) yield return r;foreach (var r in SaveReopen()) yield return r;}@@ -524,6 +525,22 @@ internal static class TakeLaneTests$"moving one half of a join onto another track fades the edge that was shared ({after[30000]:G4})");}+ // Duplicating a section with its takes gives the copies their own recording group, so+ // Flatten merges the copied comp into one clip just as it does the original.+ private static IEnumerable<(bool, string)> DuplicatedCompFlattens()+ {+ using var e = Rig(out int track);+ Record(e, track, RecFrames, 1.0);+ e.SetLoop(false, 0.0, 4.0);+ e.SetSections(new[] { new SectionInfo(0, 4, "A") });+ bool dup = e.DuplicateSectionWithContent(0);+ int takes = e.TakeCount(track);+ bool flat = e.FlattenTakes(track);+ int clips = ClipCount(e, track);+ yield return (dup && takes == 6 && flat && e.TakeCount(track) == 0 && clips == 2,+ $"duplicate a section with takes, then flatten: one clip per comp ({takes} takes before, {clips} clips after)");+ }+private static IEnumerable<(bool, string)> NoTakes(){using (var e = Rig(out int track))