#nullable enable
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace T3.Editor.Gui.Windows.TimeLine;
///
/// Per-composition recording configuration. Drives which sources the timeline Record
/// button hooks into when the user clicks it. Editor-only —
/// takes plain booleans, so there's no Core consumer for these flags. Lives on
/// alongside
/// for the same reason
/// the latter does: project-side UI-only state.
///
///
/// Permissive defaults — a composition without an explicit
/// block captures everything
/// (matches the pre-config behaviour of the recording feature). Serialised into the
/// .t3ui sidecar by SymbolUiJson.
///
internal sealed class RecordingSettings
{
public static readonly RecordingSettings Defaults = new();
/// Capture microphone / loopback audio via WASAPI on Record.
public bool CaptureAudio = true;
/// Capture IO events (MIDI + OSC) into a .data file on Record.
public bool CaptureIo = true;
///
/// When is on, also subscribe to MIDI events. Lets the user
/// record just OSC by turning this off — useful when a MIDI controller is plugged in
/// for live input but its events shouldn't end up in the timeline take.
///
public bool CaptureMidi = true;
///
/// When is on, also subscribe to OSC events on the
/// configured port. Symmetric to .
///
public bool CaptureOsc = true;
#region Serialization
///
/// Lightweight detector for "non-default state worth persisting." Keeps the
/// .t3ui file lean for compositions that never touched these settings.
///
internal bool IsAtDefault()
=> CaptureAudio == Defaults.CaptureAudio
&& CaptureIo == Defaults.CaptureIo
&& CaptureMidi == Defaults.CaptureMidi
&& CaptureOsc == Defaults.CaptureOsc;
internal void WriteToJson(JsonTextWriter writer)
{
writer.WritePropertyName("Recording");
writer.WriteRawValue(JsonConvert.SerializeObject(this, Formatting.Indented));
}
internal static RecordingSettings? ReadFromJson(JToken parentToken)
{
var token = parentToken["Recording"];
if (token == null)
return null;
return token.ToObject();
}
#endregion
}