using ManagedBass;
namespace T3.Core.Audio;
///
/// Configuration settings for the audio system.
/// Compile-time constants are used for buffer sizes that require static initialization.
/// Runtime settings can be configured through UserSettings in the Editor.
///
public static class AudioConfig
{
#region Mixer Configuration
// Note: MixerFrequency is determined at runtime from the device's sample rate.
// Other values are const because they are used for static array initialization.
///
/// Sample rate for all mixer streams (Hz).
/// This is set at runtime to match the device's current sample rate.
/// Default value is 48000Hz until Bass is initialized.
///
public static int MixerFrequency { get; internal set; } = 48000;
///
/// BASS update period in milliseconds for low-latency playback.
///
internal const int UpdatePeriodMs = 10;
///
/// Number of BASS update threads.
///
internal const int UpdateThreads = 2;
///
/// Playback buffer length in milliseconds.
///
internal const int PlaybackBufferLengthMs = 100;
///
/// Device buffer length in milliseconds for low-latency output.
///
internal const int DeviceBufferLengthMs = 20;
#endregion
#region 3D Audio Configuration
///
/// Distance factor for 3D audio. This is the number of units per meter.
/// Default is 1.0 (1 unit = 1 meter). Set to 100 if your world uses centimeters.
///
internal static float DistanceFactor { get; set; } = 1.0f;
///
/// Rolloff factor for 3D audio distance attenuation.
/// 0 = no rolloff, 1 = real-world rolloff, higher = faster rolloff.
///
internal static float RolloffFactor { get; set; } = 1.0f;
///
/// Doppler factor for 3D audio velocity effects.
/// 0 = no Doppler, 1 = real-world Doppler, higher = exaggerated Doppler.
///
internal static float DopplerFactor { get; set; } = 1.0f;
#endregion
#region FFT and Analysis Configuration (Compile-time Constants)
// Note: These are const because AudioAnalysis uses them to allocate static arrays.
///
/// FFT buffer size for frequency analysis.
///
internal const int FftBufferSize = 1024;
///
/// BASS data flag corresponding to the FFT buffer size.
///
public const DataFlags BassFftDataFlag = DataFlags.FFT2048;
///
/// Number of frequency bands for audio analysis.
///
internal const int FrequencyBandCount = 32;
///
/// Waveform sample buffer size.
///
internal const int WaveformSampleCount = 1024;
///
/// Low-pass filter cutoff frequency (Hz) for low frequency separation.
///
internal const float LowPassCutoffFrequency = 250f;
///
/// High-pass filter cutoff frequency (Hz) for high frequency separation.
///
internal const float HighPassCutoffFrequency = 2000f;
#endregion
#region Metering Configuration
///
/// Time window in seconds for level metering via Bass.ChannelGetLevel (level-ex variant).
/// Shorter values = more responsive but noisier, longer values = smoother but more latency.
/// 0.05s (50ms) provides a good balance for visual metering.
///
internal const float LevelMeteringWindowSeconds = 0.05f;
#endregion
}