mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 22:55:40 +12:00
HLE DSP: Add PCM8 audio decoding
This commit is contained in:
parent
eacf290f31
commit
800c11ff62
2 changed files with 22 additions and 1 deletions
|
@ -176,6 +176,7 @@ namespace Audio {
|
||||||
// Decode an entire buffer worth of audio
|
// Decode an entire buffer worth of audio
|
||||||
void decodeBuffer(DSPSource& source);
|
void decodeBuffer(DSPSource& source);
|
||||||
|
|
||||||
|
SampleBuffer decodePCM8(const u8* data, usize sampleCount, Source& source);
|
||||||
SampleBuffer decodePCM16(const u8* data, usize sampleCount, Source& source);
|
SampleBuffer decodePCM16(const u8* data, usize sampleCount, Source& source);
|
||||||
SampleBuffer decodeADPCM(const u8* data, usize sampleCount, Source& source);
|
SampleBuffer decodeADPCM(const u8* data, usize sampleCount, Source& source);
|
||||||
|
|
||||||
|
|
|
@ -355,7 +355,7 @@ namespace Audio {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (buffer.format) {
|
switch (buffer.format) {
|
||||||
case SampleFormat::PCM8: Helpers::warn("Unimplemented sample format!"); break;
|
case SampleFormat::PCM8: source.currentSamples = decodePCM8(data, buffer.sampleCount, source); break;
|
||||||
case SampleFormat::PCM16: source.currentSamples = decodePCM16(data, buffer.sampleCount, source); break;
|
case SampleFormat::PCM16: source.currentSamples = decodePCM16(data, buffer.sampleCount, source); break;
|
||||||
case SampleFormat::ADPCM: source.currentSamples = decodeADPCM(data, buffer.sampleCount, source); break;
|
case SampleFormat::ADPCM: source.currentSamples = decodeADPCM(data, buffer.sampleCount, source); break;
|
||||||
|
|
||||||
|
@ -406,6 +406,26 @@ namespace Audio {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HLE_DSP::SampleBuffer HLE_DSP::decodePCM8(const u8* data, usize sampleCount, Source& source) {
|
||||||
|
SampleBuffer decodedSamples(sampleCount);
|
||||||
|
|
||||||
|
if (source.sourceType == SourceType::Stereo) {
|
||||||
|
for (usize i = 0; i < sampleCount; i++) {
|
||||||
|
const s16 left = s16(u16(*data++) << 8);
|
||||||
|
const s16 right = s16(u16(*data++) << 8);
|
||||||
|
decodedSamples[i] = {left, right};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Mono
|
||||||
|
for (usize i = 0; i < sampleCount; i++) {
|
||||||
|
const s16 sample = s16(u16(*data++) << 8);
|
||||||
|
decodedSamples[i] = {sample, sample};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return decodedSamples;
|
||||||
|
}
|
||||||
|
|
||||||
HLE_DSP::SampleBuffer HLE_DSP::decodePCM16(const u8* data, usize sampleCount, Source& source) {
|
HLE_DSP::SampleBuffer HLE_DSP::decodePCM16(const u8* data, usize sampleCount, Source& source) {
|
||||||
SampleBuffer decodedSamples(sampleCount);
|
SampleBuffer decodedSamples(sampleCount);
|
||||||
const s16* data16 = reinterpret_cast<const s16*>(data);
|
const s16* data16 = reinterpret_cast<const s16*>(data);
|
||||||
|
|
Loading…
Add table
Reference in a new issue