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) Device transfer keeps lineage on the copies that stand in for a device
Egor Khindikaynen3e0cc4a4ee46
diff --git a/src/native/nota.engine/src/engine/Engine_Devices.cpp b/src/native/nota.engine/src/engine/Engine_Devices.cppindex 030352cd..902132a4 100644--- a/src/native/nota.engine/src/engine/Engine_Devices.cpp+++ b/src/native/nota.engine/src/engine/Engine_Devices.cpp@@ -893,7 +893,10 @@ int32_t Engine::transferDevice(int32_t srcId, int32_t family, int32_t index, intstd::shared_ptr<Device> dev = keepSource ? cloneDevice(*sd) : sd;if (!dev) return -3;if (dev->sidechainSourceTrackId() == dstId) {- if (dev == sd) dev = cloneDevice(*sd);+ if (dev == sd) {+ dev = cloneDevice(*sd);+ if (dev) dev->inheritLineage(sd->lineage()); // the moved device itself, not a copy+ }if (!dev) return -3;dev->setSidechainSourceTrackId(-1);dev->setSidechainPart(0);@@ -909,6 +912,7 @@ int32_t Engine::transferDevice(int32_t srcId, int32_t family, int32_t index, intif (d < index) continue;auto c = cloneMidiDevice(*m);if (!c) continue;+ c->inheritLineage(m->lineage()); // the same Arp, retargeted (take retry finds it)if (d == index) {c->setCcDest(-1, -1);flags |= kTransferLinksDropped;@@ -928,7 +932,10 @@ int32_t Engine::transferDevice(int32_t srcId, int32_t family, int32_t index, intstd::shared_ptr<MidiDevice> md = keepSource ? cloneMidiDevice(*sm) : sm;if (!md) return -3;if (md->ccDestDevice() >= 0) { // its CC target is a device on the old track- if (md == sm) md = cloneMidiDevice(*sm);+ if (md == sm) {+ md = cloneMidiDevice(*sm);+ if (md) md->inheritLineage(sm->lineage()); // the moved device itself, not a copy+ }if (!md) return -3;md->setCcDest(-1, -1);flags |= kTransferLinksDropped;diff --git a/tests/Nota.SmokeTest/RetryTakeTests.cs b/tests/Nota.SmokeTest/RetryTakeTests.csindex fb541968..0525cfc5 100644--- a/tests/Nota.SmokeTest/RetryTakeTests.cs+++ b/tests/Nota.SmokeTest/RetryTakeTests.cs@@ -36,6 +36,7 @@ internal static class RetryTakeTestsforeach (var r in RecordingTrackEditedMeanwhile()) yield return r;foreach (var r in DeviceMovedMeanwhile()) yield return r;foreach (var r in DeviceReplacedMeanwhile()) yield return r;+ foreach (var r in EffectTransferredMeanwhile()) 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;@@ -277,6 +278,35 @@ internal static class RetryTakeTestse.StopTransport();}+ // Moving an effect to another track mid-take retargets the Arp whose CC lane points past+ // it (a copy of the same Arp): its automation stays through a retry.+ private static IEnumerable<(bool, string)> EffectTransferredMeanwhile()+ {+ const int Arp = 0, Utility = 4;+ using var e = Armed(out int t);+ int o = e.AddInstrumentTrack();+ e.AddBuiltinDevice(t, Utility);+ e.AddBuiltinDevice(t, Utility);+ int arp = e.AddMidiEffect(t, Arp);+ e.SetMidiEffectCcDest(t, arp, 1, 0); // the second Utility+ int l = e.AddAutomationLane(t, AutomationTarget.MidiDeviceParam, arp, 0);+ e.SetAutomationPoints(t, l, new[] { new AutomationPoint(0, 0.2f), new AutomationPoint(4, 0.8f) });+ e.SetCountIn(0);+ e.Seek(0.0);+ Beats(e, 0.01);+ e.SetRecording(true);+ Beats(e, 0.5);+ int moved = e.TransferDevice(t, DeviceFamily.Audio, 0, o, -1, false, out _); // the first Utility leaves+ e.RetryTake();+ Beats(e, 0.01);+ bool kept = Enumerable.Range(0, e.AutomationLaneCount(t)).Select(i => e.AutomationLaneInfo(t, i))+ .Any(i => i.Target == AutomationTarget.MidiDeviceParam && i.DeviceIndex == arp && i.PointCount == 2);+ yield return (moved >= 0 && kept,+ $"retry after moving an effect away: the retargeted Arp keeps its automation (moved {moved}, kept {kept})");+ e.SetRecording(false);+ e.StopTransport();+ }+// Disarming the track ends (and keeps) its take: a retry afterwards has nothing to discard.private static IEnumerable<(bool, string)> DisarmedTakeIsKept(){