mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 22:55:40 +12:00
HLE DSP: Track voice status better
This commit is contained in:
parent
43a1c89478
commit
37f9f5d894
2 changed files with 52 additions and 4 deletions
|
@ -8,6 +8,8 @@
|
||||||
namespace Audio {
|
namespace Audio {
|
||||||
struct DSPSource {
|
struct DSPSource {
|
||||||
std::array<float, 3> gain0, gain1, gain2;
|
std::array<float, 3> gain0, gain1, gain2;
|
||||||
|
u16 syncCount;
|
||||||
|
bool enabled;
|
||||||
|
|
||||||
// Audio buffer information
|
// Audio buffer information
|
||||||
// https://www.3dbrew.org/wiki/DSP_Memory_Region
|
// https://www.3dbrew.org/wiki/DSP_Memory_Region
|
||||||
|
@ -86,6 +88,7 @@ namespace Audio {
|
||||||
Audio::HLE::SharedMemory& readRegion() { return readRegionIndex() == 0 ? dspRam.region0 : dspRam.region1; }
|
Audio::HLE::SharedMemory& readRegion() { return readRegionIndex() == 0 ? dspRam.region0 : dspRam.region1; }
|
||||||
Audio::HLE::SharedMemory& writeRegion() { return readRegionIndex() == 0 ? dspRam.region1 : dspRam.region0; }
|
Audio::HLE::SharedMemory& writeRegion() { return readRegionIndex() == 0 ? dspRam.region1 : dspRam.region0; }
|
||||||
|
|
||||||
|
void updateSourceConfig(Source& source, HLE::SourceConfiguration::Configuration& config);
|
||||||
void generateFrame(StereoFrame<s16>& frame);
|
void generateFrame(StereoFrame<s16>& frame);
|
||||||
void outputFrame();
|
void outputFrame();
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -199,11 +199,56 @@ namespace Audio {
|
||||||
SharedMemory& read = readRegion();
|
SharedMemory& read = readRegion();
|
||||||
SharedMemory& write = writeRegion();
|
SharedMemory& write = writeRegion();
|
||||||
|
|
||||||
for (int source = 0; source < sourceCount; source++) {
|
for (int i = 0; i < sourceCount; i++) {
|
||||||
//updateSourceConfig(sources[source]);
|
// Update source configuration from the read region of shared memory
|
||||||
Helpers::panic("Panda");
|
auto& config = read.sourceConfigurations.config[i];
|
||||||
|
auto& source = sources[i];
|
||||||
|
updateSourceConfig(source, config);
|
||||||
|
|
||||||
|
// Generate audio
|
||||||
|
|
||||||
|
// Update write region of shared memory
|
||||||
|
auto& status = write.sourceStatuses.status[i];
|
||||||
|
status.isEnabled = source.enabled;
|
||||||
|
status.syncCount = source.syncCount;
|
||||||
|
//status.lastBufferID=0,status.currentBufferID = 1; status.currentBufferIDDirty = 1;
|
||||||
|
//status.bufferPosition =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPSource::reset() {}
|
void HLE_DSP::updateSourceConfig(Source& source, HLE::SourceConfiguration::Configuration& config) {
|
||||||
|
// Check if the any dirty bit is set, otherwise exit early
|
||||||
|
if (!config.dirtyRaw) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.enableDirty) {
|
||||||
|
config.enableDirty = 0;
|
||||||
|
source.enabled = config.enable != 0;
|
||||||
|
|
||||||
|
printf("Voice %d enable set to %d\n", source.index, source.enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.syncCountDirty) {
|
||||||
|
config.syncCountDirty = 0;
|
||||||
|
source.syncCount = config.syncCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.resetFlag) {
|
||||||
|
config.resetFlag = 0;
|
||||||
|
printf("Reset voice %d\n", source.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.partialResetFlag) {
|
||||||
|
config.partialResetFlag = 0;
|
||||||
|
printf("Partially reset voice %d\n", source.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
config.dirtyRaw = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DSPSource::reset() {
|
||||||
|
enabled = false;
|
||||||
|
syncCount = 0;
|
||||||
|
}
|
||||||
} // namespace Audio
|
} // namespace Audio
|
||||||
|
|
Loading…
Add table
Reference in a new issue