Skip to content

armgit / nota

Public Imported from GitHub
0

Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.

Template selection in separate window

Egor Khindikaynen072fc7d92624
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a9c1732..cf25c30d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,10 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **Presets in a rack chain's GUI window.** Opening **GUI** on an instrument or effect
+ inside an Instrument Rack, Drum Rack or a Nota Rhythm voice's effects now shows a header
+ with the device's name and the same **‹ preset ▾ ›** picker as the main device cards, so
+ you can browse and switch presets right there.
- **New-version notice on the welcome screen.** When a newer Nota release is on GitHub,
the launcher shows a banner with the version number and a **Download** button that opens
the release page. Without an internet connection nothing is shown.
diff --git a/src/managed/Nota.App/DeviceCardKit.cs b/src/managed/Nota.App/DeviceCardKit.cs
index e72fb4e5..f195076a 100644
--- a/src/managed/Nota.App/DeviceCardKit.cs
+++ b/src/managed/Nota.App/DeviceCardKit.cs
@@ -8,6 +8,7 @@
// builders bring it into scope with `using static Nota.App.DeviceCardKit`.
using System;
+using System.Collections.Generic;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
@@ -319,4 +320,67 @@ internal static class DeviceCardKit
// A horizontal row of single-select chips over an integer choice (get/set).
internal static Control ChipRow(string[] options, Func<int> get, Action<int> set)
=> Segments(options, () => Math.Clamp(get(), 0, options.Length - 1), set, out _);
+
+ // Preset picker "‹ Name ▾ ›" — a sunken field (a list you pick from, not a button): the
+ // name opens the factory presets for this kind with the current one checked; ‹ › step to
+ // the previous / next preset, wrapping (from Init, › is the first and ‹ the last).
+ // Clicks are handled so they neither select nor start dragging the card. Shared by the
+ // card shell and the rack chain full-UI popups.
+ internal static Control PresetPicker(IReadOnlyList<string> presets, int cur, string current,
+ Action<int> apply, Action<int> step)
+ {
+ const double H = 18;
+ var label = new TextBlock
+ {
+ Text = string.IsNullOrEmpty(current) ? "Init" : current, FontSize = NotaType.Value + 1, FontWeight = FontWeight.Medium,
+ Foreground = TextPrimary, VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis,
+ };
+ var chevron = new Glyph(GlyphKind.ChevronDown, 8) { Foreground = TextTertiary, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(6, 0, 0, 0) };
+ DockPanel.SetDock(chevron, Dock.Right);
+ var name = new Border
+ {
+ Width = 132, Padding = new Thickness(7, 0, 6, 0), Background = Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Hand),
+ Child = new DockPanel { Children = { chevron, label } },
+ };
+ ToolTip.SetTip(name, "Choose a preset");
+ name.PointerPressed += (_, e) =>
+ {
+ if (!e.GetCurrentPoint(name).Properties.IsLeftButtonPressed) return;
+ e.Handled = true;
+ var flyout = new MenuFlyout();
+ for (int i = 0; i < presets.Count; i++)
+ {
+ int iv = i;
+ var mi = new MenuItem { Header = presets[i], ToggleType = MenuItemToggleType.Radio, IsChecked = i == cur };
+ mi.Click += (_, _) => apply(iv);
+ flyout.Items.Add(mi);
+ }
+ flyout.ShowAt(name);
+ };
+
+ Border Step(int dir)
+ {
+ var g = new Glyph(dir < 0 ? GlyphKind.ChevronLeft : GlyphKind.ChevronRight, 8)
+ { Foreground = TextTertiary, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
+ var b = new Border { Width = H, Background = Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Hand), Child = g };
+ ToolTip.SetTip(b, dir < 0 ? "Previous preset" : "Next preset");
+ b.PointerEntered += (_, _) => g.Foreground = TextPrimary;
+ b.PointerExited += (_, _) => g.Foreground = TextTertiary;
+ b.PointerPressed += (_, e) =>
+ {
+ if (!e.GetCurrentPoint(b).Properties.IsLeftButtonPressed) return;
+ e.Handled = true;
+ step(dir);
+ };
+ return b;
+ }
+ Border Rule() => new() { Width = 1, Background = NotaPalette.GraphBorder };
+
+ return new Border
+ {
+ Height = H, Background = NotaPalette.BgSunken, BorderBrush = NotaPalette.GraphBorder, BorderThickness = new Thickness(1),
+ CornerRadius = NotaRadius.Control, ClipToBounds = true, VerticalAlignment = VerticalAlignment.Center,
+ Child = new StackPanel { Orientation = Orientation.Horizontal, Children = { Step(-1), Rule(), name, Rule(), Step(+1) } },
+ };
+ }
}
diff --git a/src/managed/Nota.App/DeviceCards/DeviceCardContext.cs b/src/managed/Nota.App/DeviceCards/DeviceCardContext.cs
index e2208c5d..bea60a73 100644
--- a/src/managed/Nota.App/DeviceCards/DeviceCardContext.cs
+++ b/src/managed/Nota.App/DeviceCards/DeviceCardContext.cs
@@ -27,11 +27,15 @@ internal sealed class DeviceCardContext(
Action invokeRackParamRefreshers,
Action requestRebuild,
Action<int> requestRackPresetSave,
- Action hideDropGlow)
+ Action hideDropGlow,
+ IFactoryPresets? factory = null)
{
public IAudioEngine Engine => engine;
public int TrackId => trackId;
+ /// <summary>The shipped preset library — rack chain full-UI popups list their kind's presets from it.</summary>
+ public IFactoryPresets? Factory => factory;
+
/// <summary>Register a closure invoked on every UI tick (compressor GR meter, param
/// faders following automation, …). Kept as a plain list append — no per-frame cost.</summary>
public void AddDeviceRefresher(Action refresher) => addDeviceRefresher(refresher);
diff --git a/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs b/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs
index e6b6bba0..b5f2f12b 100644
--- a/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs
+++ b/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs
@@ -11,6 +11,8 @@
// RackCardView.Drum.cs.
using System;
+using System.Collections.Generic;
+using System.Linq;
using Avalonia;
using Avalonia.Collections;
using Avalonia.Controls;
@@ -424,9 +426,80 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
{
int ik = a.ChainInstrumentKind(sc);
if (ik == -1) { try { E.RackOpenChainInstrumentEditor(T, sc); } catch { /* no-op */ } return; }
- if (ik == 1) { OpenChainSamplerWindow(anchor, sc); return; }
+ if (ik == 1) { OpenChainSamplerWindow(anchor, sc, InstrumentPresets(a, sc, ik)); return; }
string nm = string.IsNullOrEmpty(a.ChainInstrumentName(sc)) ? "Instrument" : a.ChainInstrumentName(sc);
- OpenFullUiWindow(anchor, nm, tickReg => BuildChainInstrumentBespoke(ik, sc, tickReg));
+ OpenFullUiWindow(anchor, nm, tickReg => BuildChainInstrumentBespoke(ik, sc, tickReg), InstrumentPresets(a, sc, ik));
+ }
+
+ // ---- full-UI popup header: the device's name + its factory-preset picker ----
+
+ // A chain slot's preset list and how to apply one in place. Key names the slot (rack
+ // addressing + chain + device + kind) so the header remembers the last preset applied.
+ private sealed record ChainPresets(string Key, IReadOnlyList<(string Id, string Name)> Items, Action<string> Apply);
+ private static readonly Dictionary<string, string> _chainPresetIds = new();
+
+ private List<(string Id, string Name)> FactoryItems(int kind, bool instrument)
+ => _ctx.Factory is { } f
+ ? f.All().Where(p => p.BuiltinKind == kind && p.IsInstrument == instrument && !p.IsMidiEffect).Select(p => (p.Id, p.DisplayName)).ToList()
+ : new();
+
+ // Factory presets apply through the same proxies the bespoke editors use, so the
+ // preset code sees the chain instrument / device as if it were the track's own.
+ private ChainPresets InstrumentPresets(IRackAccess a, int sc, int ik)
+ => new($"{a.GetType().Name}:{T}:{a.AutomationDeviceIndex}:{sc}:i{ik}", FactoryItems(ik, instrument: true),
+ id => _ctx.Factory?.ApplyInPlace(ChainInstrumentProxy(sc), id, T, -1));
+ private ChainPresets DevicePresets(IRackAccess a, int sc, int d, int kind)
+ => new($"{a.GetType().Name}:{T}:{a.AutomationDeviceIndex}:{sc}:{d}:d{kind}", FactoryItems(kind, instrument: false),
+ id => _ctx.Factory?.ApplyInPlace(ChainDeviceProxy(a, sc, d, kind), id, T, d));
+
+ private IAudioEngine ChainInstrumentProxy(int sc)
+ {
+ IAudioEngine proxy = System.Reflection.DispatchProxy.Create<IAudioEngine, RackChainEngineProxy>();
+ var pp = (RackChainEngineProxy)(object)proxy; pp.Inner = E; pp.Chain = sc;
+ return proxy;
+ }
+ private IAudioEngine ChainDeviceProxy(IRackAccess a, int sc, int d, int kind)
+ {
+ IAudioEngine proxy = System.Reflection.DispatchProxy.Create<IAudioEngine, RackChainDeviceEngineProxy>();
+ var pp = (RackChainDeviceEngineProxy)(object)proxy; pp.Inner = E; pp.Access = a; pp.Chain = sc; pp.Dev = d; pp.Kind = kind;
+ return proxy;
+ }
+
+ // The card shell's header, for a popup: name on the left, preset picker on the right.
+ // Applying a preset re-fills the popup (so every control shows the new values) and
+ // nudges the rack's inline faders.
+ private Control WithPopupHeader(string title, ChainPresets presets, Control content, Action refill)
+ {
+ var name = new TextBlock
+ {
+ Text = title, FontSize = NotaType.DeviceName, FontWeight = FontWeight.SemiBold, Foreground = TextPrimary,
+ VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis,
+ };
+ var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), ColumnSpacing = 8, Children = { name } };
+ var items = presets.Items;
+ if (items.Count > 0)
+ {
+ int cur = -1;
+ if (_chainPresetIds.TryGetValue(presets.Key, out var curId))
+ for (int i = 0; i < items.Count; i++) if (items[i].Id == curId) { cur = i; break; }
+ void Apply(int i)
+ {
+ presets.Apply(items[i].Id);
+ _chainPresetIds[presets.Key] = items[i].Id;
+ _ctx.InvokeRackParamRefreshers();
+ refill();
+ }
+ void Step(int dir) { int n = items.Count; Apply(cur < 0 ? (dir > 0 ? 0 : n - 1) : ((cur + dir) % n + n) % n); }
+ var picker = PresetPicker(items.Select(p => p.Name).ToList(), cur, cur >= 0 ? items[cur].Name : "", Apply, Step);
+ Grid.SetColumn(picker, 1); grid.Children.Add(picker);
+ }
+ var header = new Border
+ {
+ Height = HeaderH, Background = NotaPalette.SurfaceCard, BorderBrush = BorderDef, BorderThickness = new Thickness(0, 0, 0, 1),
+ Padding = new Thickness(NotaSpace.DeviceInsetWide, 0), Child = grid,
+ };
+ DockPanel.SetDock(header, Dock.Top);
+ return new DockPanel { Children = { header, content } };
}
// Host a built-in instrument's own editor for a rack chain: a DispatchProxy redirects
@@ -434,12 +507,11 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
// a local tick drives its live graphs + knob follow.
private Control BuildChainInstrumentBespoke(int ik, int sc, Action<Action> tickReg)
{
- IAudioEngine proxy = System.Reflection.DispatchProxy.Create<IAudioEngine, RackChainEngineProxy>();
- var pp = (RackChainEngineProxy)(object)proxy; pp.Inner = E; pp.Chain = sc;
+ var proxy = ChainInstrumentProxy(sc);
var faders = new System.Collections.Generic.List<(int i, Knob k, TextBlock v, Func<float, string>? fmt)>();
Action? viz = null;
var ctx = new DeviceCardContext(proxy, T, tickReg, () => { }, (i, k, v, f) => faders.Add((i, k, v, f)), v => viz = v,
- _ => { }, () => 0, _ => { }, tickReg, () => { }, () => { }, _ => { }, () => { });
+ _ => { }, () => 0, _ => { }, tickReg, () => { }, () => { }, _ => { }, () => { }, _ctx.Factory);
var body = _irFactory.Resolve(ik, true).Build(ctx);
tickReg(() => { viz?.Invoke(); foreach (var f in faders) { if (f.k.Dragging) continue; float v = proxy.PluginParamGet(T, -1, f.i); if (Math.Abs(v - f.k.Value) > 1e-3) { f.k.Value = v; f.v.Text = (f.fmt ?? Pct)(v); } } });
return new Border { Width = 700, Height = DeviceCardKit.CardH - DeviceCardKit.HeaderH, Background = NotaPalette.BgApp, ClipToBounds = true, Child = body };
@@ -447,7 +519,7 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
// Sampler pop-out that also accepts a dropped sample file (browser or Finder) → load it
// into the chain's Sampler and rebuild the editor.
- private void OpenChainSamplerWindow(Control anchor, int sc)
+ private void OpenChainSamplerWindow(Control anchor, int sc, ChainPresets presets)
{
var acc = new ChainSamplerAccess(E, T, sc);
var ticks = new System.Collections.Generic.List<Action>();
@@ -461,7 +533,7 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
DragDrop.SetAllowDrop(wrap, true);
DragDrop.AddDragOverHandler(wrap, (_, e) => { if (!BrowserView.IsAcceptableDrag(e)) { e.DragEffects = DragDropEffects.None; return; } e.DragEffects = DragDropEffects.Copy; e.Handled = true; });
DragDrop.AddDropHandler(wrap, (_, e) => { foreach (var it in BrowserView.DroppedItems(e)) if (it.Kind == Nota.Presentation.BrowserItemKind.Sample) { acc.LoadSample(it.Path); Rebuild(); break; } e.Handled = true; });
- win.SetContent(wrap);
+ win.SetContent(WithPopupHeader("Nota Sampler", presets, wrap, Rebuild));
}
Rebuild();
win.Opened += (_, _) => timer.Start();
@@ -478,7 +550,7 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
int kind = a.ChainDeviceBuiltinKind(sc, d);
if (kind < 0) { a.OpenChainDeviceEditor(sc, d); return; } // hosted plug-in → native window
string nm = a.ChainDeviceName(sc, d);
- OpenFullUiWindow(anchor, nm, tickReg => BuildChainDeviceBespoke(a, sc, d, kind, tickReg)); // built-in → its real device card
+ OpenFullUiWindow(anchor, nm, tickReg => BuildChainDeviceBespoke(a, sc, d, kind, tickReg), DevicePresets(a, sc, d, kind)); // built-in → its real device card
}
// Host a built-in effect's own device card for a rack chain: a DispatchProxy redirects
@@ -486,9 +558,8 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
// effect shows its real UI (AutoFilter curve, EQ bands, …) rather than plain knobs.
private Control BuildChainDeviceBespoke(IRackAccess a, int sc, int d, int kind, Action<Action> tickReg)
{
- IAudioEngine proxy = System.Reflection.DispatchProxy.Create<IAudioEngine, RackChainDeviceEngineProxy>();
- var pp = (RackChainDeviceEngineProxy)(object)proxy; pp.Inner = E; pp.Access = a; pp.Chain = sc; pp.Dev = d;
- var ctx = new DeviceCardContext(proxy, T, tickReg, () => { }, (_, _, _, _) => { }, _ => { }, _ => { }, () => sc, _ => { }, tickReg, () => { }, () => { }, _ => { }, () => { });
+ var proxy = ChainDeviceProxy(a, sc, d, kind);
+ var ctx = new DeviceCardContext(proxy, T, tickReg, () => { }, (_, _, _, _) => { }, _ => { }, _ => { }, () => sc, _ => { }, tickReg, () => { }, () => { }, _ => { }, () => { }, _ctx.Factory);
var body = _irDeviceFactory.Resolve(kind).Build(ctx, a.AutomationDeviceIndex);
return new Border { Width = 700, Height = DeviceCardKit.CardH - DeviceCardKit.HeaderH, Background = NotaPalette.BgApp, ClipToBounds = true, Child = body };
}
@@ -1085,7 +1156,7 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
Control fullBtn;
if (ik == -1) fullBtn = ActionChip("Full", () => { try { E.RackOpenChainInstrumentEditor(T, sc); } catch { /* no-op */ } });
- else if (ik == 1) { Border b = null!; b = ActionChip("Full", () => OpenChainSamplerWindow(b, sc)); fullBtn = b; }
+ else if (ik == 1) { Border b = null!; b = ActionChip("Full", () => OpenChainSamplerWindow(b, sc, InstrumentPresets(a, sc, ik))); fullBtn = b; }
else fullBtn = FullUiChip(nm, _ => ParamGridContent(nm, a.ChainInstrumentParamCount(sc), p => RackInstParamRow(a, sc, p)));
return DeviceCardShell(nm, fullBtn, body, 180);
}
@@ -1108,24 +1179,27 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)
return chip;
}
- private void OpenFullUiWindow(Control anchor, string title, Func<Action<Action>, Control> build)
+ // With presets, the popup gets the name + preset header, and applying one rebuilds the
+ // content (fresh tick list) so the editor shows the new values.
+ private void OpenFullUiWindow(Control anchor, string title, Func<Action<Action>, Control> build, ChainPresets? presets = null)
{
- var ticks = new System.Collections.Generic.List<Action>();
- var content = build(ticks.Add);
+ var ticks = new List<Action>();
var win = new NotaPopupWindow
{
Title = title, SizeToContent = SizeToContent.WidthAndHeight, CanResize = false,
ShowInTaskbar = false, WindowStartupLocation = WindowStartupLocation.CenterOwner,
};
- win.SetContent(content);
- Avalonia.Threading.DispatcherTimer? timer = null;
- if (ticks.Count > 0)
+ void Fill()
{
- timer = new Avalonia.Threading.DispatcherTimer { Interval = TimeSpan.FromMilliseconds(33) };
- timer.Tick += (_, _) => { for (int i = 0; i < ticks.Count; i++) ticks[i](); };
+ ticks.Clear();
+ var content = build(ticks.Add);
+ win.SetContent(presets is null ? content : WithPopupHeader(title, presets, content, Fill));
}
- win.Opened += (_, _) => timer?.Start();
- win.Closed += (_, _) => timer?.Stop();
+ Fill();
+ var timer = new Avalonia.Threading.DispatcherTimer { Interval = TimeSpan.FromMilliseconds(33) };
+ timer.Tick += (_, _) => { for (int i = 0; i < ticks.Count; i++) ticks[i](); };
+ win.Opened += (_, _) => { if (ticks.Count > 0) timer.Start(); };
+ win.Closed += (_, _) => timer.Stop();
ShowPopup(win, anchor);
}
@@ -1652,6 +1726,7 @@ internal class RackChainEngineProxy : System.Reflection.DispatchProxy
case nameof(Nota.Application.IAudioEngine.PluginParamGet): return Inner.RackChainInstrumentParamGet((int)args![0]!, Chain, (int)args![2]!);
case nameof(Nota.Application.IAudioEngine.PluginParamSet): Inner.RackChainInstrumentParamSet((int)args![0]!, Chain, (int)args![2]!, (float)args![3]!); return null;
case nameof(Nota.Application.IAudioEngine.InstrumentParamDefault): return Inner.RackChainInstrumentParamDefault((int)args![0]!, Chain, (int)args![1]!);
+ case nameof(Nota.Application.IAudioEngine.TrackInstrumentKind): return Inner.RackChainInstrumentKind((int)args![0]!, Chain);
case nameof(Nota.Application.IAudioEngine.BeginAutomationWrite):
case nameof(Nota.Application.IAudioEngine.EndAutomationWrite): return null;
// Live telemetry comes from the chain instrument, not the track's rack instrument.
@@ -1672,6 +1747,7 @@ internal class RackChainDeviceEngineProxy : System.Reflection.DispatchProxy
public Nota.Application.IAudioEngine Inner = null!;
public IRackAccess Access = null!;
public int Chain, Dev;
+ public int Kind = -1; // built-in effect kind, for factory defaults (-1 = hosted plug-in)
protected override object? Invoke(System.Reflection.MethodInfo? m, object?[]? args)
{
switch (m?.Name)
@@ -1682,7 +1758,7 @@ internal class RackChainDeviceEngineProxy : System.Reflection.DispatchProxy
case nameof(Nota.Application.IAudioEngine.DeviceParamMax): return Access.ChainDeviceParamMax(Chain, Dev, (int)args![2]!);
case nameof(Nota.Application.IAudioEngine.DeviceGetParam): return Access.ChainDeviceParamGet(Chain, Dev, (int)args![2]!);
case nameof(Nota.Application.IAudioEngine.DeviceSetParam): Access.ChainDeviceParamSet(Chain, Dev, (int)args![2]!, (float)args![3]!); return null;
- case nameof(Nota.Application.IAudioEngine.DeviceParamDefault): return Access.ChainDeviceParamGet(Chain, Dev, (int)args![2]!); // no default surface for chain devices
+ case nameof(Nota.Application.IAudioEngine.DeviceParamDefault): return Kind >= 0 ? Inner.BuiltinDeviceParamDefault(Kind, (int)args![2]!) : Access.ChainDeviceParamGet(Chain, Dev, (int)args![2]!);
case nameof(Nota.Application.IAudioEngine.DeviceName): return Access.ChainDeviceName(Chain, Dev);
case nameof(Nota.Application.IAudioEngine.DeviceBypassed): return Access.ChainDeviceBypassed(Chain, Dev);
case nameof(Nota.Application.IAudioEngine.SetDeviceBypassed): Access.SetChainDeviceBypassed(Chain, Dev, (bool)args![2]!); return null;
diff --git a/src/managed/Nota.App/DeviceChainView.Shell.cs b/src/managed/Nota.App/DeviceChainView.Shell.cs
index e1bbd072..1dc57a07 100644
--- a/src/managed/Nota.App/DeviceChainView.Shell.cs
+++ b/src/managed/Nota.App/DeviceChainView.Shell.cs
@@ -104,69 +104,6 @@ public sealed partial class DeviceChainView
private static TextBlock Caps(string t, double fs = 9) => new() { Text = t, FontSize = fs, FontWeight = FontWeight.Bold, Foreground = TextTertiary, VerticalAlignment = VerticalAlignment.Center };
private static TextBlock Mono(string t, double w) { var tb = new TextBlock { Text = t, FontSize = 9, Foreground = TextSecondary, Width = w, TextAlignment = TextAlignment.Right, VerticalAlignment = VerticalAlignment.Center }; tb.BindResource(TextBlock.FontFamilyProperty, "Font.Mono"); return tb; }
- // Preset picker "‹ Name ▾ ›" — a sunken field (a list you pick from, not a button): the
- // name opens the factory presets for this kind with the current one checked; ‹ › step to
- // the previous / next preset, wrapping (from Init, › is the first and ‹ the last).
- // Clicks are handled so they neither select nor start dragging the card.
- private Control PresetPicker(IReadOnlyList<string> presets, int cur, string current,
- Action<int> apply, Action<int> step)
- {
- const double H = 18;
- var label = new TextBlock
- {
- Text = string.IsNullOrEmpty(current) ? "Init" : current, FontSize = NotaType.Value + 1, FontWeight = FontWeight.Medium,
- Foreground = TextPrimary, VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis,
- };
- var chevron = new Glyph(GlyphKind.ChevronDown, 8) { Foreground = TextTertiary, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(6, 0, 0, 0) };
- var name = new Border
- {
- Width = 132, Padding = new Thickness(7, 0, 6, 0), Background = Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Hand),
- Child = new DockPanel { Children = { Docked(chevron, Dock.Right), label } },
- };
- ToolTip.SetTip(name, "Choose a preset");
- name.PointerPressed += (_, e) =>
- {
- if (!e.GetCurrentPoint(name).Properties.IsLeftButtonPressed) return;
- e.Handled = true;
- var flyout = new MenuFlyout();
- for (int i = 0; i < presets.Count; i++)
- {
- int iv = i;
- var mi = new MenuItem { Header = presets[i], ToggleType = MenuItemToggleType.Radio, IsChecked = i == cur };
- mi.Click += (_, _) => apply(iv);
- flyout.Items.Add(mi);
- }
- flyout.ShowAt(name);
- };
-
- Border Step(int dir)
- {
- var g = new Glyph(dir < 0 ? GlyphKind.ChevronLeft : GlyphKind.ChevronRight, 8)
- { Foreground = TextTertiary, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
- var b = new Border { Width = H, Background = Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Hand), Child = g };
- ToolTip.SetTip(b, dir < 0 ? "Previous preset" : "Next preset");
- b.PointerEntered += (_, _) => g.Foreground = TextPrimary;
- b.PointerExited += (_, _) => g.Foreground = TextTertiary;
- b.PointerPressed += (_, e) =>
- {
- if (!e.GetCurrentPoint(b).Properties.IsLeftButtonPressed) return;
- e.Handled = true;
- step(dir);
- };
- return b;
- }
- Border Rule() => new() { Width = 1, Background = NotaPalette.GraphBorder };
-
- return new Border
- {
- Height = H, Background = NotaPalette.BgSunken, BorderBrush = NotaPalette.GraphBorder, BorderThickness = new Thickness(1),
- CornerRadius = NotaRadius.Control, ClipToBounds = true, VerticalAlignment = VerticalAlignment.Center,
- Child = new StackPanel { Orientation = Orientation.Horizontal, Children = { Step(-1), Rule(), name, Rule(), Step(+1) } },
- };
- }
-
- private static T Docked<T>(T c, Dock d) where T : Control { DockPanel.SetDock(c, d); return c; }
-
private Border BuildCardShell(ShellSpec s, Control body)
{
int di = s.DeviceIndex;
diff --git a/src/managed/Nota.App/DeviceChainView.cs b/src/managed/Nota.App/DeviceChainView.cs
index 1d53ac5b..25e6b141 100644
--- a/src/managed/Nota.App/DeviceChainView.cs
+++ b/src/managed/Nota.App/DeviceChainView.cs
@@ -217,7 +217,8 @@ public sealed partial class DeviceChainView : UserControl
() => { foreach (var r in _rackParamRefreshers) r(); },
Rebuild,
c => RackPresetSaveRequested?.Invoke(c),
- () => _dropGlow.IsVisible = false);
+ () => _dropGlow.IsVisible = false,
+ _factory);
// ---- instrument / sends / add ----------------------------------------
diff --git a/src/managed/Nota.Application/Engine/IAudioEngine.cs b/src/managed/Nota.Application/Engine/IAudioEngine.cs
index 41471373..ce90b91d 100644
--- a/src/managed/Nota.Application/Engine/IAudioEngine.cs
+++ b/src/managed/Nota.Application/Engine/IAudioEngine.cs
@@ -375,6 +375,8 @@ public interface IAudioEngine : IDisposable
float DeviceGainReduction(int trackId, int deviceIndex);
/// <summary>Factory-default value of a parameter, for double-click reset.</summary>
float DeviceParamDefault(int trackId, int deviceIndex, int paramIndex);
+ /// <summary>Factory default of a built-in effect KIND's parameter (rack chain devices).</summary>
+ float BuiltinDeviceParamDefault(int kind, int paramIndex);
float InstrumentParamDefault(int trackId, int paramIndex);
float MidiEffectParamDefault(int trackId, int index, int paramIndex);
diff --git a/src/managed/Nota.Infrastructure/Interop/NativeMethods.Devices.cs b/src/managed/Nota.Infrastructure/Interop/NativeMethods.Devices.cs
index b0423b8c..ba5b9145 100644
--- a/src/managed/Nota.Infrastructure/Interop/NativeMethods.Devices.cs
+++ b/src/managed/Nota.Infrastructure/Interop/NativeMethods.Devices.cs
@@ -63,6 +63,8 @@ internal static partial class NativeMethods
[LibraryImport(Lib, EntryPoint = "nota_device_param_default")]
internal static partial float DeviceParamDefault(IntPtr engine, int trackId, int deviceIndex, int paramIndex);
+ [LibraryImport(Lib, EntryPoint = "nota_builtin_device_param_default")]
+ internal static partial float BuiltinDeviceParamDefault(IntPtr engine, int kind, int paramIndex);
[LibraryImport(Lib, EntryPoint = "nota_instrument_param_default")]
internal static partial float InstrumentParamDefault(IntPtr engine, int trackId, int paramIndex);
[LibraryImport(Lib, EntryPoint = "nota_midi_effect_param_default")]
diff --git a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Devices.cs b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Devices.cs
index d931e97c..af03db44 100644
--- a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Devices.cs
+++ b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Devices.cs
@@ -96,6 +96,9 @@ public sealed partial class NotaEngine
public float DeviceParamDefault(int trackId, int deviceIndex, int paramIndex)
{ ThrowIfDisposed(); return NativeMethods.DeviceParamDefault(_handle, trackId, deviceIndex, paramIndex); }
+
+ public float BuiltinDeviceParamDefault(int kind, int paramIndex)
+ { ThrowIfDisposed(); return NativeMethods.BuiltinDeviceParamDefault(_handle, kind, paramIndex); }
public float InstrumentParamDefault(int trackId, int paramIndex)
{ ThrowIfDisposed(); return NativeMethods.InstrumentParamDefault(_handle, trackId, paramIndex); }
public float MidiEffectParamDefault(int trackId, int index, int paramIndex)
diff --git a/src/native/nota.engine/include/nota/nota_engine.h b/src/native/nota.engine/include/nota/nota_engine.h
index 4eee6478..3e87d8bb 100644
--- a/src/native/nota.engine/include/nota/nota_engine.h
+++ b/src/native/nota.engine/include/nota/nota_engine.h
@@ -863,6 +863,8 @@ NOTA_API float nota_device_gain_reduction(const NotaEngine* engine, int32_
NOTA_API float nota_device_param_default(const NotaEngine* engine, int32_t track_id, int32_t device_index, int32_t param_index);
NOTA_API float nota_instrument_param_default(const NotaEngine* engine, int32_t track_id, int32_t param_index);
NOTA_API float nota_midi_effect_param_default(const NotaEngine* engine, int32_t track_id, int32_t index, int32_t param_index);
+/* Default of a built-in effect kind's parameter, independent of any instance (rack chain devices). */
+NOTA_API float nota_builtin_device_param_default(const NotaEngine* engine, int32_t kind, int32_t param_index);
/* Real-time analyzer feed: copies up to max_samples of the device's live readings
* into out, returning the count written. Each device defines its own layout (e.g.
diff --git a/src/native/nota.engine/src/Engine.h b/src/native/nota.engine/src/Engine.h
index f2faec0c..5c3a7fc5 100644
--- a/src/native/nota.engine/src/Engine.h
+++ b/src/native/nota.engine/src/Engine.h
@@ -579,6 +579,7 @@ public:
// value; hosted plugins → the current value (no reset).
float deviceParamDefault(int32_t trackId, int32_t deviceIndex, int32_t paramIndex) const;
float instrumentParamDefault(int32_t trackId, int32_t paramIndex) const;
+ float builtinDeviceParamDefault(int32_t kind, int32_t paramIndex) const;
float midiEffectParamDefault(int32_t trackId, int32_t index, int32_t paramIndex) const;
// Live gain reduction (dB) of a dynamics device (built-in Compressor); 0 otherwise.
float deviceGainReduction(int32_t trackId, int32_t deviceIndex) const;
diff --git a/src/native/nota.engine/src/Engine_Devices.cpp b/src/native/nota.engine/src/Engine_Devices.cpp
index 5c20d8bc..6fb81081 100644
--- a/src/native/nota.engine/src/Engine_Devices.cpp
+++ b/src/native/nota.engine/src/Engine_Devices.cpp
@@ -741,6 +741,12 @@ float Engine::deviceParamDefault(int32_t t, int32_t d, int32_t p) const {
auto fresh = makeBuiltinDevice(dev->builtinKind());
return fresh ? fresh->getParam(p) : dev->getParam(p);
}
+// Default of a built-in effect KIND (no instance needed) — for rack chain devices, which
+// have no track/device address of their own.
+float Engine::builtinDeviceParamDefault(int32_t kind, int32_t p) const {
+ auto fresh = makeBuiltinDevice(kind);
+ return fresh ? fresh->getParam(p) : 0.0f;
+}
float Engine::instrumentParamDefault(int32_t t, int32_t p) const {
auto tr = findTrackAuthoring(t);
if (!tr || !tr->instrument) return 0.0f;
diff --git a/src/native/nota.engine/src/nota_engine_device.cpp b/src/native/nota.engine/src/nota_engine_device.cpp
index 355aafa6..fba399bc 100644
--- a/src/native/nota.engine/src/nota_engine_device.cpp
+++ b/src/native/nota.engine/src/nota_engine_device.cpp
@@ -88,6 +88,7 @@ float nota_device_gain_reduction(const NotaEngine* e, int32_t track_id, int32_t
float nota_device_param_default(const NotaEngine* e, int32_t t, int32_t d, int32_t p) { return e ? CENG(e)->deviceParamDefault(t, d, p) : 0.0f; }
float nota_instrument_param_default(const NotaEngine* e, int32_t t, int32_t p) { return e ? CENG(e)->instrumentParamDefault(t, p) : 0.0f; }
float nota_midi_effect_param_default(const NotaEngine* e, int32_t t, int32_t i, int32_t p) { return e ? CENG(e)->midiEffectParamDefault(t, i, p) : 0.0f; }
+float nota_builtin_device_param_default(const NotaEngine* e, int32_t kind, int32_t p) { return e ? CENG(e)->builtinDeviceParamDefault(kind, p) : 0.0f; }
int32_t nota_device_scope(const NotaEngine* e, int32_t track_id, int32_t device_index, float* out, int32_t max_samples) {
return e ? CENG(e)->deviceScope(track_id, device_index, out, max_samples) : 0;
}