mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-25 16:31:42 +00:00
Implements skip_audio.
This commit is contained in:
parent
6f47f9d67c
commit
4870506f6e
@ -174,6 +174,27 @@ uint8_t GLU::get_address_high() {
|
|||||||
|
|
||||||
// MARK: - Update logic.
|
// MARK: - Update logic.
|
||||||
|
|
||||||
|
void GLU::skip_audio(EnsoniqState &state, size_t number_of_samples) {
|
||||||
|
// Just advance all oscillator pointers and check for interrupts.
|
||||||
|
// If a read occurs to the current-output level, generate it then.
|
||||||
|
|
||||||
|
for(int c = 0; c < local_.oscillator_count; c++) {
|
||||||
|
// Don't do anything for halted oscillators.
|
||||||
|
if(state.oscillators[c].control&1) continue;
|
||||||
|
|
||||||
|
// Update phase.
|
||||||
|
state.oscillators[c].position += state.oscillators[c].velocity * number_of_samples;
|
||||||
|
|
||||||
|
// Check for stops, and any interrupts that therefore flow.
|
||||||
|
if((state.oscillators[c].control & 1) && (state.oscillators[c].position & state.oscillators[c].overflow_mask)) {
|
||||||
|
// Apply halt, set interrupt request flag.
|
||||||
|
state.oscillators[c].position = 0;
|
||||||
|
state.oscillators[c].control |= 1;
|
||||||
|
state.oscillators[c].interrupt_request = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GLU::generate_audio(size_t number_of_samples, std::int16_t *target) {
|
void GLU::generate_audio(size_t number_of_samples, std::int16_t *target) {
|
||||||
auto next_store = pending_stores_[pending_store_read_].load(std::memory_order::memory_order_acquire);
|
auto next_store = pending_stores_[pending_store_read_].load(std::memory_order::memory_order_acquire);
|
||||||
uint8_t next_amplitude = 255;
|
uint8_t next_amplitude = 255;
|
||||||
@ -291,11 +312,3 @@ int16_t GLU::EnsoniqState::Oscillator::output(uint8_t *ram) {
|
|||||||
// Samples are unsigned 8-bit; do the proper work to make volume work correctly.
|
// Samples are unsigned 8-bit; do the proper work to make volume work correctly.
|
||||||
return int8_t(level ^ 128) * volume;
|
return int8_t(level ^ 128) * volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLU::skip_audio(EnsoniqState &state, size_t number_of_samples) {
|
|
||||||
(void)number_of_samples;
|
|
||||||
(void)state;
|
|
||||||
|
|
||||||
// Just advance all oscillator pointers and check for interrupts.
|
|
||||||
// If a read occurs to the current-output level, generate it then.
|
|
||||||
}
|
|
||||||
|
@ -77,14 +77,16 @@ class GLU: public Outputs::Speaker::SampleSource {
|
|||||||
uint8_t table_size;
|
uint8_t table_size;
|
||||||
|
|
||||||
// Derived state.
|
// Derived state.
|
||||||
uint32_t overflow_mask; // If a non-zero bit gets anywhere into the overflow mask, this channel
|
uint32_t overflow_mask; // If a non-zero bit gets anywhere into the overflow mask, this channel
|
||||||
// has wrapped around. It's a function of table_size.
|
// has wrapped around. It's a function of table_size.
|
||||||
|
bool interrupt_request = false; // Will be non-zero if this channel would request an interrupt, were
|
||||||
|
// it currently enabled to do so.
|
||||||
|
|
||||||
uint8_t sample(uint8_t *ram);
|
uint8_t sample(uint8_t *ram);
|
||||||
int16_t output(uint8_t *ram);
|
int16_t output(uint8_t *ram);
|
||||||
} oscillators[32];
|
} oscillators[32];
|
||||||
|
|
||||||
// TODO: do all of these need to be on the audio thread?
|
// Some of these aren't actually needed on both threads.
|
||||||
uint8_t control;
|
uint8_t control;
|
||||||
uint8_t interrupt_state;
|
uint8_t interrupt_state;
|
||||||
int oscillator_count;
|
int oscillator_count;
|
||||||
|
Loading…
Reference in New Issue
Block a user