33 lines
1.1 KiB
C++
33 lines
1.1 KiB
C++
#pragma once
|
|
#include "../System/IOPorts/spu_io.hpp"
|
|
|
|
namespace JabyEngine {
|
|
namespace SPU {
|
|
using SRAMAdr = SPU_IO::SRAMAdr;
|
|
|
|
// TODO: Rename to sample...?
|
|
struct Voice {
|
|
size_t get_id() const {
|
|
return reinterpret_cast<size_t>(this);
|
|
}
|
|
|
|
SRAMAdr allocate(size_t size) const;
|
|
SRAMAdr allocate(SPU_IO::SampleRate frequency, size_t size) const;
|
|
void deallocate() const;
|
|
|
|
void set_sample_rate(SPU_IO::SampleRate frequency) const {
|
|
SPU_IO::Voice[Voice::get_id()].sampleRate.write(frequency);
|
|
}
|
|
|
|
void play() const {
|
|
SPU_IO::Key::On.write(SPU_IO::KeyOn::for_specific(Voice::get_id()));
|
|
}
|
|
|
|
void stop() const {
|
|
SPU_IO::Key::Off.write(SPU_IO::KeyOff::for_specific(Voice::get_id()));
|
|
}
|
|
};
|
|
|
|
extern const Voice voice[SPU_IO::VoiceCount];
|
|
}
|
|
} |