Allocate voice

This commit is contained in:
2024-09-06 11:51:13 +02:00
parent 92b19ecabc
commit 0dcd2b71a6
2 changed files with 17 additions and 6 deletions

View File

@@ -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))};
}
};