summaryrefslogtreecommitdiff
path: root/src/audio_core/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio_core/common.h')
-rw-r--r--src/audio_core/common.h132
1 files changed, 0 insertions, 132 deletions
diff --git a/src/audio_core/common.h b/src/audio_core/common.h
deleted file mode 100644
index 056a0ac70..000000000
--- a/src/audio_core/common.h
+++ /dev/null
@@ -1,132 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "common/common_funcs.h"
7#include "common/common_types.h"
8#include "common/swap.h"
9#include "core/hle/result.h"
10
11namespace AudioCommon {
12namespace Audren {
13constexpr Result ERR_INVALID_PARAMETERS{ErrorModule::Audio, 41};
14constexpr Result ERR_SPLITTER_SORT_FAILED{ErrorModule::Audio, 43};
15} // namespace Audren
16
17constexpr u8 BASE_REVISION = '0';
18constexpr u32_le CURRENT_PROCESS_REVISION =
19 Common::MakeMagic('R', 'E', 'V', static_cast<u8>(BASE_REVISION + 0xA));
20constexpr std::size_t MAX_MIX_BUFFERS = 24;
21constexpr std::size_t MAX_BIQUAD_FILTERS = 2;
22constexpr std::size_t MAX_CHANNEL_COUNT = 6;
23constexpr std::size_t MAX_WAVE_BUFFERS = 4;
24constexpr std::size_t MAX_SAMPLE_HISTORY = 4;
25constexpr u32 STREAM_SAMPLE_RATE = 48000;
26constexpr u32 STREAM_NUM_CHANNELS = 2;
27constexpr s32 NO_SPLITTER = -1;
28constexpr s32 NO_MIX = 0x7fffffff;
29constexpr s32 NO_FINAL_MIX = std::numeric_limits<s32>::min();
30constexpr s32 FINAL_MIX = 0;
31constexpr s32 NO_EFFECT_ORDER = -1;
32constexpr std::size_t TEMP_MIX_BASE_SIZE = 0x3f00; // TODO(ogniK): Work out this constant
33// Any size checks seem to take the sample history into account
34// and our const ends up being 0x3f04, the 4 bytes are most
35// likely the sample history
36constexpr std::size_t TOTAL_TEMP_MIX_SIZE = TEMP_MIX_BASE_SIZE + AudioCommon::MAX_SAMPLE_HISTORY;
37constexpr f32 I3DL2REVERB_MAX_LEVEL = 5000.0f;
38constexpr f32 I3DL2REVERB_MIN_REFLECTION_DURATION = 0.02f;
39constexpr std::size_t I3DL2REVERB_TAPS = 20;
40constexpr std::size_t I3DL2REVERB_DELAY_LINE_COUNT = 4;
41using Fractional = s32;
42
43template <typename T>
44constexpr Fractional ToFractional(T x) {
45 return static_cast<Fractional>(x * static_cast<T>(0x4000));
46}
47
48constexpr Fractional MultiplyFractional(Fractional lhs, Fractional rhs) {
49 return static_cast<Fractional>(static_cast<s64>(lhs) * rhs >> 14);
50}
51
52constexpr s32 FractionalToFixed(Fractional x) {
53 const auto s = x & (1 << 13);
54 return static_cast<s32>(x >> 14) + s;
55}
56
57constexpr s32 CalculateDelaySamples(s32 sample_rate_khz, float time) {
58 return FractionalToFixed(MultiplyFractional(ToFractional(sample_rate_khz), ToFractional(time)));
59}
60
61static constexpr u32 VersionFromRevision(u32_le rev) {
62 // "REV7" -> 7
63 return ((rev >> 24) & 0xff) - 0x30;
64}
65
66static constexpr bool IsRevisionSupported(u32 required, u32_le user_revision) {
67 const auto base = VersionFromRevision(user_revision);
68 return required <= base;
69}
70
71static constexpr bool IsValidRevision(u32_le revision) {
72 const auto base = VersionFromRevision(revision);
73 constexpr auto max_rev = VersionFromRevision(CURRENT_PROCESS_REVISION);
74 return base <= max_rev;
75}
76
77static constexpr bool CanConsumeBuffer(std::size_t size, std::size_t offset, std::size_t required) {
78 if (offset > size) {
79 return false;
80 }
81 if (size < required) {
82 return false;
83 }
84 if ((size - offset) < required) {
85 return false;
86 }
87 return true;
88}
89
90struct UpdateDataSizes {
91 u32_le behavior{};
92 u32_le memory_pool{};
93 u32_le voice{};
94 u32_le voice_channel_resource{};
95 u32_le effect{};
96 u32_le mixer{};
97 u32_le sink{};
98 u32_le performance{};
99 u32_le splitter{};
100 u32_le render_info{};
101 INSERT_PADDING_WORDS(4);
102};
103static_assert(sizeof(UpdateDataSizes) == 0x38, "UpdateDataSizes is an invalid size");
104
105struct UpdateDataHeader {
106 u32_le revision{};
107 UpdateDataSizes size{};
108 u32_le total_size{};
109};
110static_assert(sizeof(UpdateDataHeader) == 0x40, "UpdateDataHeader is an invalid size");
111
112struct AudioRendererParameter {
113 u32_le sample_rate;
114 u32_le sample_count;
115 u32_le mix_buffer_count;
116 u32_le submix_count;
117 u32_le voice_count;
118 u32_le sink_count;
119 u32_le effect_count;
120 u32_le performance_frame_count;
121 u8 is_voice_drop_enabled;
122 u8 unknown_21;
123 u8 unknown_22;
124 u8 execution_mode;
125 u32_le splitter_count;
126 u32_le num_splitter_send_channels;
127 u32_le unknown_30;
128 u32_le revision;
129};
130static_assert(sizeof(AudioRendererParameter) == 52, "AudioRendererParameter is an invalid size");
131
132} // namespace AudioCommon