diff options
Diffstat (limited to 'src/audio_core/hle/source.h')
| -rw-r--r-- | src/audio_core/hle/source.h | 149 |
1 files changed, 0 insertions, 149 deletions
diff --git a/src/audio_core/hle/source.h b/src/audio_core/hle/source.h deleted file mode 100644 index c4d2debc2..000000000 --- a/src/audio_core/hle/source.h +++ /dev/null | |||
| @@ -1,149 +0,0 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <array> | ||
| 8 | #include <queue> | ||
| 9 | #include <vector> | ||
| 10 | #include "audio_core/codec.h" | ||
| 11 | #include "audio_core/hle/common.h" | ||
| 12 | #include "audio_core/hle/dsp.h" | ||
| 13 | #include "audio_core/hle/filter.h" | ||
| 14 | #include "audio_core/interpolate.h" | ||
| 15 | #include "common/common_types.h" | ||
| 16 | |||
| 17 | namespace DSP { | ||
| 18 | namespace HLE { | ||
| 19 | |||
| 20 | /** | ||
| 21 | * This module performs: | ||
| 22 | * - Buffer management | ||
| 23 | * - Decoding of buffers | ||
| 24 | * - Buffer resampling and interpolation | ||
| 25 | * - Per-source filtering (SimpleFilter, BiquadFilter) | ||
| 26 | * - Per-source gain | ||
| 27 | * - Other per-source processing | ||
| 28 | */ | ||
| 29 | class Source final { | ||
| 30 | public: | ||
| 31 | explicit Source(size_t source_id_) : source_id(source_id_) { | ||
| 32 | Reset(); | ||
| 33 | } | ||
| 34 | |||
| 35 | /// Resets internal state. | ||
| 36 | void Reset(); | ||
| 37 | |||
| 38 | /** | ||
| 39 | * This is called once every audio frame. This performs per-source processing every frame. | ||
| 40 | * @param config The new configuration we've got for this Source from the application. | ||
| 41 | * @param adpcm_coeffs ADPCM coefficients to use if config tells us to use them (may contain | ||
| 42 | * invalid values otherwise). | ||
| 43 | * @return The current status of this Source. This is given back to the emulated application via | ||
| 44 | * SharedMemory. | ||
| 45 | */ | ||
| 46 | SourceStatus::Status Tick(SourceConfiguration::Configuration& config, | ||
| 47 | const s16_le (&adpcm_coeffs)[16]); | ||
| 48 | |||
| 49 | /** | ||
| 50 | * Mix this source's output into dest, using the gains for the `intermediate_mix_id`-th | ||
| 51 | * intermediate mixer. | ||
| 52 | * @param dest The QuadFrame32 to mix into. | ||
| 53 | * @param intermediate_mix_id The id of the intermediate mix whose gains we are using. | ||
| 54 | */ | ||
| 55 | void MixInto(QuadFrame32& dest, size_t intermediate_mix_id) const; | ||
| 56 | |||
| 57 | private: | ||
| 58 | const size_t source_id; | ||
| 59 | StereoFrame16 current_frame; | ||
| 60 | |||
| 61 | using Format = SourceConfiguration::Configuration::Format; | ||
| 62 | using InterpolationMode = SourceConfiguration::Configuration::InterpolationMode; | ||
| 63 | using MonoOrStereo = SourceConfiguration::Configuration::MonoOrStereo; | ||
| 64 | |||
| 65 | /// Internal representation of a buffer for our buffer queue | ||
| 66 | struct Buffer { | ||
| 67 | PAddr physical_address; | ||
| 68 | u32 length; | ||
| 69 | u8 adpcm_ps; | ||
| 70 | std::array<u16, 2> adpcm_yn; | ||
| 71 | bool adpcm_dirty; | ||
| 72 | bool is_looping; | ||
| 73 | u16 buffer_id; | ||
| 74 | |||
| 75 | MonoOrStereo mono_or_stereo; | ||
| 76 | Format format; | ||
| 77 | |||
| 78 | bool from_queue; | ||
| 79 | u32_dsp play_position; // = 0; | ||
| 80 | bool has_played; // = false; | ||
| 81 | }; | ||
| 82 | |||
| 83 | struct BufferOrder { | ||
| 84 | bool operator()(const Buffer& a, const Buffer& b) const { | ||
| 85 | // Lower buffer_id comes first. | ||
| 86 | return a.buffer_id > b.buffer_id; | ||
| 87 | } | ||
| 88 | }; | ||
| 89 | |||
| 90 | struct { | ||
| 91 | |||
| 92 | // State variables | ||
| 93 | |||
| 94 | bool enabled = false; | ||
| 95 | u16 sync = 0; | ||
| 96 | |||
| 97 | // Mixing | ||
| 98 | |||
| 99 | std::array<std::array<float, 4>, 3> gain = {}; | ||
| 100 | |||
| 101 | // Buffer queue | ||
| 102 | |||
| 103 | std::priority_queue<Buffer, std::vector<Buffer>, BufferOrder> input_queue; | ||
| 104 | MonoOrStereo mono_or_stereo = MonoOrStereo::Mono; | ||
| 105 | Format format = Format::ADPCM; | ||
| 106 | |||
| 107 | // Current buffer | ||
| 108 | |||
| 109 | u32 current_sample_number = 0; | ||
| 110 | u32 next_sample_number = 0; | ||
| 111 | AudioInterp::StereoBuffer16 current_buffer; | ||
| 112 | |||
| 113 | // buffer_id state | ||
| 114 | |||
| 115 | bool buffer_update = false; | ||
| 116 | u32 current_buffer_id = 0; | ||
| 117 | |||
| 118 | // Decoding state | ||
| 119 | |||
| 120 | std::array<s16, 16> adpcm_coeffs = {}; | ||
| 121 | Codec::ADPCMState adpcm_state = {}; | ||
| 122 | |||
| 123 | // Resampling state | ||
| 124 | |||
| 125 | float rate_multiplier = 1.0; | ||
| 126 | InterpolationMode interpolation_mode = InterpolationMode::Polyphase; | ||
| 127 | AudioInterp::State interp_state = {}; | ||
| 128 | |||
| 129 | // Filter state | ||
| 130 | |||
| 131 | SourceFilters filters; | ||
| 132 | |||
| 133 | } state; | ||
| 134 | |||
| 135 | // Internal functions | ||
| 136 | |||
| 137 | /// INTERNAL: Update our internal state based on the current config. | ||
| 138 | void ParseConfig(SourceConfiguration::Configuration& config, const s16_le (&adpcm_coeffs)[16]); | ||
| 139 | /// INTERNAL: Generate the current audio output for this frame based on our internal state. | ||
| 140 | void GenerateFrame(); | ||
| 141 | /// INTERNAL: Dequeues a buffer and does preprocessing on it (decoding, resampling). Puts it | ||
| 142 | /// into current_buffer. | ||
| 143 | bool DequeueBuffer(); | ||
| 144 | /// INTERNAL: Generates a SourceStatus::Status based on our internal state. | ||
| 145 | SourceStatus::Status GetCurrentStatus(); | ||
| 146 | }; | ||
| 147 | |||
| 148 | } // namespace HLE | ||
| 149 | } // namespace DSP | ||