mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-23 20:29:42 +00:00
Advances slightly. I think I need a custom queue for RAM writes.
This commit is contained in:
parent
69dddf34b9
commit
96cf617ee6
@ -28,7 +28,7 @@ void GLU::set_data(uint8_t data) {
|
||||
// oscillators_[address_ & 0x1f].velocity = (oscillators_[address_ & 0x1f].velocity & 0x00ff) | (data << 8);
|
||||
break;
|
||||
}
|
||||
printf("Register write %04x\n", address_);
|
||||
// printf("Register write %04x\n", address_);
|
||||
}
|
||||
|
||||
if(control_ & 0x20) {
|
||||
@ -40,34 +40,38 @@ uint8_t GLU::get_data() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// MARK: - Update logic.
|
||||
// MARK: - Time entry points.
|
||||
|
||||
void GLU::run_for(Cycles cycles) {
|
||||
// Update local state, without generating audio.
|
||||
local_.skip_audio(cycles.as<size_t>());
|
||||
}
|
||||
|
||||
void GLU::get_samples(std::size_t number_of_samples, std::int16_t *target) {
|
||||
// Update remote state, generating audio.
|
||||
remote_.generate_audio(number_of_samples, target, output_range_);
|
||||
}
|
||||
|
||||
void GLU::skip_samples(const std::size_t number_of_samples) {
|
||||
// Update remote state, without generating audio.
|
||||
remote_.skip_audio(number_of_samples);
|
||||
}
|
||||
|
||||
void GLU::set_sample_volume_range(std::int16_t range) {
|
||||
// TODO
|
||||
output_range_ = range;
|
||||
}
|
||||
|
||||
// MARK: - Interface boilerplate.
|
||||
|
||||
void GLU::set_control(uint8_t control) {
|
||||
control_ = control;
|
||||
|
||||
// Low three bits are volume control: this probably needs to be fed off-thrad?
|
||||
local_.control = control;
|
||||
audio_queue_.defer([this, control] () {
|
||||
remote_.control = control;
|
||||
});
|
||||
}
|
||||
|
||||
uint8_t GLU::get_control() {
|
||||
return control_;
|
||||
return local_.control;
|
||||
}
|
||||
|
||||
void GLU::set_address_low(uint8_t low) {
|
||||
@ -85,3 +89,20 @@ void GLU::set_address_high(uint8_t high) {
|
||||
uint8_t GLU::get_address_high() {
|
||||
return address_ >> 8;
|
||||
}
|
||||
|
||||
// MARK: - Update logic.
|
||||
|
||||
void GLU::EnsoniqState::generate_audio(size_t number_of_samples, std::int16_t *target, int16_t range) {
|
||||
(void)number_of_samples;
|
||||
(void)target;
|
||||
(void)range;
|
||||
|
||||
memset(target, 0, number_of_samples * sizeof(int16_t));
|
||||
}
|
||||
|
||||
void GLU::EnsoniqState::skip_audio(size_t number_of_samples) {
|
||||
(void)number_of_samples;
|
||||
|
||||
// Just advance all oscillator pointers and check for interrupts.
|
||||
// If a read occurs to the current-output level, generate it then.
|
||||
}
|
||||
|
@ -54,11 +54,18 @@ class GLU: public Outputs::Speaker::SampleSource {
|
||||
uint8_t control;
|
||||
uint8_t table_size;
|
||||
} oscillators_[32];
|
||||
|
||||
uint8_t control;
|
||||
|
||||
void generate_audio(size_t number_of_samples, std::int16_t *target, int16_t range);
|
||||
void skip_audio(size_t number_of_samples);
|
||||
} local_, remote_;
|
||||
uint8_t interrupt_state_;
|
||||
uint8_t oscillator_enable_;
|
||||
|
||||
uint8_t control_ = 0x00;
|
||||
|
||||
int16_t output_range_ = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user