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.

4.2 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
//
// M7-4c: a single-device/instrument preset. C# owns serialization (like
// ProjectModel). A preset captures either a built-in device (kind + param
// values) or a plugin (stable id + opaque state blob), so it can be recalled
// onto any track.

using System.Text.Json.Serialization;

namespace Nota.Infrastructure;

public sealed class PresetDocument
{
    public int FormatVersion { get; set; } = 1;
    public string DisplayName { get; set; } = "";

    /// <summary>"builtin-effect" | "builtin-instrument" | "plugin-effect" | "plugin-instrument".</summary>
    public string Type { get; set; } = "";

    /// <summary>Device/instrument display name at save time (e.g. "Nota Volt", "Serum"),
    /// used to group presets under their device in the browser. "" for older presets.</summary>
    public string DeviceName { get; set; } = "";

    // Built-in device/instrument: kind (effects 0=EQ…5=Rack · instruments 0=Synth,2=Physical,5=Aurora).
    public int BuiltinKind { get; set; } = -1;

    // Legacy positional values (user-saved built-in effect presets, format v1).
    public float[] Params { get; set; } = System.Array.Empty<float>();

    /// <summary>Parameter values keyed by name (effects) or id (instruments). Preferred
    /// over <see cref="Params"/> — robust to param reordering. Effect values are in real
    /// units; instrument values are normalized 0..1.</summary>
    public System.Collections.Generic.Dictionary<string, float>? NamedParams { get; set; }

    /// <summary>Nota Grain factory presets: the factory source (GrainSources id) the
    /// preset loads before its params. Null = keep whatever sample is loaded.</summary>
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? GrainSource { get; set; }

    /// <summary>Nota Mosaic factory presets: the factory multisample (MosaicSources id) the
    /// preset renders on first use and loads. Null = none.</summary>
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? MosaicSource { get; set; }

    /// <summary>Nota Mosaic: the program text (zones + sample references) the preset loads.
    /// Null = keep the loaded program (a sound-only preset).</summary>
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? MosaicProgram { get; set; }

    /// <summary>Nota Aurora: the imported wavetables (specs/053), one entry per oscillator that
    /// holds one. Null = none: applying the preset puts both oscillators back on their built-in
    /// tables (every factory preset).</summary>
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public System.Collections.Generic.List<PresetAuroraTable>? AuroraTables { get; set; }

    /// <summary>Nota EQ-8: the user's band labels and notes (specs/049), one entry per annotated
    /// band. Null = none (a factory preset, or one saved before labels existed).</summary>
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public System.Collections.Generic.List<PresetBandText>? BandText { get; set; }

    // Plugin: stable identity + base64-encoded state blob.
    public string PluginId { get; set; } = "";
    public string StateBase64 { get; set; } = "";

    /// <summary>Forward-compat: unknown fields from newer versions round-trip.</summary>
    [JsonExtensionData] public System.Collections.Generic.Dictionary<string, System.Text.Json.JsonElement>? Extra { get; set; }
}

/// <summary>One EQ-8 band's label and note in a preset (band 1..8).</summary>
public sealed class PresetBandText
{
    public int Band { get; set; }
    public string Label { get; set; } = "";
    public string Note { get; set; } = "";
}

/// <summary>One Nota Aurora oscillator's imported table in a preset (specs/053): the frames as
/// base64 of little-endian float32 (2048 per frame), and whether the oscillator plays it.</summary>
public sealed class PresetAuroraTable
{
    public int Osc { get; set; }
    public string Name { get; set; } = "";
    public int Origin { get; set; }
    public int Frames { get; set; }
    public bool UseCustom { get; set; } = true;
    public string Data { get; set; } = "";
}