mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-23 20:11:49 +01:00
Implement audren Surround->Stereo downmixing
This commit is contained in:
parent
ad0005f398
commit
af90d4f977
@ -30,7 +30,7 @@ namespace skyline::audio {
|
|||||||
/**
|
/**
|
||||||
* @brief Downmixes a buffer of 5.1 surround audio to stereo
|
* @brief Downmixes a buffer of 5.1 surround audio to stereo
|
||||||
*/
|
*/
|
||||||
std::vector<StereoSample> DownMix(span<Surround51Sample> surroundSamples) {
|
inline std::vector<StereoSample> DownMix(span<Surround51Sample> surroundSamples) {
|
||||||
constexpr i16 FixedPointMultiplier{1000}; //!< Avoids using floating point maths
|
constexpr i16 FixedPointMultiplier{1000}; //!< Avoids using floating point maths
|
||||||
constexpr i16 Attenuation3Db{707}; //! 10^(-3/20)
|
constexpr i16 Attenuation3Db{707}; //! 10^(-3/20)
|
||||||
constexpr i16 Attenuation6Db{501}; //! 10^(-6/20)
|
constexpr i16 Attenuation6Db{501}; //! 10^(-6/20)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
||||||
|
|
||||||
#include <kernel/types/KProcess.h>
|
#include <kernel/types/KProcess.h>
|
||||||
|
#include <audio/downmixer.h>
|
||||||
#include "voice.h"
|
#include "voice.h"
|
||||||
|
|
||||||
namespace skyline::service::audio::IAudioRenderer {
|
namespace skyline::service::audio::IAudioRenderer {
|
||||||
@ -36,7 +37,7 @@ namespace skyline::service::audio::IAudioRenderer {
|
|||||||
format = input.format;
|
format = input.format;
|
||||||
sampleRate = input.sampleRate;
|
sampleRate = input.sampleRate;
|
||||||
|
|
||||||
if (input.channelCount > (input.format == skyline::audio::AudioFormat::ADPCM ? 1 : 2))
|
if (input.channelCount > (input.format == skyline::audio::AudioFormat::ADPCM ? 1 : 6))
|
||||||
throw exception("Unsupported voice channel count: {}", input.channelCount);
|
throw exception("Unsupported voice channel count: {}", input.channelCount);
|
||||||
|
|
||||||
channelCount = static_cast<u8>(input.channelCount);
|
channelCount = static_cast<u8>(input.channelCount);
|
||||||
@ -89,6 +90,11 @@ namespace skyline::service::audio::IAudioRenderer {
|
|||||||
samples[--targetIndex] = sample;
|
samples[--targetIndex] = sample;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (channelCount == constant::SurroundChannelCount) {
|
||||||
|
span(samples).copy_from(span(skyline::audio::DownMix(span(samples).cast<skyline::audio::Surround51Sample>())));
|
||||||
|
samples.resize((samples.size() / constant::SurroundChannelCount) * constant::StereoChannelCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<i16> &Voice::GetBufferData(u32 maxSamples, u32 &outOffset, u32 &outSize) {
|
std::vector<i16> &Voice::GetBufferData(u32 maxSamples, u32 &outOffset, u32 &outSize) {
|
||||||
|
Loading…
Reference in New Issue
Block a user