Works a lot better now

This commit is contained in:
PJB3005
2026-03-29 00:19:56 +01:00
parent bb92f955c8
commit b17b5fe405
6 changed files with 252 additions and 34 deletions
+13 -5
View File
@@ -111,11 +111,6 @@ int RenderNewAudioFrame() {
outRaw.flush();
#endif
if (JASDriver::extMixCallback != nullptr) {
// TODO: actually mix this data in.
JASDriver::extMixCallback(countSubframes * DSP_SUBFRAME_SIZE);
}
return static_cast<u16>(countSubframes) * DSP_SUBFRAME_SIZE;
}
@@ -138,6 +133,19 @@ void RenderAudioSubframe() {
InterleaveOutputData(OutBuffer, OutInterleaveBuffer);
if (JASDriver::extMixCallback != nullptr && JASDriver::sMixMode == MIX_MODE_INTERLEAVE) {
static_assert(OutputSubframe::NUM_CHANNELS == 2); // This code only works with Stereo so far.
// NOTE: In the real game, this gets called on the entire audio frame, rather than the subframe.
// That's probably more efficient, but I didn't wanna change the code to calculate the
// entire audio buffers at once.
const auto mixData = JASDriver::extMixCallback(DSP_SUBFRAME_SIZE);
if (mixData) {
for (int i = 0; i < OutInterleaveBuffer.size(); i++) {
OutInterleaveBuffer[i] += static_cast<f32>(mixData[i]) / static_cast<f32>(0x7FFF);
}
}
}
#if defined(DUSK_DUMP_AUDIO)
outRaw.write((const char*)OutInterleaveBuffer.data(), sizeof(OutInterleaveBuffer));
#endif