mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-21 05:29:13 +00:00
Correct stereo.
This commit is contained in:
parent
d6f1ea50a6
commit
06b6f85d55
@ -93,21 +93,25 @@ void Audio::output() {
|
||||
}
|
||||
}
|
||||
|
||||
// TEMPORARY: just fill the audio buffer with silence.
|
||||
// Spin until the next buffer is available if just entering it for the first time.
|
||||
// Contention here should be essentially non-existent.
|
||||
if(!sample_pointer_) {
|
||||
while(!buffer_available_[buffer_pointer_].load(std::memory_order::memory_order_relaxed));
|
||||
}
|
||||
|
||||
// Left.
|
||||
buffer_[buffer_pointer_][sample_pointer_] = int16_t(
|
||||
(
|
||||
int8_t(channels_[0].output_level) * channels_[0].output_enabled +
|
||||
int8_t(channels_[2].output_level) * channels_[2].output_enabled
|
||||
channels_[1].output_level * channels_[1].output_enabled +
|
||||
channels_[2].output_level * channels_[2].output_enabled
|
||||
) << 7
|
||||
);
|
||||
|
||||
// Right.
|
||||
buffer_[buffer_pointer_][sample_pointer_+1] = int16_t(
|
||||
(
|
||||
int8_t(channels_[1].output_level) * channels_[1].output_enabled +
|
||||
int8_t(channels_[3].output_level) * channels_[3].output_enabled
|
||||
channels_[0].output_level * channels_[0].output_enabled +
|
||||
channels_[3].output_level * channels_[3].output_enabled
|
||||
) << 7
|
||||
);
|
||||
sample_pointer_ += 2;
|
||||
@ -445,7 +449,7 @@ template <> bool Audio::Channel::output<Audio::Channel::State::PlayingHigh>() {
|
||||
}
|
||||
|
||||
// Output high byte.
|
||||
output_level = data_latch >> 8;
|
||||
output_level = int8_t(data_latch >> 8);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -490,7 +494,7 @@ template <> bool Audio::Channel::output<Audio::Channel::State::PlayingLow>() {
|
||||
}
|
||||
|
||||
// Output low byte.
|
||||
output_level = data_latch & 0xff;
|
||||
output_level = int8_t(data_latch & 0xff);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class Audio: public DMADevice<4> {
|
||||
template <State begin, State end> bool transit();
|
||||
|
||||
// Output state.
|
||||
uint8_t output_level = 0;
|
||||
int8_t output_level = 0;
|
||||
uint8_t output_phase = 0;
|
||||
bool output_enabled = false;
|
||||
} channels_[4];
|
||||
|
Loading…
x
Reference in New Issue
Block a user