Constants.cs
1 namespace Ryujinx.Audio 2 { 3 /// <summary> 4 /// Define constants used by the audio system. 5 /// </summary> 6 public static class Constants 7 { 8 /// <summary> 9 /// The default device output name. 10 /// </summary> 11 public const string DefaultDeviceOutputName = "DeviceOut"; 12 13 /// <summary> 14 /// The default device input name. 15 /// </summary> 16 public const string DefaultDeviceInputName = "BuiltInHeadset"; 17 18 /// <summary> 19 /// The maximum number of channels supported. (6 channels for 5.1 surround) 20 /// </summary> 21 public const int ChannelCountMax = 6; 22 23 /// <summary> 24 /// The maximum number of channels supported per voice. 25 /// </summary> 26 public const int VoiceChannelCountMax = ChannelCountMax; 27 28 /// <summary> 29 /// The maximum count of mix buffer supported per operations (volumes, mix effect, ...) 30 /// </summary> 31 public const int MixBufferCountMax = 24; 32 33 /// <summary> 34 /// The maximum count of wavebuffer per voice. 35 /// </summary> 36 public const int VoiceWaveBufferCount = 4; 37 38 /// <summary> 39 /// The maximum count of biquad filter per voice. 40 /// </summary> 41 public const int VoiceBiquadFilterCount = 2; 42 43 /// <summary> 44 /// The lowest priority that a voice can have. 45 /// </summary> 46 public const int VoiceLowestPriority = 0xFF; 47 48 /// <summary> 49 /// The highest priority that a voice can have. 50 /// </summary> 51 /// <remarks>Voices with the highest priority will not be dropped if a voice drop needs to occur.</remarks> 52 public const int VoiceHighestPriority = 0; 53 54 /// <summary> 55 /// Maximum <see cref="Common.BehaviourParameter.ErrorInfo"/> that can be returned by <see cref="Parameter.BehaviourErrorInfoOutStatus"/>. 56 /// </summary> 57 public const int MaxErrorInfos = 10; 58 59 /// <summary> 60 /// Default alignment for buffers. 61 /// </summary> 62 public const int BufferAlignment = 0x40; 63 64 /// <summary> 65 /// Alignment required for the work buffer. 66 /// </summary> 67 public const int WorkBufferAlignment = 0x1000; 68 69 /// <summary> 70 /// Alignment required for every performance metrics frame. 71 /// </summary> 72 public const int PerformanceMetricsPerFramesSizeAlignment = 0x100; 73 74 /// <summary> 75 /// The id of the final mix. 76 /// </summary> 77 public const int FinalMixId = 0; 78 79 /// <summary> 80 /// The id defining an unused mix id. 81 /// </summary> 82 public const int UnusedMixId = int.MaxValue; 83 84 /// <summary> 85 /// The id defining an unused splitter id as a signed integer. 86 /// </summary> 87 public const int UnusedSplitterIdInt = -1; 88 89 /// <summary> 90 /// The id defining an unused splitter id. 91 /// </summary> 92 public const uint UnusedSplitterId = uint.MaxValue; 93 94 /// <summary> 95 /// The id of invalid/unused node id. 96 /// </summary> 97 public const int InvalidNodeId = -268435456; 98 99 /// <summary> 100 /// The indice considered invalid for processing order. 101 /// </summary> 102 public const int InvalidProcessingOrder = -1; 103 104 /// <summary> 105 /// The maximum number of audio renderer sessions allowed to be created system wide. 106 /// </summary> 107 public const int AudioRendererSessionCountMax = 2; 108 109 /// <summary> 110 /// The maximum number of audio output sessions allowed to be created system wide. 111 /// </summary> 112 public const int AudioOutSessionCountMax = 12; 113 114 /// <summary> 115 /// The maximum number of audio input sessions allowed to be created system wide. 116 /// </summary> 117 public const int AudioInSessionCountMax = 4; 118 119 /// <summary> 120 /// Maximum buffers supported by one audio device session. 121 /// </summary> 122 public const int AudioDeviceBufferCountMax = 32; 123 124 /// <summary> 125 /// The target sample rate of the audio renderer. (48kHz) 126 /// </summary> 127 public const uint TargetSampleRate = 48000; 128 129 /// <summary> 130 /// The target sample size of the audio renderer. (PCM16) 131 /// </summary> 132 public const int TargetSampleSize = sizeof(ushort); 133 134 /// <summary> 135 /// The target sample count per audio renderer update. 136 /// </summary> 137 public const int TargetSampleCount = 240; 138 139 /// <summary> 140 /// The size of an upsampler entry to process upsampling to <see cref="TargetSampleRate"/>. 141 /// </summary> 142 public const int UpSampleEntrySize = TargetSampleCount * VoiceChannelCountMax; 143 144 /// <summary> 145 /// The target audio latency computed from <see cref="TargetSampleRate"/> and <see cref="TargetSampleCount"/>. 146 /// </summary> 147 public const int AudioProcessorMaxUpdateTimeTarget = 1000000000 / ((int)TargetSampleRate / TargetSampleCount); // 5.00 ms 148 149 /// <summary> 150 /// The maximum update time of the DSP on original hardware. 151 /// </summary> 152 public const int AudioProcessorMaxUpdateTime = 5760000; // 5.76 ms 153 154 /// <summary> 155 /// The maximum update time per audio renderer session. 156 /// </summary> 157 public const int AudioProcessorMaxUpdateTimePerSessions = AudioProcessorMaxUpdateTime / AudioRendererSessionCountMax; 158 159 /// <summary> 160 /// Guest timer frequency used for system ticks. 161 /// </summary> 162 public const int TargetTimerFrequency = 19200000; 163 164 /// <summary> 165 /// The default coefficients used for standard 5.1 surround to stereo downmixing. 166 /// </summary> 167 public static readonly float[] DefaultSurroundToStereoCoefficients = new float[4] 168 { 169 1.0f, 170 0.707f, 171 0.251f, 172 0.707f, 173 }; 174 } 175 }