dump audio and bigger room size

This commit is contained in:
madeline
2026-04-04 17:14:09 -07:00
parent 37ab09ec1d
commit 29ea44fc1d
4 changed files with 42 additions and 17 deletions
-16
View File
@@ -3,8 +3,6 @@
#include <SDL3/SDL_init.h>
#include <array>
#include <cassert>
#include <fstream>
#include <ios>
#include <span>
#include "JSystem/JAudio2/JASAiCtrl.h"
@@ -17,8 +15,6 @@
#include "JSystem/JAudio2/JASAudioThread.h"
#include "JSystem/JAudio2/JASDriverIF.h"
// #define DUSK_DUMP_AUDIO
using namespace dusk::audio;
static OutputSubframe OutBuffer;
@@ -91,10 +87,6 @@ void SDLCALL GetNewAudio(
}
}
#if defined(DUSK_DUMP_AUDIO)
static std::ofstream outRaw("guh.raw", std::ios_base::out | std::ios_base::binary);
#endif
int RenderNewAudioFrame() {
JASCriticalSection section;
const u32 countSubframes = JASDriver::getSubFrames();
@@ -107,10 +99,6 @@ int RenderNewAudioFrame() {
JASAudioThread::snIntCount -= 1;
}
#if defined(DUSK_DUMP_AUDIO)
outRaw.flush();
#endif
return static_cast<u16>(countSubframes) * DSP_SUBFRAME_SIZE;
}
@@ -147,10 +135,6 @@ void RenderAudioSubframe() {
}
}
#if defined(DUSK_DUMP_AUDIO)
outRaw.write((const char*)OutInterleaveBuffer.data(), sizeof(OutInterleaveBuffer));
#endif
SDL_PutAudioStreamData(PlaybackStream, &OutInterleaveBuffer, sizeof(OutInterleaveBuffer));
}
+39 -1
View File
@@ -5,6 +5,7 @@
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <span>
#include "Adpcm.hpp"
@@ -17,9 +18,30 @@ using namespace dusk::audio;
ChannelAuxData dusk::audio::ChannelAux[DSP_CHANNELS] = {};
static bool sDumpWasActive = false;
static FILE* sChannelDumpFiles[DSP_CHANNELS] = {};
static void OpenChannelDumpFiles() {
char name[32];
for (int i = 0; i < DSP_CHANNELS; i++) {
snprintf(name, sizeof(name), "channel_%02d.raw", i);
sChannelDumpFiles[i] = fopen(name, "wb");
}
}
static void CloseChannelDumpFiles() {
for (int i = 0; i < DSP_CHANNELS; i++) {
if (sChannelDumpFiles[i]) {
fclose(sChannelDumpFiles[i]);
sChannelDumpFiles[i] = nullptr;
}
}
}
f32 dusk::audio::MasterVolume = 1.0f;
f32 dusk::audio::PrevMasterVolume = 1.0f;
bool dusk::audio::EnableReverb = true;
bool dusk::audio::DumpAudio = false;
/**
* Validate that a DSP channel's format is actually something we know how to play.
@@ -107,6 +129,15 @@ static void MixSubframe(DspSubframe& dst, const DspSubframe& src) {
}
void dusk::audio::DspRender(OutputSubframe& subframe) {
if (DumpAudio != sDumpWasActive) {
sDumpWasActive = DumpAudio;
if (DumpAudio) {
OpenChannelDumpFiles();
} else {
CloseChannelDumpFiles();
}
}
std::span channels(JASDsp::CH_BUF, DSP_CHANNELS);
for (int i = 0; i < channels.size(); i++) {
@@ -167,6 +198,13 @@ void dusk::audio::DspRender(OutputSubframe& subframe) {
}
}
if (DumpAudio && sChannelDumpFiles[i]) {
for (int j = 0; j < DSP_SUBFRAME_SIZE; j++) {
fwrite(&channelSubframe.channels[0][j], sizeof(f32), 1, sChannelDumpFiles[i]);
fwrite(&channelSubframe.channels[1][j], sizeof(f32), 1, sChannelDumpFiles[i]);
}
}
for (int o = 0; o < subframe.channels.size(); o++) {
MixSubframe(subframe.channels[o], channelSubframe.channels[o]);
}
@@ -495,7 +533,7 @@ void dusk::audio::DspInit() {
auto& channelAux = ChannelAux[i];
channelAux.reverb.setwet(1.0f);
channelAux.reverb.setdry(0.0f);
channelAux.reverb.setroomsize(0.2f);
channelAux.reverb.setroomsize(0.4f);
channelAux.reverb.setdamp(0.7f);
channelAux.reverb.setwidth(1.0f);
channelAux.reverb.setmode(0.0f);
+1
View File
@@ -122,4 +122,5 @@ namespace dusk::audio {
extern f32 MasterVolume;
extern f32 PrevMasterVolume;
extern bool EnableReverb;
extern bool DumpAudio;
}
+2
View File
@@ -8,6 +8,7 @@
#include "JSystem/JAudio2/JASDSPInterface.h"
#include "JSystem/JAudio2/JASTrack.h"
#include "dusk/audio/DuskAudioSystem.h"
#include "dusk/audio/DuskDsp.hpp"
static std::array<u8, DSP_CHANNELS> channelSortIndices = {};
static std::array<u32, DSP_CHANNELS> lastResetCounts = {};
@@ -102,6 +103,7 @@ static void ShowAllDspChannels() {
}
ImGui::Text("Active channels: %d", activeChannels);
ImGui::Checkbox("Dump channels to disk", &dusk::audio::DumpAudio);
ImGui::Checkbox("Sort by update count", &sortUpdateCount);
if (sortUpdateCount) {