diff options
| author | 2016-03-24 17:53:22 -0400 | |
|---|---|---|
| committer | 2016-03-24 17:53:22 -0400 | |
| commit | b25605e20f70686fdfea4f5d4fa4d21d4bebb4e8 (patch) | |
| tree | f04f7fc057bf1096ed2332375ab9764fc90cbd89 /src/audio_core/codec.h | |
| parent | Merge pull request #1461 from yuriks/imm-mode2 (diff) | |
| parent | DSP: Implement audio codecs (PCM8, PCM16, ADPCM) (diff) | |
| download | yuzu-b25605e20f70686fdfea4f5d4fa4d21d4bebb4e8.tar.gz yuzu-b25605e20f70686fdfea4f5d4fa4d21d4bebb4e8.tar.xz yuzu-b25605e20f70686fdfea4f5d4fa4d21d4bebb4e8.zip | |
Merge pull request #1566 from MerryMage/audio-codec
DSP: Implement audio codecs (PCM8, PCM16, ADPCM)
Diffstat (limited to 'src/audio_core/codec.h')
| -rw-r--r-- | src/audio_core/codec.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/audio_core/codec.h b/src/audio_core/codec.h new file mode 100644 index 000000000..e695f2edc --- /dev/null +++ b/src/audio_core/codec.h | |||
| @@ -0,0 +1,50 @@ | |||
| 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 <vector> | ||
| 9 | |||
| 10 | #include "common/common_types.h" | ||
| 11 | |||
| 12 | namespace Codec { | ||
| 13 | |||
| 14 | /// A variable length buffer of signed PCM16 stereo samples. | ||
| 15 | using StereoBuffer16 = std::vector<std::array<s16, 2>>; | ||
| 16 | |||
| 17 | /// See: Codec::DecodeADPCM | ||
| 18 | struct ADPCMState { | ||
| 19 | // Two historical samples from previous processed buffer, | ||
| 20 | // required for ADPCM decoding | ||
| 21 | s16 yn1; ///< y[n-1] | ||
| 22 | s16 yn2; ///< y[n-2] | ||
| 23 | }; | ||
| 24 | |||
| 25 | /** | ||
| 26 | * @param data Pointer to buffer that contains ADPCM data to decode | ||
| 27 | * @param sample_count Length of buffer in terms of number of samples | ||
| 28 | * @param adpcm_coeff ADPCM coefficients | ||
| 29 | * @param state ADPCM state, this is updated with new state | ||
| 30 | * @return Decoded stereo signed PCM16 data, sample_count in length | ||
| 31 | */ | ||
| 32 | StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count, const std::array<s16, 16>& adpcm_coeff, ADPCMState& state); | ||
| 33 | |||
| 34 | /** | ||
| 35 | * @param num_channels Number of channels | ||
| 36 | * @param data Pointer to buffer that contains PCM8 data to decode | ||
| 37 | * @param sample_count Length of buffer in terms of number of samples | ||
| 38 | * @return Decoded stereo signed PCM16 data, sample_count in length | ||
| 39 | */ | ||
| 40 | StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data, const size_t sample_count); | ||
| 41 | |||
| 42 | /** | ||
| 43 | * @param num_channels Number of channels | ||
| 44 | * @param data Pointer to buffer that contains PCM16 data to decode | ||
| 45 | * @param sample_count Length of buffer in terms of number of samples | ||
| 46 | * @return Decoded stereo signed PCM16 data, sample_count in length | ||
| 47 | */ | ||
| 48 | StereoBuffer16 DecodePCM16(const unsigned num_channels, const u8* const data, const size_t sample_count); | ||
| 49 | |||
| 50 | }; | ||