Support new SPU voice approach

This commit is contained in:
2024-08-24 14:25:05 +02:00
parent 12de2340cc
commit 92b19ecabc
3 changed files with 48 additions and 2 deletions

View File

@@ -4,7 +4,28 @@
#include <PSX/SPU/spu.hpp>
#include <stddef.hpp>
#include <stdio.hpp>
namespace JabyEngine {
namespace SPU {
SRAM_Adr Voice :: allocate(size_t size) const {
Voice::stop();
const auto voice_id = Voice::get_id();
const auto adr = static_cast<SRAM_Adr>(reinterpret_cast<uintptr_t>(SPU_MMU::allocate(voice_id, size)));
SPU_IO::Voice[voice_id].adr.write({adr});
return adr;
}
SRAM_Adr Voice :: allocate(SPU_IO::SampleRate frequency, size_t size) const {
const auto result = Voice::allocate(size);
Voice::set_sample_rate(frequency);
return result;
}
void Voice :: deallocate() const {
Voice::stop();
SPU_MMU::deallocate(Voice::get_id());
}
}
}