mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-19 20:19:13 +12:00
Semi-proper audio output
This commit is contained in:
parent
21ced6fae7
commit
e0c1d4511b
2 changed files with 11 additions and 4 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "helpers.hpp"
|
||||
|
||||
static constexpr uint channelCount = 2;
|
||||
|
||||
MiniAudioDevice::MiniAudioDevice() : initialized(false), running(false), samples(nullptr) {}
|
||||
|
||||
void MiniAudioDevice::init(Samples& samples, bool safe) {
|
||||
|
@ -79,10 +81,10 @@ void MiniAudioDevice::init(Samples& samples, bool safe) {
|
|||
deviceConfig = ma_device_config_init(ma_device_type_playback);
|
||||
// The 3DS outputs s16 stereo audio @ 32768 Hz
|
||||
deviceConfig.playback.format = ma_format_s16;
|
||||
deviceConfig.playback.channels = 2;
|
||||
deviceConfig.playback.channels = channelCount;
|
||||
deviceConfig.sampleRate = 32768;
|
||||
//deviceConfig.periodSizeInFrames = 64;
|
||||
//deviceConfig.periods = 2;
|
||||
//deviceConfig.periods = 16;
|
||||
deviceConfig.pUserData = this;
|
||||
deviceConfig.aaudio.usage = ma_aaudio_usage_game;
|
||||
deviceConfig.wasapi.noAutoConvertSRC = true;
|
||||
|
@ -91,7 +93,8 @@ void MiniAudioDevice::init(Samples& samples, bool safe) {
|
|||
auto self = reinterpret_cast<MiniAudioDevice*>(device->pUserData);
|
||||
s16* output = reinterpret_cast<ma_int16*>(out);
|
||||
|
||||
self->samples->pop(output, frameCount);
|
||||
while (self->samples->size() < frameCount * channelCount) {}
|
||||
self->samples->pop(output, frameCount * 2);
|
||||
};
|
||||
|
||||
if (ma_device_init(&context, &deviceConfig, &device) != MA_SUCCESS) {
|
||||
|
|
|
@ -55,7 +55,11 @@ TeakraDSP::TeakraDSP(Memory& mem, Scheduler& scheduler, DSPService& dspService)
|
|||
ahbm.write32 = [&](u32 addr, u32 value) { *(u32*)&mem.getFCRAM()[addr - PhysicalAddrs::FCRAM] = value; };
|
||||
|
||||
teakra.SetAHBMCallback(ahbm);
|
||||
teakra.SetAudioCallback([=](std::array<s16, 2> sample) { sampleBuffer.push(sample.data(), 2); });
|
||||
teakra.SetAudioCallback([=](std::array<s16, 2> sample) {
|
||||
while (sampleBuffer.size() + 2 > sampleBuffer.Capacity()) {}
|
||||
|
||||
sampleBuffer.push(sample.data(), 2);
|
||||
});
|
||||
|
||||
// Set up event handlers. These handlers forward a hardware interrupt to the DSP service, which is responsible
|
||||
// For triggering the appropriate DSP kernel events
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue