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) Open an SFZ by dropping it, or its folder, on Nota Mosaic (#470)
Chris Laupama86f4fddb34b6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e3c6f141..0382e18f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -256,6 +256,11 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.returns, then the master.### Fixed+- **Open an SFZ by dropping it on Nota Mosaic** (#349): drop an `.sfz` file, or the folder of+ an SFZ library (such as the Salamander Grand Piano), on a Mosaic card and its zones load, with+ the import report. Before, only installed sample packs could bring an SFZ in, so a library+ you downloaded yourself couldn't be opened. Controllers an SFZ starts with `set_hdcc` (0–1)+ now count too, so Salamander's string resonance and hammer noise release layers come along.- **Effects on an audio track ring out after Stop** (#449): a reverb or delay placed on anaudio track used to fall silent the instant the transport stopped, while the same reverb ona return track rang on. The track's effects now keep playing on silence until their outputdiff --git a/src/managed/Nota.App/DeviceCards/Instruments/MosaicInstrumentCard.cs b/src/managed/Nota.App/DeviceCards/Instruments/MosaicInstrumentCard.csindex 3550d32c..bd73be12 100644--- a/src/managed/Nota.App/DeviceCards/Instruments/MosaicInstrumentCard.cs+++ b/src/managed/Nota.App/DeviceCards/Instruments/MosaicInstrumentCard.cs@@ -351,7 +351,7 @@ internal sealed class MosaicInstrumentCard : IInstrumentCard// ======================= the zone map (Zones tab, and S) =================================var map = new MosaicZoneMap { Mini = mini, Interactive = !mini };- string EmptyText() => mini ? "Empty" : Loc.T("device.mosaic.drop_samples_or_a_folder");+ string EmptyText() => mini ? "Empty" : Loc.T("device.mosaic.drop_samples_a_folder_or_sfz");void SetMap() => map.Set(prog.Zones, ui.ReleaseView, ui.Zone, EmptyText());SetMap();map.Selected += i => { ui.Zone = i; if (i >= 0 && i < prog.Zones.Count) ui.Group = prog.Zones[i].Group; Refresh(); };@@ -1181,7 +1181,7 @@ internal sealed class MosaicInstrumentCard : IInstrumentCard{if (AllMissing() && prog.Zones.Count > 0) return Loc.T("device.mosaic.samples_unavailable_notes_muted");if (Loading()) return Loc.F("device.mosaic.loading_notes_muted", NotaNum.Bytes(status.RamBytes), NotaNum.Bytes(RamEstimate()));- if (prog.IsEmpty) return Loc.T("device.mosaic.empty_drop_samples_or_a");+ if (prog.IsEmpty) return Loc.T("device.mosaic.empty_drop_samples_a_folder_or_sfz");string name = prog.Name.Length > 0 ? prog.Name + " · " : "";switch (tab){@@ -1297,7 +1297,8 @@ internal sealed class MosaicInstrumentCard : IInstrumentCard{var title = new TextBlock { FontSize = 12, FontWeight = FontWeight.SemiBold, Foreground = AccentBright, HorizontalAlignment = HorizontalAlignment.Center };var line = new TextBlock { FontSize = 8.5, Foreground = TextPrimary, HorizontalAlignment = HorizontalAlignment.Center, TextAlignment = TextAlignment.Center };- var hint = new TextBlock { FontSize = 7.5, Foreground = TextTertiary, HorizontalAlignment = HorizontalAlignment.Center, Text = Loc.T("device.mosaic.opens_the_mapping_preview_a") };+ string multiHint = Loc.T("device.mosaic.opens_the_mapping_preview_a");+ var hint = new TextBlock { FontSize = 7.5, Foreground = TextTertiary, HorizontalAlignment = HorizontalAlignment.Center, Text = multiHint };var dash = new Rectangle{Stroke = AccentBright, StrokeThickness = 1.2, StrokeDashArray = new Avalonia.Collections.AvaloniaList<double> { 4, 3 },@@ -1308,18 +1309,44 @@ internal sealed class MosaicInstrumentCard : IInstrumentCardMargin = new Thickness(5), IsVisible = false, IsHitTestVisible = false,Children = { dash, new StackPanel { Spacing = 4, VerticalAlignment = VerticalAlignment.Center, Children = { title, line, hint } } },};- box.Tag = (Action<string, string>)((t, l) => { title.Text = t; line.Text = l; });+ box.Tag = (Action<string, string, string?>)((t, l, h) => { title.Text = t; line.Text = l; hint.Text = h ?? multiHint; });return box;}+ // An SFZ dropped on the card (#349): its zones become the program, the report shows+ // what it couldn't take, and its controllers' articulations are offered.+ void LoadSfz(string sfz)+ {+ var packs = App.Services?.GetService(typeof(IMosaicPacks)) as IMosaicPacks;+ SfzResult res;+ try { res = SfzImporter.Import(sfz, null, packs is null ? null : packs.ToRef); }+ catch (Exception ex) { ctx.Status(Loc.F("device.mosaic.couldnt_read_sfz", Path.GetFileName(sfz), ex.Message)); return; }+ if (res.Program.Zones.Count == 0)+ {+ ctx.Status(Loc.F("device.mosaic.sfz_has_no_playable_zones", Path.GetFileName(sfz), res.Report.Summary()));+ return;+ }+ res.Program.SourceRef = packs?.ToRef(sfz) ?? sfz;+ prog = res.Program;+ ui.Zone = 0;+ SetImportReport(track, res.Report);+ Commit(rebuild: true);+ // Its envelope, bend range and filter, as an installed pack's SFZ preset sets them.+ // After the commit, so they land on the new instrument it published: undo brings+ // back the old one with its own settings.+ foreach (var (id, v) in SfzImporter.ParamsFrom(res.Report)) SetP(id, v);+ }+void HookDrop(Control target, Control overlay){DragDrop.SetAllowDrop(target, true);- void Show(bool on, string t = "", string l = "")+ void Show(bool on, string t = "", string l = "", string? h = null){overlay.IsVisible = on;- if (on && overlay.Tag is Action<string, string> set) set(t, l);+ if (on && overlay.Tag is Action<string, string, string?> set) set(t, l, h);}+ // Whether a drag carries an SFZ (#349) is checked without reading any file; which+ // program a folder holds is worked out once, on the drop.DragDrop.AddDragOverHandler(target, (_, e) =>{var item = BrowserView.CurrentDrag;@@ -1334,6 +1361,11 @@ internal sealed class MosaicInstrumentCard : IInstrumentCardelse{var paths = folder ? new List<string> { item!.Path } : DroppedPaths(e);+ if (SfzImporter.HasSfz(paths))+ {+ Show(true, Loc.T("device.mosaic.release_to_load_the_sfz"), Path.GetFileName(paths[0].TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)), Loc.T("device.mosaic.its_zones_replace_the_instruments"));+ return;+ }var audio = ExpandAudio(paths);if (audio.Count == 1) Show(true, Loc.T("device.mosaic.release_to_load_the_sample"), Path.GetFileName(audio[0]));else@@ -1354,6 +1386,12 @@ internal sealed class MosaicInstrumentCard : IInstrumentCardelse if (item is { Kind: BrowserItemKind.Folder } && Directory.Exists(item.Path)) paths = new List<string> { item.Path };else if (item is null) paths = DroppedPaths(e);else return;+ if (SfzImporter.ProgramIn(paths) is { } sfz)+ {+ e.Handled = true;+ LoadSfz(sfz);+ return;+ }var audio = ExpandAudio(paths);if (audio.Count == 0) return;e.Handled = true;diff --git a/src/managed/Nota.Application/Instruments/Mosaic/SfzImporter.cs b/src/managed/Nota.Application/Instruments/Mosaic/SfzImporter.csindex 83a4ff3f..17e27f5f 100644--- a/src/managed/Nota.Application/Instruments/Mosaic/SfzImporter.cs+++ b/src/managed/Nota.Application/Instruments/Mosaic/SfzImporter.cs@@ -122,6 +122,10 @@ public static class SfzImporter{if (kv.Key.StartsWith("set_cc", StringComparison.Ordinal) && int.TryParse(kv.Key[6..], NumberStyles.Integer, Inv, out int n))cc[n] = (int)Math.Round(Num(kv.Value, 0));+ // ARIA's high-resolution form, 0..1 (#349: Salamander starts its string resonance,+ // hammer and pedal noise controllers at 0.5 this way).+ else if (kv.Key.StartsWith("set_hdcc", StringComparison.Ordinal) && int.TryParse(kv.Key[8..], NumberStyles.Integer, Inv, out int hn))+ cc[hn] = Math.Clamp((int)Math.Round(Num(kv.Value, 0) * 127), 0, 127);else if (kv.Key.StartsWith("label_cc", StringComparison.Ordinal) && int.TryParse(kv.Key[8..], NumberStyles.Integer, Inv, out int l))report.CcLabels[l] = kv.Value;}@@ -286,6 +290,70 @@ public static class SfzImporterreturn result;}+ /// <summary>The SFZ a drop asks to open (#349): an .sfz file among <paramref name="paths"/>,+ /// else the instrument in a dropped folder (its first SFZ no other SFZ there #includes).+ /// Null when there is none.</summary>+ public static string? ProgramIn(IEnumerable<string> paths)+ {+ var list = paths.ToList();+ foreach (var p in list)+ if (IsSfz(p) && File.Exists(p)) return p;+ foreach (var p in list)+ if (Directory.Exists(p) && TopLevel(p) is { Count: > 0 } top) return top[0];+ return null;+ }++ /// <summary>The envelope, bend range and filter the SFZ names, as Nota Mosaic params (by id).</summary>+ public static Dictionary<string, float> ParamsFrom(SfzImportReport r)+ {+ var d = new Dictionary<string, float>();+ if (r.Attack is { } a) d["attack"] = MosaicModel.AttackNorm(a);+ if (r.Decay is { } dc) d["decay"] = MosaicModel.DecayNorm(dc);+ if (r.Sustain is { } s) d["sustain"] = (float)s;+ if (r.Release is { } rel) d["release"] = MosaicModel.DecayNorm(rel);+ if (r.BendSemis is { } b) d["bendrange"] = (float)Math.Clamp(b / 24.0, 0, 1);+ if (r.CutoffHz is { } c && c < 18000)+ {+ d["filtertype"] = 1f / 3f;+ d["cutoff"] = (float)Math.Clamp(Math.Log(Math.Max(20, c) / 20.0) / Math.Log(1000.0), 0, 1);+ }+ return d;+ }++ /// <summary>Whether a drop carries an SFZ (an .sfz file, or one anywhere in a dropped folder),+ /// without reading any: cheap enough for every drag-over event.</summary>+ public static bool HasSfz(IEnumerable<string> paths)+ {+ foreach (var p in paths)+ {+ if (IsSfz(p) && File.Exists(p)) return true;+ if (!Directory.Exists(p)) continue;+ try { if (Directory.EnumerateFiles(p, "*", SearchOption.AllDirectories).Any(IsSfz)) return true; }+ catch { }+ }+ return false;+ }++ public static bool IsSfz(string path) => Path.GetExtension(path).Equals(".sfz", StringComparison.OrdinalIgnoreCase);++ /// <summary>The SFZ files under <paramref name="root"/> that no other SFZ there #includes —+ /// the instruments, not the fragments they are built from — by name.</summary>+ public static List<string> TopLevel(string root)+ {+ List<string> all;+ try { all = Directory.EnumerateFiles(root, "*", SearchOption.AllDirectories).Where(IsSfz).OrderBy(f => f, StringComparer.OrdinalIgnoreCase).ToList(); }+ catch { return new List<string>(); }+ var included = new HashSet<string>(StringComparer.OrdinalIgnoreCase);+ foreach (var f in all)+ {+ string text;+ try { text = File.ReadAllText(f); } catch { continue; }+ foreach (Match m in IncludeRx.Matches(text))+ included.Add(Path.GetFileName(m.Groups[1].Value.Replace('\\', '/')));+ }+ return all.Where(f => !included.Contains(Path.GetFileName(f))).ToList();+ }+// ---- loading (#include, #define, comments) ---------------------------------------------private static readonly Regex DefineRx = new(@"#define\s+(\$\w+)\s+(\S+)", RegexOptions.Compiled);private static readonly Regex IncludeRx = new("#include\\s+\"([^\"]+)\"", RegexOptions.Compiled);diff --git a/src/managed/Nota.Application/Instruments/MosaicModel.cs b/src/managed/Nota.Application/Instruments/MosaicModel.csindex 8c111977..28d17730 100644--- a/src/managed/Nota.Application/Instruments/MosaicModel.cs+++ b/src/managed/Nota.Application/Instruments/MosaicModel.cs@@ -100,7 +100,7 @@ public static class MosaicModel/// <summary>"Osiris Piano · 30 roots × 4 velocity layers · release 30".</summary>public static string Summary(MosaicProgram p, Func<string, float> g){- if (p.IsEmpty) return "Empty · drop samples or a folder, or pick a preset";+ if (p.IsEmpty) return "Empty · drop samples, a folder or an SFZ, or pick a preset";string voices = VoiceNames[Index(g("voicemode"), 3)] == "Poly" ? $"Poly {Poly(g("polyphony"))}" : VoiceNames[Index(g("voicemode"), 3)];return $"{(p.Name.Length > 0 ? p.Name + " · " : "")}{p.Summary()} · {voices}";}diff --git a/src/managed/Nota.Application/Localization/en.json b/src/managed/Nota.Application/Localization/en.jsonindex 4e75e4fc..42c4aefe 100644--- a/src/managed/Nota.Application/Localization/en.json+++ b/src/managed/Nota.Application/Localization/en.json@@ -1005,13 +1005,14 @@"device.mosaic.blends_the_loops_end_into": "Blends the loop's end into its start (forward loops)","device.mosaic.busy_on_pedal_release": "{0} busy · {1} on pedal · {2} release","device.mosaic.click_a_key_to_make": "Click a key to make it the selected zone's root",+ "device.mosaic.couldnt_read_sfz": "Couldn't read {0}: {1}","device.mosaic.detect_from_file_name": "Detect from file name","device.mosaic.drag_left_right_for_the": "Drag: left / right for the cutoff, up / down for the resonance · Shift for fine steps · ⌥-click to type · double-click resets","device.mosaic.drag_the_nodes_attack_decay": "Drag the nodes: attack, decay and sustain (up / down), release · Shift for fine steps · ⌥-click to type · double-click resets",- "device.mosaic.drop_samples_or_a_folder": "Drop samples or a folder here · or pick a preset",+ "device.mosaic.drop_samples_a_folder_or_sfz": "Drop samples, a folder or an SFZ here · or pick a preset","device.mosaic.edit_this_zones_start_end": "Edit this zone's start, end and loop","device.mosaic.empty": "Empty",- "device.mosaic.empty_drop_samples_or_a": "Empty · drop samples or a folder, or pick a preset",+ "device.mosaic.empty_drop_samples_a_folder_or_sfz": "Empty · drop samples, a folder or an SFZ, or pick a preset","device.mosaic.exclusive_group_off_by": "Exclusive · group / off by","device.mosaic.exclusive_is_for_hi_hats": "Exclusive is for hi-hats and valves: a new note chokes the off_by group.","device.mosaic.files": "{0} / {1} · {2} / {3} files",@@ -1028,6 +1029,7 @@"device.mosaic.how_much_velocity_sets_the": "How much velocity sets the level","device.mosaic.install_pack": "Install pack","device.mosaic.instruments": { "one": "{0} instrument", "other": "{0} instruments" },+ "device.mosaic.its_zones_replace_the_instruments": "Its zones replace the instrument's; the import report says what it couldn't take.","device.mosaic.layers": { "one": "{0} layer", "other": "{0} layers" },"device.mosaic.let_the_amp_envelope_open": "Let the amp envelope open (or close) the filter","device.mosaic.loading": "Loading {0}",@@ -1052,12 +1054,14 @@"device.mosaic.poly_chords_click_again_for": "Poly: chords (click again for the voice settings) · Mono: one at a time, legato with Glide · Choke: a new note cuts the ringing ones","device.mosaic.release_to_build_a_multisample": "Release to build a multisample","device.mosaic.release_to_load_the_sample": "Release to load the sample",+ "device.mosaic.release_to_load_the_sfz": "Release to load the SFZ","device.mosaic.round_robin_steps_the_groups": "Round-robin steps: the group's zones take turns 1 … N (each zone's step is set by its file)","device.mosaic.sample_not_loaded": "Sample not loaded","device.mosaic.samples_are_not_copied_into": "Samples are not copied into the project; the program keeps where they are.","device.mosaic.samples_unavailable_notes_muted": "Samples unavailable · notes muted","device.mosaic.select_a_zone": "Select a zone","device.mosaic.settings_downloads_sample_packs": "Settings → Downloads → Sample packs",+ "device.mosaic.sfz_has_no_playable_zones": "{0} has no zones Nota Mosaic can play ({1})","device.mosaic.shift_every_note_24_semitones": "Shift every note, ±24 semitones","device.mosaic.slide_from_the_last_note": "Slide from the last note — in Mono, legato","device.mosaic.snap_to_zero": "Snap to zero",diff --git a/src/managed/Nota.Infrastructure/Mosaic/MosaicLibrary.cs b/src/managed/Nota.Infrastructure/Mosaic/MosaicLibrary.csindex 4270e175..a6f802af 100644--- a/src/managed/Nota.Infrastructure/Mosaic/MosaicLibrary.cs+++ b/src/managed/Nota.Infrastructure/Mosaic/MosaicLibrary.cs@@ -273,7 +273,7 @@ public sealed class MosaicPackLibrary : IMosaicPackspublic List<(string Name, MosaicProgram Program, Dictionary<string, float> Params)> Generate(string packPath, string packId, string packName){var made = new List<(string, MosaicProgram, Dictionary<string, float>)>();- var sfz = TopLevelSfz(packPath);+ var sfz = SfzImporter.TopLevel(packPath);foreach (var path in sfz){SfzResult res;@@ -283,7 +283,7 @@ public sealed class MosaicPackLibrary : IMosaicPacksstring name = sfz.Count == 1 || stem.Equals("main", StringComparison.OrdinalIgnoreCase) || stem.Equals(packName, StringComparison.OrdinalIgnoreCase)? packName : MultisampleMapper.Pretty(stem.Replace(' ', '_'));res.Program.Name = name; res.Program.SourceRef = ToRef(path); res.Program.PackId = packId; res.Program.PackName = packName;- made.Add((name, res.Program, ParamsFrom(res.Report)));+ made.Add((name, res.Program, SfzImporter.ParamsFrom(res.Report)));}if (made.Count > 0) return made;@@ -299,41 +299,6 @@ public sealed class MosaicPackLibrary : IMosaicPacksreturn made;}- // The SFZ files no other SFZ in the pack #includes (an instrument, not a fragment of one).- private static List<string> TopLevelSfz(string root)- {- List<string> all;- try { all = Directory.EnumerateFiles(root, "*.sfz", SearchOption.AllDirectories).OrderBy(f => f, StringComparer.OrdinalIgnoreCase).ToList(); }- catch { return new List<string>(); }- var included = new HashSet<string>(StringComparer.OrdinalIgnoreCase);- var rx = new System.Text.RegularExpressions.Regex("#include\\s+\"([^\"]+)\"");- foreach (var f in all)- {- string text;- try { text = File.ReadAllText(f); } catch { continue; }- foreach (System.Text.RegularExpressions.Match m in rx.Matches(text))- included.Add(Path.GetFileName(m.Groups[1].Value.Replace('\\', '/')));- }- return all.Where(f => !included.Contains(Path.GetFileName(f))).ToList();- }-- // The envelope / bend / filter the SFZ names, as Mosaic params.- private static Dictionary<string, float> ParamsFrom(SfzImportReport r)- {- var d = new Dictionary<string, float>();- if (r.Attack is { } a) d["attack"] = MosaicModel.AttackNorm(a);- if (r.Decay is { } dc) d["decay"] = MosaicModel.DecayNorm(dc);- if (r.Sustain is { } s) d["sustain"] = (float)s;- if (r.Release is { } rel) d["release"] = MosaicModel.DecayNorm(rel);- if (r.BendSemis is { } b) d["bendrange"] = (float)Math.Clamp(b / 24.0, 0, 1);- if (r.CutoffHz is { } c && c < 18000)- {- d["filtertype"] = 1f / 3f;- d["cutoff"] = (float)Math.Clamp(Math.Log(Math.Max(20, c) / 20.0) / Math.Log(1000.0), 0, 1);- }- return d;- }-private static string Sanitize(string name){foreach (char c in Path.GetInvalidFileNameChars()) name = name.Replace(c, '_');diff --git a/tests/Nota.SmokeTest/LocalizationAllowList.txt b/tests/Nota.SmokeTest/LocalizationAllowList.txtindex 6f40115d..e24241f4 100644--- a/tests/Nota.SmokeTest/LocalizationAllowList.txt+++ b/tests/Nota.SmokeTest/LocalizationAllowList.txt@@ -2349,7 +2349,7 @@ Nota.Application/Instruments/MosaicModel.cs $"Poly {Poly(g(" # data: device paraNota.Application/Instruments/MosaicModel.cs $"{(bytes / 1073741824.0).ToString(" # data: device parameter and value names, scale names (FR-004); instrument tool text for MCPNota.Application/Instruments/MosaicModel.cs (velocity layers with a shared gain/tune and a round-robin). Every zone covering the key, the velocity and the # data: instrument tool text for MCPNota.Application/Instruments/MosaicModel.cs Choke # data: device parameter and value names, scale names (FR-004); instrument tool text for MCP-Nota.Application/Instruments/MosaicModel.cs Empty · drop samples or a folder, or pick a preset # data: device parameter and value names, scale names (FR-004); instrument tool text for MCP+Nota.Application/Instruments/MosaicModel.cs Empty · drop samples, a folder or an SFZ, or pick a preset # data: device parameter and value names, scale names (FR-004); instrument tool text for MCPNota.Application/Instruments/MosaicModel.cs Fwd # data: device parameter and value names, scale names (FR-004); instrument tool text for MCPNota.Application/Instruments/MosaicModel.cs Mono # data: device parameter and value names, scale names (FR-004); instrument tool text for MCPNota.Application/Instruments/MosaicModel.cs Nota Mosaic plays a multisample: zones (a sample on a key × velocity rectangle, with its root) in groups # data: device parameter and value names, scale names (FR-004); instrument tool text for MCPdiff --git a/tests/Nota.SmokeTest/MosaicTests.cs b/tests/Nota.SmokeTest/MosaicTests.csindex c6aab006..6f471586 100644--- a/tests/Nota.SmokeTest/MosaicTests.cs+++ b/tests/Nota.SmokeTest/MosaicTests.cs@@ -384,6 +384,47 @@ internal static class MosaicTestsbool ok = WaitReady(e, t);e.TrackNoteOn(t, 60, 0.3f);yield return (ok && Rms(Render(e, 4096)) > 0.01, "an imported SFZ plays");++ // #349 (Salamander Grand Piano): a dropped folder opens its instrument, not a fragment+ // it #includes, and set_hdcc (0..1) starts a controller as set_cc does.+ yield return (SfzImporter.ProgramIn(new[] { sfzDir }) is { } found && Path.GetFileName(found) == "main.sfz"+ && SfzImporter.ProgramIn(new[] { Path.Combine(sfzDir, "Samples", "brush.wav"), Path.Combine(sfzDir, "Programs", "map", "keys.sfz") }) is { } named+ && Path.GetFileName(named) == "keys.sfz",+ "a dropped SFZ, or the SFZ instrument in a dropped folder, is what opens");+ string hdPath = Path.Combine(dir, "sfz-hd.sfz"); // beside the pack folder, not in it+ File.WriteAllText(hdPath, "<control> set_hdcc20=0.5\n<global> trigger=release\n<region> sample=sfz/Samples/c4_rel.wav key=c4 locc20=1\n");+ var hd = SfzImporter.Import(hdPath);+ yield return (hd.Report.Imported == 1 && hd.Program.Zones[0].Release && hd.Report.CcState.TryGetValue(20, out int cc20) && cc20 == 64,+ $"set_hdcc20=0.5 starts CC20 at 64, so its release layer imports ({hd.Report.Imported} zones)");++ // A dropped SFZ brings its envelope like an installed pack's preset (ParamsFrom), an+ // upper-case .SFZ in a folder is found, and the drag check finds it without reading.+ string upDir = Path.Combine(dir, "sfz-upper");+ Directory.CreateDirectory(upDir);+ File.WriteAllText(Path.Combine(upDir, "Piano.SFZ"), "<global> ampeg_release=4\n<region> sample=../sfz/Samples/c4_rel.wav key=c4\n");+ var upFound = SfzImporter.ProgramIn(new[] { upDir });+ yield return (upFound is not null && Path.GetFileName(upFound) == "Piano.SFZ" && SfzImporter.HasSfz(new[] { upDir })+ && !SfzImporter.HasSfz(new[] { Path.Combine(dir, "sfz", "Samples") }),+ "a folder's upper-case .SFZ is found, and a drag of a folder without one isn't taken for an SFZ");+ var upParams = SfzImporter.ParamsFrom(SfzImporter.Import(upFound!).Report);+ yield return (upParams.TryGetValue("release", out float relN) && Math.Abs(MosaicModel.ReleaseSec(relN) - 4.0) < 0.2,+ $"a dropped SFZ's ampeg_release=4 sets Mosaic's release (got {(upParams.TryGetValue("release", out float r2) ? MosaicModel.ReleaseSec(r2) : -1):F2} s)");++ // The card loads a dropped SFZ as an undoable program and then sets its params on the+ // instrument that published: one undo brings back the old zones with their own release.+ using (var ue = new NotaEngine())+ {+ int ut = ue.AddMosaicTrack();+ int ri = Pi(ue, ut, "release");+ ue.PluginParamSet(ut, -1, ri, 0.2f);+ ue.MosaicSetProgram(ut, SfzImporter.Import(upFound!).Program.Serialize());+ ue.PluginParamSet(ut, -1, ri, relN);+ float after = ue.PluginParamGet(ut, -1, ri);+ ue.Undo();+ float undone = ue.PluginParamGet(ut, -1, ri);+ yield return (Math.Abs(after - relN) < 1e-4 && Math.Abs(undone - 0.2f) < 1e-4,+ $"undoing an SFZ drop brings back the old release too ({undone:F3}, was 0.200)");+ }}// ---- factory multisamples: rendered once, mapped by their names, playable -----------------