//
// Copyright (c) 2019-2020 Ryujinx
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see .
//
namespace Ryujinx.Audio.Renderer
{
///
/// Define constants used by the Audio Renderer.
///
public static class RendererConstants
{
///
/// The maximum number of channels supported. (6 channels for 5.1 surround)
///
public const int ChannelCountMax = 6;
///
/// The maximum number of channels supported per voice.
///
public const int VoiceChannelCountMax = ChannelCountMax;
///
/// The max count of mix buffer supported per operations (volumes, mix effect, ...)
///
public const int MixBufferCountMax = 24;
///
/// The max count of wavebuffer per voice.
///
public const int VoiceWaveBufferCount = 4;
///
/// The max count of biquad filter per voice.
///
public const int VoiceBiquadFilterCount = 2;
///
/// The lowest priority that a voice can have.
///
public const int VoiceLowestPriority = 0xFF;
///
/// The highest priority that a voice can have.
///
/// Voices with the highest priority will not be dropped if a voice drop needs to occur.
public const int VoiceHighestPriority = 0;
///
/// Max that can be returned by .
///
public const int MaxErrorInfos = 10;
///
/// Default alignment for buffers.
///
public const int BufferAlignment = 0x40;
///
/// Alignment required for the work buffer.
///
public const int WorkBufferAlignment = 0x1000;
///
/// Alignment required for every performance metrics frame.
///
public const int PerformanceMetricsPerFramesSizeAlignment = 0x100;
///
/// The id of the final mix.
///
public const int FinalMixId = 0;
///
/// The id defining an unused mix id.
///
public const int UnusedMixId = int.MaxValue;
///
/// The id defining an unused splitter id as a signed integer.
///
public const int UnusedSplitterIdInt = -1;
///
/// The id defining an unused splitter id.
///
public const uint UnusedSplitterId = uint.MaxValue;
///
/// The id of invalid/unused node id.
///
public const int InvalidNodeId = -268435456;
///
/// The indice considered invalid for processing order.
///
public const int InvalidProcessingOrder = -1;
///
/// The max number of audio renderer sessions allowed to be created system wide.
///
public const int AudioRendererSessionCountMax = 2;
///
/// The target sample rate of the audio renderer. (48kHz)
///
public const uint TargetSampleRate = 48000;
///
/// The target sample size of the audio renderer. (PCM16)
///
public const int TargetSampleSize = sizeof(ushort);
///
/// The target sample count per audio renderer update.
///
public const int TargetSampleCount = 240;
///
/// The size of an upsampler entry to process upsampling to .
///
public const int UpSampleEntrySize = TargetSampleCount * VoiceChannelCountMax;
///
/// The target audio latency computed from and .
///
public const int AudioProcessorMaxUpdateTimeTarget = 1000000000 / ((int)TargetSampleRate / TargetSampleCount); // 5.00 ms
///
/// The max update time of the DSP on original hardware.
///
public const int AudioProcessorMaxUpdateTime = 5760000; // 5.76 ms
///
/// The max update time per audio renderer session.
///
public const int AudioProcessorMaxUpdateTimePerSessions = AudioProcessorMaxUpdateTime / AudioRendererSessionCountMax;
///
/// Guest timer frequency used for system ticks.
///
public const int TargetTimerFrequency = 19200000;
///
/// The default coefficients used for standard 5.1 surround to stereo downmixing.
///
public static float[] DefaultSurroundToStereoCoefficients = new float[4]
{
1.0f,
0.707f,
0.251f,
0.707f,
};
}
}