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
(feat) duplicate range and insert silence to range hotkeys
Egor Khindikaynen0c8013186c10
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d2d2e044..dc29e154 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -19,6 +19,12 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.## [Unreleased]### Added+- **Duplicate time (⌘⇧D) and insert silence (⌘⇧I):** select a time range in the Arrangement+ and ⌘⇧D inserts a copy of it right after itself, while ⌘⇧I opens an empty gap of the same+ length at its start. Both act on the whole song: every track's clips and automation after+ that point move right, and clips that cross it are cut. Press ⌘⇧D again to repeat the copy.+ Both are also in the Edit menu and the right-click menu of the range. Import audio no longer+ has a shortcut; use File ▸ Import audio.- **Audio clips into instruments:** drag an audio clip from the Arrangement onto the row of atrack with a Sampler, Nota Grain, Drum Rack or Instrument Rack and its audio loads there (aDrum Rack takes it on the next free pad). Pull a clip out of the Arrangement and it becomes adiff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.csindex bb906d4d..28835c85 100644--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs@@ -1087,8 +1087,14 @@ public sealed partial class ArrangementView{var consolidate = new MenuItem { Header = "Consolidate selection", Icon = MenuKit.Icon(GlyphKind.Consolidate), InputGesture = MenuKit.ConsolidateKey };consolidate.Click += (_, _) => _o.ConsolidateSelection();+ var dupTime = new MenuItem { Header = "Duplicate time", Icon = MenuKit.Icon(GlyphKind.Duplicate), InputGesture = MenuKit.DuplicateTimeKey };+ dupTime.Click += (_, _) => _o.DuplicateTimeInsert();+ var silence = new MenuItem { Header = "Insert silence", Icon = MenuKit.Icon(GlyphKind.Plus), InputGesture = MenuKit.InsertSilenceKey };+ silence.Click += (_, _) => _o.InsertSilenceAtTimeSelection();flyout.Items.Add(new Separator());flyout.Items.Add(consolidate);+ flyout.Items.Add(dupTime);+ flyout.Items.Add(silence);}flyout.ShowAt(this, showAtPointer: true);}diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.csindex e6d9abf9..c18fd1fe 100644--- a/src/managed/Nota.App/ArrangementView.cs+++ b/src/managed/Nota.App/ArrangementView.cs@@ -1418,6 +1418,30 @@ public sealed partial class ArrangementView : UserControlreturn true;}+ /// <summary>⌘⇧D Duplicate Time: insert a copy of the time selection right after it, pushing+ /// everything later right on every track (clips and automation), then move the selection+ /// onto the copy so repeated presses chain.</summary>+ public bool DuplicateTimeInsert()+ {+ if (_engine is null || !HasTimeSelection) return false;+ double len = _timeSelEnd - _timeSelStart;+ if (!_engine.InsertTime(_timeSelEnd, len, duplicate: true)) return false;+ _timeSelStart = _timeSelEnd;+ _timeSelEnd = _timeSelStart + len;+ Refresh();+ return true;+ }++ /// <summary>⌘⇧I Insert Silence: open an empty gap the length of the time selection at its+ /// start, pushing everything after it right on every track. The selection stays on the gap.</summary>+ public bool InsertSilenceAtTimeSelection()+ {+ if (_engine is null || !HasTimeSelection) return false;+ if (!_engine.InsertTime(_timeSelStart, _timeSelEnd - _timeSelStart, duplicate: false)) return false;+ Refresh();+ return true;+ }+/// <summary>Shift+click rectangular clip selection: every clip between the primary-selection/// anchor and the clicked clip, across rows and beats (req 1.1.3).</summary>internal void ShiftSelectTo(int trackId, int clipIndex)diff --git a/src/managed/Nota.App/MainWindow.Input.cs b/src/managed/Nota.App/MainWindow.Input.csindex 961dd70b..729a3ef8 100644--- a/src/managed/Nota.App/MainWindow.Input.cs+++ b/src/managed/Nota.App/MainWindow.Input.cs@@ -192,6 +192,19 @@ public partial class MainWindowreturn;}+ // ⌘⇧D / ⌃⇧D = Duplicate Time, ⌘⇧I / ⌃⇧I = Insert Silence over the arrangement time+ // selection. On macOS the Edit menu's accelerators get there first.+ if ((e.Key == Key.D || e.Key == Key.I) && !OperatingSystem.IsMacOS()+ && ArrangementView.IsPrimaryDown(e.KeyModifiers)+ && (e.KeyModifiers & KeyModifiers.Shift) != 0 && (e.KeyModifiers & KeyModifiers.Alt) == 0+ && Timeline.HasTimeSelection)+ {+ if (e.Key == Key.D) OnMenuDuplicateTime(this, EventArgs.Empty);+ else OnMenuInsertSilence(this, EventArgs.Empty);+ e.Handled = true;+ return;+ }+// ⌘/⌃ + C/X/V = copy/cut/paste the selected arrangement clip. Skipped while the// piano-roll grid is focused (it copies/pastes notes) and when nothing is// actionable, so the event falls through to other handlers.diff --git a/src/managed/Nota.App/MainWindow.Menu.cs b/src/managed/Nota.App/MainWindow.Menu.csindex 880a0c33..7d23da49 100644--- a/src/managed/Nota.App/MainWindow.Menu.cs+++ b/src/managed/Nota.App/MainWindow.Menu.cs@@ -95,6 +95,23 @@ public partial class MainWindowelse _vm.StatusText = "Select a clip first.";}+ // ⌘⇧D Duplicate Time / ⌘⇧I Insert Silence: whole-arrangement time ops on the time selection.+ private void OnMenuDuplicateTime(object? sender, EventArgs e)+ {+ if (_vm is null) return;+ if (!Timeline.HasTimeSelection) { _vm.StatusText = "Select a time range first."; return; }+ if (Timeline.DuplicateTimeInsert()) { _session?.Refresh(); _vm.StatusText = "Duplicated time"; }+ else _vm.StatusText = "Nothing to duplicate in the selected range.";+ }++ private void OnMenuInsertSilence(object? sender, EventArgs e)+ {+ if (_vm is null) return;+ if (!Timeline.HasTimeSelection) { _vm.StatusText = "Select a time range first."; return; }+ if (Timeline.InsertSilenceAtTimeSelection()) { _session?.Refresh(); _vm.StatusText = "Inserted silence"; }+ else _vm.StatusText = "Nothing after the selection to move.";+ }+private void OnMenuSplit(object? sender, EventArgs e){if (_vm is null) return;diff --git a/src/managed/Nota.App/MainWindow.axaml b/src/managed/Nota.App/MainWindow.axamlindex 2f45062e..d74aa65f 100644--- a/src/managed/Nota.App/MainWindow.axaml+++ b/src/managed/Nota.App/MainWindow.axaml@@ -27,7 +27,7 @@<NativeMenuItem Header="Save As…" Click="OnMenuSaveAs" Gesture="Shift+Cmd+S"/><NativeMenuItem Header="Save Version with Note…" Click="OnMenuSaveVersion" Gesture="Alt+Cmd+S"/><NativeMenuItemSeparator/>- <NativeMenuItem Header="Import audio…" Click="OnMenuImport" Gesture="Shift+Cmd+I"/>+ <NativeMenuItem Header="Import audio…" Click="OnMenuImport"/><NativeMenuItem Header="Export audio…" Click="OnMenuExport" Gesture="Shift+Cmd+E"/><NativeMenuItemSeparator/><NativeMenuItem Header="Settings…" Click="OnPreferences" Gesture="Ctrl+,"/>@@ -44,6 +44,8 @@<NativeMenuItem Header="Insert scene" Click="OnMenuInsertScene" Gesture="Cmd+I"/><NativeMenuItem Header="Split at playhead" Click="OnMenuSplit" Gesture="Cmd+E"/><NativeMenuItem Header="Consolidate" Click="OnMenuConsolidate" Gesture="Cmd+J"/>+ <NativeMenuItem Header="Duplicate time" Click="OnMenuDuplicateTime" Gesture="Shift+Cmd+D"/>+ <NativeMenuItem Header="Insert silence" Click="OnMenuInsertSilence" Gesture="Shift+Cmd+I"/><NativeMenuItemSeparator/><NativeMenuItem Header="Lock Envelopes" Click="OnToggleLockEnvelopes" ToggleType="CheckBox"/><NativeMenuItemSeparator/>diff --git a/src/managed/Nota.App/MenuKit.cs b/src/managed/Nota.App/MenuKit.csindex 9ce884f1..41f20737 100644--- a/src/managed/Nota.App/MenuKit.cs+++ b/src/managed/Nota.App/MenuKit.cs@@ -29,6 +29,9 @@ internal static class MenuKitpublic static readonly KeyGesture CopyToOtherViewKey = Cmd(Key.C, shift: true);public static readonly KeyGesture SplitKey = Cmd(Key.E);public static readonly KeyGesture ConsolidateKey = Cmd(Key.J);+ // Arrangement time selection: Duplicate Time · Insert Silence.+ public static readonly KeyGesture DuplicateTimeKey = Cmd(Key.D, shift: true);+ public static readonly KeyGesture InsertSilenceKey = Cmd(Key.I, shift: true);public static readonly KeyGesture LoopKey = Cmd(Key.L);public static readonly KeyGesture GroupKey = Cmd(Key.G);public static readonly KeyGesture UngroupKey = Cmd(Key.G, shift: true);diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.csindex 7cc529f9..e7def246 100644--- a/src/managed/Nota.App/PreferencesWindow.cs+++ b/src/managed/Nota.App/PreferencesWindow.cs@@ -950,7 +950,7 @@ public sealed partial class PreferencesWindow : NotaWindow("⌘N ⌘O", "New project / open a project"),("⌘S ⌘⇧S", "Save (records a version) / save as"),("⌥⌘S", "Save a version with a note"),- ("⌘⇧I ⌘⇧E", "Import audio / export audio"),+ ("⌘⇧E", "Export audio"),}),("TRANSPORT", new[]{@@ -973,6 +973,8 @@ public sealed partial class PreferencesWindow : NotaWindow("⌘⇧C", "Copy the selected clips to Session · the first scene row where they fit"),("⌘⇧V", "Paste the last range as audio rendered through its devices"),("⌘D", "Duplicate the selected clip(s) / range"),+ ("⌘⇧D", "Duplicate time · insert a copy of the time range after it, pushing everything later right"),+ ("⌘⇧I", "Insert silence · push everything from the range start right by its length"),("⌘E", "Split at the playhead · at the range edges"),("⌘J", "Consolidate the selection into one clip per track"),("0", "Deactivate / activate the selected clip(s)"),diff --git a/src/managed/Nota.Application/Engine/IAudioEngine.cs b/src/managed/Nota.Application/Engine/IAudioEngine.csindex e1d93b8a..76272a82 100644--- a/src/managed/Nota.Application/Engine/IAudioEngine.cs+++ b/src/managed/Nota.Application/Engine/IAudioEngine.cs@@ -236,6 +236,12 @@ public interface IAudioEngine : IDisposable/// <summary>Duplicates the [start,end) slice of the given tracks to [end, end+len), splitting/// at the edges. Returns the range length (>0), or 0 when nothing was duplicated.</summary>double DuplicateRange(int[] trackIds, double start, double end);+ /// <summary>Opens a <paramref name="len"/>-beat gap at <paramref name="at"/> across the whole+ /// arrangement (every track and the master): clips crossing it are cut, clips and automation+ /// at or after it move right. <paramref name="duplicate"/> false = Insert Silence; true =+ /// Duplicate Time, which fills the gap with a copy of [at-len, at). One undo step.+ /// False = nothing moved.</summary>+ bool InsertTime(double at, double len, bool duplicate);/// <summary>Splits the given tracks' clips at both [start] and [end] (keeping all content) so/// the covered slice becomes its own clip(s). One undo step, no ripple. False = nothing changed.</summary>bool SplitClipsInRange(int[] trackIds, double start, double end);diff --git a/src/managed/Nota.Infrastructure/Interop/NativeMethods.Tracks.cs b/src/managed/Nota.Infrastructure/Interop/NativeMethods.Tracks.csindex 7469c772..71c9c699 100644--- a/src/managed/Nota.Infrastructure/Interop/NativeMethods.Tracks.cs+++ b/src/managed/Nota.Infrastructure/Interop/NativeMethods.Tracks.cs@@ -213,6 +213,9 @@ internal static partial class NativeMethods[LibraryImport(Lib, EntryPoint = "nota_clips_duplicate_range")]internal static partial double ClipsDuplicateRange(IntPtr engine, [In] int[] trackIds, int n, double start, double end);+ [LibraryImport(Lib, EntryPoint = "nota_arrangement_insert_time")]+ internal static partial NotaResult ArrangementInsertTime(IntPtr engine, double at, double len, int duplicate);+[LibraryImport(Lib, EntryPoint = "nota_clips_split_range")]internal static partial NotaResult ClipsSplitRange(IntPtr engine, [In] int[] trackIds, int n, double start, double end);diff --git a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.csindex cee25f27..c7976ad9 100644--- a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs+++ b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs@@ -266,6 +266,12 @@ public sealed partial class NotaEnginepublic double DuplicateRange(int[] trackIds, double start, double end){ ThrowIfDisposed(); double r = NativeMethods.ClipsDuplicateRange(_handle, trackIds, trackIds.Length, start, end); return r > 0 ? r : 0; }+ /// <summary>Insert Silence / Duplicate Time: opens a len-beat gap at `at` across every track+ /// and the master (clips and automation after it move right); duplicate fills it with a copy+ /// of [at-len, at). One undo step. False when nothing moved.</summary>+ public bool InsertTime(double at, double len, bool duplicate)+ { ThrowIfDisposed(); return NativeMethods.ArrangementInsertTime(_handle, at, len, duplicate ? 1 : 0) == NativeMethods.NotaResult.Ok; }+/// <summary>Splits the given tracks' clips at both [start] and [end], keeping all content, so/// the covered slice becomes its own clip(s). One undo step, no ripple. False on no-op.</summary>public bool SplitClipsInRange(int[] trackIds, double start, double end)diff --git a/src/native/nota.engine/include/nota/nota_engine.h b/src/native/nota.engine/include/nota/nota_engine.hindex 8f849fcb..3dbfb1d2 100644--- a/src/native/nota.engine/include/nota/nota_engine.h+++ b/src/native/nota.engine/include/nota/nota_engine.h@@ -977,6 +977,11 @@ NOTA_API NotaResult nota_clip_delete(NotaEngine* engine, int32_t track_id, int32* [end, end+(end-start)) and returns the range length (>0), or -1 on no-op. */NOTA_API NotaResult nota_clips_delete_range(NotaEngine* engine, const int32_t* track_ids, int32_t n, double start, double end);NOTA_API double nota_clips_duplicate_range(NotaEngine* engine, const int32_t* track_ids, int32_t n, double start, double end);+/* insert_time opens a `len`-beat gap at `at` across the whole arrangement (all tracks and the+ * master): clips crossing `at` are cut, clips and automation at or after it move right.+ * duplicate=0 is Insert Silence; duplicate=1 is Duplicate Time — the gap gets a copy of+ * [at-len, at). One undo step; an error when nothing moved. */+NOTA_API NotaResult nota_arrangement_insert_time(NotaEngine* engine, double at, double len, int32_t duplicate);/* split_range cuts each listed track's clips at both boundaries, keeping all content, so the* covered slice becomes its own clip(s). One undo step, no ripple. */NOTA_API NotaResult nota_clips_split_range(NotaEngine* engine, const int32_t* track_ids, int32_t n, double start, double end);diff --git a/src/native/nota.engine/src/Engine.h b/src/native/nota.engine/src/Engine.hindex a18fad45..2f00c7ed 100644--- a/src/native/nota.engine/src/Engine.h+++ b/src/native/nota.engine/src/Engine.h@@ -466,6 +466,12 @@ public:// copies that slice to [end, end+(end-start)) and returns the range length (>0), or -1.bool deleteClipsInRange(const std::vector<int32_t>& trackIds, double start, double end);double duplicateRange(const std::vector<int32_t>& trackIds, double start, double end);+ // insertTime opens a `len`-beat gap at `at` across the whole arrangement (every track and+ // the master): clips crossing `at` are cut, everything at or after it — clips and+ // automation — moves right. Insert Silence leaves the gap empty (automation holds its value+ // at `at`); duplicate=true (Duplicate Time) fills it with a copy of [at-len, at). One undo+ // step. False when nothing moved.+ bool insertTime(double at, double len, bool duplicate);// splitClipsAtRange cuts every listed track's clips at both `start` and `end` (keeping// all content) so the covered slice becomes its own clip(s). One undo step; no ripple.bool splitClipsAtRange(const std::vector<int32_t>& trackIds, double start, double end);diff --git a/src/native/nota.engine/src/Engine_Tracks.cpp b/src/native/nota.engine/src/Engine_Tracks.cppindex 67f6e4ab..b3a4bd38 100644--- a/src/native/nota.engine/src/Engine_Tracks.cpp+++ b/src/native/nota.engine/src/Engine_Tracks.cpp@@ -1509,6 +1509,128 @@ double Engine::duplicateRange(const std::vector<int32_t>& trackIds, double startreturn len;}+// --- insert time (Insert Silence ⌘⇧I / Duplicate Time ⌘⇧D) ----------------------+namespace {+// The lane's curve over [a,b] re-based so `a` is 0: the value at each edge plus every point+// strictly inside (a partial first segment keeps its curvature).+std::vector<AutomationPoint> laneSlice(const AutomationLane& lane, double a, double b) {+ constexpr double eps = 1e-9;+ std::vector<AutomationPoint> out;+ float c0 = 0.0f;+ for (const auto& q : lane.points) { if (q.beat > a + eps) break; c0 = q.curve; }+ out.push_back({0.0, lane.valueAt(a), c0});+ for (const auto& q : lane.points)+ if (q.beat > a + eps && q.beat < b - eps) out.push_back({q.beat - a, q.value, q.curve});+ out.push_back({b - a, lane.valueAt(b), 0.0f});+ return out;+}++// Opens a `len`-beat gap at `at`: points at or after `at` move right. With `fill` (a+// laneSlice `len` long) the gap plays that curve; without, it holds the lane's value at `at`.+// False when the lane didn't change.+bool laneInsertGap(AutomationLane& lane, double at, double len, const std::vector<AutomationPoint>* fill) {+ if (lane.points.empty()) return false;+ constexpr double eps = 1e-9;+ const float v = lane.valueAt(at);+ auto& p = lane.points;+ const auto mid = std::find_if(p.begin(), p.end(), [&](const AutomationPoint& q) { return q.beat >= at - eps; });+ const bool before = mid != p.begin(), after = mid != p.end();+ if (!fill && !after) return false;+ std::vector<AutomationPoint> out;+ out.reserve(p.size() + (fill ? fill->size() + 1 : 2));+ out.insert(out.end(), p.begin(), mid);+ if (fill) {+ out.push_back({at, v, 0.0f}); // a step from the left side into the copy+ for (auto q : *fill) { q.beat += at; out.push_back(q); }+ } else if (before) {+ out.push_back({at, v, 0.0f});+ out.push_back({at + len, v, 0.0f});+ }+ for (auto it = mid; it != p.end(); ++it) { auto q = *it; q.beat += len; out.push_back(q); }+ p.swap(out);+ return true;+}+} // namespace++bool Engine::insertTime(double at, double len, bool duplicate) {+ at = std::max(0.0, at);+ if (len <= 1e-9) return false;+ const double src = at - len; // Duplicate Time copies [src, at) into the gap+ if (duplicate && src < -1e-9) return false;+ const double spb = transport_.samplesPerBeat(), devSR = transport_.sampleRate();+ constexpr double eps = 1e-6;++ auto shiftLane = [&](AutomationLane& lane) {+ if (!duplicate) return laneInsertGap(lane, at, len, nullptr);+ if (lane.points.empty() || lane.points.back().beat < src - eps) return laneInsertGap(lane, at, len, nullptr);+ const auto fill = laneSlice(lane, src, at);+ return laneInsertGap(lane, at, len, &fill);+ };+ // A clone of `t` with the gap opened (and filled), or null when nothing in it moved.+ auto shiftTrack = [&](const Track& t) -> std::shared_ptr<Track> {+ auto nt = cloneTrack(t);+ bool changed = false;+ if (nt->type() == TrackType::Instrument) {+ std::vector<MidiClip> out;+ out.reserve(nt->midiClips.size() + 2);+ std::vector<MidiClip> copies;+ for (const auto& c : nt->midiClips) {+ const double cs = c.startBeat, ce = cs + c.lengthBeats;+ if (duplicate && ce > src + eps && cs < at - eps)+ { auto s = midiSlice(c, src, at); s.startBeat += len; copies.push_back(std::move(s)); }+ if (ce <= at + eps) { out.push_back(c); continue; }+ if (cs < at - eps) { // crosses the insert point: cut it there+ out.push_back(midiSlice(c, cs, at));+ auto r = midiSlice(c, at, ce); r.startBeat += len; out.push_back(std::move(r));+ } else { auto m = c; m.startBeat += len; out.push_back(std::move(m)); }+ changed = true;+ }+ changed |= !copies.empty();+ for (auto& c : copies) out.push_back(std::move(c));+ nt->midiClips.swap(out);+ } else if (nt->type() == TrackType::Audio) {+ std::vector<AudioClip> out;+ out.reserve(nt->clips.size() + 2);+ std::vector<AudioClip> copies;+ for (const auto& c : nt->clips) {+ const double cs = c.startBeat, ce = cs + audioDisplayLenBeats(c, spb, devSR);+ if (duplicate && ce > src + eps && cs < at - eps)+ { auto s = audioSlice(c, src, at, spb, devSR); s.startBeat += len; copies.push_back(std::move(s)); }+ if (ce <= at + eps) { out.push_back(c); continue; }+ if (cs < at - eps) {+ out.push_back(audioSlice(c, cs, at, spb, devSR));+ auto r = audioSlice(c, at, ce, spb, devSR); r.startBeat += len; out.push_back(std::move(r));+ } else { auto m = c; m.startBeat += len; out.push_back(std::move(m)); }+ changed = true;+ }+ changed |= !copies.empty();+ for (auto& c : copies) out.push_back(std::move(c));+ nt->clips.swap(out);+ }+ for (auto& lane : nt->automation) changed |= shiftLane(lane);+ return changed ? nt : nullptr;+ };++ bool any = false;+ auto g = std::make_shared<Graph>();+ g->sceneCount = authoring_->sceneCount;+ g->scenes = authoring_->scenes;+ g->masterVolume = authoring_->masterVolume;+ g->masterTrack = authoring_->masterTrack;+ any |= shiftLane(g->masterVolume);+ if (g->masterTrack)+ if (auto nm = shiftTrack(*g->masterTrack)) { g->masterTrack = nm; any = true; }+ g->tracks.reserve(authoring_->tracks.size());+ for (auto& t : authoring_->tracks) {+ if (auto nt = shiftTrack(*t)) { g->tracks.push_back(nt); any = true; }+ else g->tracks.push_back(t);+ }+ if (!any) return false;+ pushUndo();+ publishRaw(std::move(g));+ return true;+}+// --- consolidate (⌘J): one clip per track over a range ------------------------namespace {// One source clip's audible slice [a,b) of a consolidate range (timeline beats), with thediff --git a/src/native/nota.engine/src/nota_engine_track.cpp b/src/native/nota.engine/src/nota_engine_track.cppindex d1d79574..c6994e08 100644--- a/src/native/nota.engine/src/nota_engine_track.cpp+++ b/src/native/nota.engine/src/nota_engine_track.cpp@@ -480,6 +480,10 @@ double nota_clips_duplicate_range(NotaEngine* e, const int32_t* track_ids, int32std::vector<int32_t> ids; if (track_ids && n > 0) ids.assign(track_ids, track_ids + n);return ENG(e)->duplicateRange(ids, start, end);}+NotaResult nota_arrangement_insert_time(NotaEngine* e, double at, double len, int32_t duplicate) {+ if (!e) return NOTA_ERR_INVALID_ARG;+ return ENG(e)->insertTime(at, len, duplicate != 0) ? NOTA_OK : NOTA_ERR_INVALID_ARG;+}NotaResult nota_clips_split_range(NotaEngine* e, const int32_t* track_ids, int32_t n, double start, double end) {if (!e) return NOTA_ERR_INVALID_ARG;std::vector<int32_t> ids; if (track_ids && n > 0) ids.assign(track_ids, track_ids + n);diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex 40b680eb..9a110ad6 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -12027,6 +12027,75 @@ Console.WriteLine("-- consolidate --");}}+// ============ insert time (⌘⇧I Insert Silence / ⌘⇧D Duplicate Time) ========+Console.WriteLine("-- insert time --");+{+ const double eps = 1e-6;+ static Nota.Application.NotaNote N(int p, double s, double l) => new(p, s, l, 0.8f);+ static Nota.Application.AutomationPoint P(double b, float v) => new(b, v);++ // Insert Silence: a clip crossing the point is cut, later clips and automation (all+ // tracks, master included) move right; the gap holds the lane's value. One undo step.+ {+ using var e = new NotaEngine();+ e.SetBpm(120);+ int a = e.AddInstrumentTrack();+ int b = e.AddInstrumentTrack();+ int ca = e.AddMidiClip(a, 0.0, 8.0);+ e.SetClipNotes(a, ca, new[] { N(60, 1, 1), N(62, 5, 1) });+ e.AddMidiClip(b, 8.0, 4.0);+ int lane = e.AddAutomationLane(b, AutomationTarget.Volume, -1, -1);+ e.SetAutomationPoints(b, lane, new[] { P(0, 0.2f), P(8, 1.0f) });+ e.SetMasterVolumeAutomation(new[] { P(0, 0.5f), P(8, 1.0f) });+ Check(e.InsertTime(4.0, 2.0, duplicate: false), "insert silence returns true");+ Check(e.TryGetTrackInfo(FindTrackIndex(e, a), out var ta) && ta.ClipCount == 2, "silence: crossing clip cut in two");+ var clipsA = Enumerable.Range(0, 2).Select(i => { e.TryGetClipInfo(a, i, out var ci); return (ci, i); }).OrderBy(x => x.ci.StartBeat).ToArray();+ Check(Math.Abs(clipsA[0].ci.LengthBeats - 4.0) < eps && Math.Abs(clipsA[1].ci.StartBeat - 6.0) < eps,+ "silence: left half stays at [0,4), right half moved to 6");+ var right = e.GetClipNotes(a, clipsA[1].i);+ Check(right.Length == 1 && right[0].Pitch == 62 && Math.Abs(right[0].StartBeat - 1.0) < eps, "silence: right half keeps its note");+ Check(e.TryGetClipInfo(b, 0, out var cb) && Math.Abs(cb.StartBeat - 10.0) < eps, "silence: other track's clip moved 8 -> 10");+ var pts = e.GetAutomationPoints(b, lane);+ Check(pts.Length == 4 && Math.Abs(pts[1].Beat - 4) < eps && Math.Abs(pts[2].Beat - 6) < eps && Math.Abs(pts[1].Value - pts[2].Value) < 1e-5+ && Math.Abs(pts[3].Beat - 10) < eps, "silence: automation holds over the gap and shifts after it");+ var mv = e.GetMasterVolumeAutomation();+ Check(mv.Length > 0 && Math.Abs(mv[^1].Beat - 10) < eps, "silence: master volume automation shifted");+ Check(e.Undo() && e.TryGetTrackInfo(FindTrackIndex(e, a), out var tu) && tu.ClipCount == 1+ && e.TryGetClipInfo(b, 0, out var cbu) && Math.Abs(cbu.StartBeat - 8.0) < eps, "silence: one undo restores everything");+ Check(!e.InsertTime(20.0, 2.0, duplicate: false), "silence past the end is a no-op");+ }++ // Duplicate Time: the range [2,4) is copied into a new gap at 4; content after 4 moves+ // right by 2, and the automation curve is copied into the gap.+ {+ using var e = new NotaEngine();+ int a = e.AddInstrumentTrack();+ int ca = e.AddMidiClip(a, 0.0, 6.0);+ e.SetClipNotes(a, ca, new[] { N(60, 2.5, 0.5), N(64, 4.5, 0.5) });+ int lane = e.AddAutomationLane(a, AutomationTarget.Volume, -1, -1);+ e.SetAutomationPoints(a, lane, new[] { P(2, 0.0f), P(4, 1.0f) });+ Check(e.InsertTime(4.0, 2.0, duplicate: true), "duplicate time returns true");+ var dupNotes = Enumerable.Range(0, e.TryGetTrackInfo(FindTrackIndex(e, a), out var ti) ? ti.ClipCount : 0)+ .SelectMany(i => { e.TryGetClipInfo(a, i, out var ci); return e.GetClipNotes(a, i).Select(n => (n.Pitch, at: ci.StartBeat + n.StartBeat)); })+ .OrderBy(n => n.at).ToArray();+ Check(dupNotes.Length == 3 && dupNotes[0].Pitch == 60 && Math.Abs(dupNotes[1].at - 4.5) < eps && dupNotes[1].Pitch == 60+ && dupNotes[2].Pitch == 64 && Math.Abs(dupNotes[2].at - 6.5) < eps, "duplicate: copy at 4.5, later note pushed to 6.5");+ var pts = e.GetAutomationPoints(a, lane);+ float At(double beat)+ {+ if (beat <= pts[0].Beat) return pts[0].Value;+ for (int i = 1; i < pts.Length; i++)+ if (beat <= pts[i].Beat)+ return pts[i].Beat - pts[i - 1].Beat <= 0 ? pts[i].Value+ : (float)(pts[i - 1].Value + (pts[i].Value - pts[i - 1].Value) * (beat - pts[i - 1].Beat) / (pts[i].Beat - pts[i - 1].Beat));+ return pts[^1].Value;+ }+ Check(Math.Abs(At(3.0) - 0.5f) < 1e-4 && Math.Abs(At(5.0) - 0.5f) < 1e-4 && Math.Abs(At(7.0) - 1.0f) < 1e-4,+ "duplicate: automation ramp copied into the gap, the rest holds");+ Check(!e.InsertTime(1.0, 2.0, duplicate: true), "duplicate with a range before 0 is rejected");+ }+}+// ============ track/clip names + colour + track clipboard ==================Console.WriteLine("-- names, colour, track clipboard --");{