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.

3.8 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
//
// Empty plugin catalog / preset library, so a BrowserViewModel can be built over the
// factory catalog alone (no scanned plug-ins, no presets folder).

using Nota.Application;

namespace Nota.SmokeTest;

internal sealed class EmptyPluginCatalog : IPluginCatalog
{
    public int Scan(string workerPath) => 0;
    public int Count => 0;
    public string? Description(int index) => null;
    public string? Id(int index) => null;
    public int IndexOfId(string identifier) => -1;
    public void AddScanPath(string dir) { }
    public void RemoveScanPath(int index) { }
    public int ScanPathCount => 0;
    public string? ScanPath(int index) => null;
}

internal sealed class EmptyPresetLibrary : IPresetLibrary
{
    public IReadOnlyList<PresetInfo> List(string folder) => Array.Empty<PresetInfo>();
}

/// <summary>A fixed list of Mosaic pack presets, for the browser's Nota Mosaic → Packs tree.</summary>
internal sealed class FakeMosaicPacks(params MosaicPackPreset[] presets) : IMosaicPacks
{
    public string Root => "";
    public IReadOnlyList<MosaicPackPreset> Presets() => presets;
    public event Action? Changed { add { } remove { } }
    public Task<int> ScanAsync(CancellationToken ct = default) => Task.FromResult(0);
    public string Save(Nota.Application.Mosaic.MosaicProgram program, string name, string folder, IReadOnlyDictionary<string, float>? param = null) => "";
    public string ApplyInPlace(IAudioEngine engine, string path, int trackId) => "";
    public Nota.Application.Mosaic.MosaicProgram? Read(string path) => null;
    public string ToRef(string path) => path;
    public string? Resolve(string reference) => null;
    public double? DetectNote(string path) => null;
}

/// <summary>In-memory favourites (no tags), for the browser's favourites-first ordering.</summary>
internal sealed class FakeBrowserLibrary : IBrowserLibrary
{
    private readonly HashSet<string> _favorites = new(StringComparer.Ordinal);
    public IReadOnlyList<BrowserTag> Tags => Array.Empty<BrowserTag>();
    public bool IsFavorite(string deviceKey) => _favorites.Contains(deviceKey);
    public void SetFavorite(string deviceKey, bool on) { if (on) _favorites.Add(deviceKey); else _favorites.Remove(deviceKey); }
    public IReadOnlyList<string> TagIdsFor(string deviceKey) => Array.Empty<string>();
    public void AssignTag(string deviceKey, string tagId, bool on) { }
    public BrowserTag CreateTag(string title, string color) => new() { Id = title, Title = title, Color = color };
    public void UpdateTag(string id, string title, string color) { }
    public void DeleteTag(string id) { }
    public void Save() { }
    public event Action? Changed { add { } remove { } }
}

/// <summary>A list of scanned plug-ins, each described the way the plug-in host does:
/// "Name | Format | inst|fx | Vendor | Category". <see cref="Set"/> stands in for a rescan.</summary>
internal sealed class FakePluginCatalog(params string[] initial) : IPluginCatalog
{
    private string[] descriptions = initial;
    public void Set(params string[] list) => descriptions = list;
    public int Scan(string workerPath) => descriptions.Length;
    public int Count => descriptions.Length;
    public string? Description(int index) => index >= 0 && index < descriptions.Length ? descriptions[index] : null;
    public string? Id(int index) => index >= 0 && index < descriptions.Length ? $"fake:{index}" : null;
    public int IndexOfId(string identifier)
        => identifier.StartsWith("fake:", StringComparison.Ordinal) && int.TryParse(identifier[5..], out var i) && i < descriptions.Length ? i : -1;
    public void AddScanPath(string dir) { }
    public void RemoveScanPath(int index) { }
    public int ScanPathCount => 0;
    public string? ScanPath(int index) => null;
}