Allocate voice
This commit is contained in:
parent
92b19ecabc
commit
0dcd2b71a6
|
@ -41,10 +41,14 @@ namespace JabyEngine {
|
|||
};
|
||||
|
||||
__declare_io_value(SampleRate, uint16_t) {
|
||||
static constexpr SampleRate from_HZ(uint32_t freq) {
|
||||
constexpr uint32_t Base1024Hz = static_cast<uint32_t>((4096.0/44100.0)*1024.0);
|
||||
return {static_cast<uint16_t>((freq >> 10)*Base1024Hz)};
|
||||
}
|
||||
|
||||
static constexpr SampleRate from_HZ(double freq) {
|
||||
//4096 == 44100Hz
|
||||
constexpr double Base = (4096.0 / 44100.0);
|
||||
|
||||
return {static_cast<uint16_t>((freq*Base))};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <PSX/Auxiliary/big_endian.hpp>
|
||||
#include <PSX/File/file_processor_helper.hpp>
|
||||
#include <PSX/SPU/spu.hpp>
|
||||
#include <stdio.hpp>
|
||||
|
||||
#ifdef __SUPPORT_VAG__
|
||||
|
@ -28,8 +29,12 @@ namespace JabyEngine {
|
|||
};
|
||||
|
||||
struct VAGState {
|
||||
static constexpr VAGState create() {
|
||||
return VAGState{};
|
||||
uint32_t voice_id;
|
||||
size_t bytes_left;
|
||||
SPU::SRAM_Adr adr;
|
||||
|
||||
static constexpr VAGState create(uint32_t voice_id) {
|
||||
return VAGState{.voice_id = voice_id, .bytes_left = 0, .adr = 0};
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -37,8 +42,10 @@ namespace JabyEngine {
|
|||
if(config.data_bytes >= sizeof(VAGHeader)) {
|
||||
const auto& header = *reinterpret_cast<const VAGHeader*>(config.data_adr);
|
||||
|
||||
//printf("VAG-ID: %s\nName: %s\nSample size: %i\nSample rate: %i\n", header.id, header.name, header.get_sample_size(), header.get_sample_frequency());
|
||||
// TODO: Allocate SPU memory
|
||||
state.bytes_left = header.get_sample_size();
|
||||
state.adr = SPU::voice[state.voice_id].allocate(SPU_IO::SampleRate::from_HZ(header.get_sample_frequency()), state.bytes_left);
|
||||
|
||||
// TODO: Parse samples
|
||||
return Progress::Error;
|
||||
}
|
||||
|
||||
|
@ -46,7 +53,7 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
State create(const uint32_t* data_adr, const VAG& file) {
|
||||
return State::from(VAGState::create(), data_adr, parse_header);
|
||||
return State::from(VAGState::create(file.voice_number), data_adr, parse_header);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue