Skip to content

Commit

Permalink
fix stereo mixing
Browse files Browse the repository at this point in the history
  • Loading branch information
HookedBehemoth committed Jun 12, 2020
1 parent 7d4327b commit 28c4c18
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions sys-tune/source/impl/music_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,22 @@ namespace tune::impl {

audrvVoiceSetDestinationMix(&g_drv, 0, AUDREN_FINAL_MIX_ID);

for (int src = 0; src < channel_count; src++) {
audrvVoiceSetMixFactor(&g_drv, 0, 1.0f, src, src % 2);
if (channel_count == 1) {
audrvVoiceSetMixFactor(&g_drv, 0, 1.0f, 0, 0);
audrvVoiceSetMixFactor(&g_drv, 0, 1.0f, 0, 1);
} else {
audrvVoiceSetMixFactor(&g_drv, 0, 1.0f, 0, 0);
audrvVoiceSetMixFactor(&g_drv, 0, 0.0f, 0, 1);
audrvVoiceSetMixFactor(&g_drv, 0, 0.0f, 1, 0);
audrvVoiceSetMixFactor(&g_drv, 0, 1.0f, 1, 1);
}

audrvVoiceStart(&g_drv, 0);

const s32 sample_count = AudioSampleSize / channel_count / sizeof(s16);
AudioDriverWaveBuf buffers[2] = {};
const s32 sample_count = AudioSampleSize / channel_count / sizeof(s16);
AudioDriverWaveBuf buffers[BufferCount] = {};

for (int i = 0; i < 2; i++) {
for (int i = 0; i < BufferCount; i++) {
buffers[i].data_pcm16 = reinterpret_cast<s16 *>(&AudioMemoryPool);
buffers[i].size = AudioSampleSize;
buffers[i].start_sample_offset = i * sample_count;
Expand Down Expand Up @@ -162,7 +169,7 @@ namespace tune::impl {
}
}

/* Sleep if queue is selected. */
/* Sleep if queue is empty. */
if (g_current.empty()) {
svcSleepThread(100'000'000ul);
continue;
Expand Down

0 comments on commit 28c4c18

Please sign in to comment.