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.

2.2 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
//
// Detail · Devices — maps a built-in device kind (or -1 for a hosted plugin) to the
// body strategy that renders it, replacing the switch that used to live in
// DeviceChainView.DeviceCard. Adding a new built-in effect body is a one-line
// registration here plus a new IDeviceBody — no switch to edit (open/closed).
//
// This lives in the App layer as a plain registry the view news up itself; it is not
// registered in the MS.DI container, matching how the views are wired today.

using System.Collections.Generic;

namespace Nota.App;

internal sealed class DeviceCardFactory
{
    private readonly IDeviceBody _generic = new GenericParamDeviceBody();
    private readonly Dictionary<int, IDeviceBody> _byKind = new()
    {
        [0] = new EqDeviceBody(),
        [1] = new CompressorDeviceBody(),
        [2] = new ReverbDeviceBody(),
        [3] = new DelayDeviceBody(),
        [4] = new UtilityDeviceBody(),
        [6] = new ValveDeviceBody(),
        [7] = new AutoFilterDeviceBody(),
        [8] = new VintageDeviceBody(),
        [9] = new AutoPanDeviceBody(),
        [10] = new AutoShiftDeviceBody(),
        [11] = new BeatRepeatDeviceBody(),
        [12] = new CrushDeviceBody(),
        [13] = new DynamicEqDeviceBody(),
        [14] = new CeilingDeviceBody(),
        [15] = new StrataDeviceBody(),
        [16] = new Eq3DeviceBody(),
        [17] = new ForgeDeviceBody(),
        [18] = new AutoGainDeviceBody(),
        [19] = new ShutterDeviceBody(),
        [20] = new ChamberDeviceBody(),
        [21] = new PrismDeviceBody(),
        [22] = new LensDeviceBody(),
        [23] = new FlangerDeviceBody(),
        [24] = new PhaserDeviceBody(),
        [25] = new ChorusDeviceBody(),
        [26] = new VocoderDeviceBody(),
    };

    /// <summary>Resolve the body for a built-in device: its mapped body, or the generic
    /// param-bar fallback. Hosted plug-ins (-1) and the Audio Effect Rack (5) are built by
    /// the view (PluginCard / RackCardView).</summary>
    public IDeviceBody Resolve(int builtinKind)
        => _byKind.TryGetValue(builtinKind, out var body) ? body
         : _generic;
}