some optimisation
This commit is contained in:
parent
8129b9f840
commit
86397d3884
3 changed files with 13 additions and 11 deletions
|
@ -224,7 +224,7 @@ impl EmulatorHandler {
|
|||
}
|
||||
|
||||
fn cycle(&mut self) {
|
||||
if self.since.elapsed() >= Duration::from_millis(10) {
|
||||
if self.since.elapsed() >= UPDATE_INTERVAL {
|
||||
self.window_manager.update_events();
|
||||
self.since = Instant::now();
|
||||
}
|
||||
|
@ -234,3 +234,5 @@ impl EmulatorHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
const UPDATE_INTERVAL: Duration = Duration::from_millis(1);
|
||||
|
|
|
@ -16,14 +16,14 @@ mod types;
|
|||
|
||||
impl DacSample {
|
||||
fn mixed(&self, mixer: &Mixer) -> [f32; 2] {
|
||||
let left = (self.one * mixer.ch1.left.scale())
|
||||
+ (self.two * mixer.ch2.left.scale())
|
||||
+ (self.three * mixer.ch3.left.scale())
|
||||
+ (self.four * mixer.ch4.left.scale());
|
||||
let right = (self.one * mixer.ch1.right.scale())
|
||||
+ (self.two * mixer.ch2.right.scale())
|
||||
+ (self.three * mixer.ch3.right.scale())
|
||||
+ (self.four * mixer.ch4.right.scale());
|
||||
let left = mixer.ch1.left.gate(self.one)
|
||||
+ mixer.ch2.left.gate(self.two)
|
||||
+ mixer.ch3.left.gate(self.three)
|
||||
+ mixer.ch4.left.gate(self.four);
|
||||
let right = mixer.ch1.right.gate(self.one)
|
||||
+ mixer.ch2.right.gate(self.two)
|
||||
+ mixer.ch3.right.gate(self.three)
|
||||
+ mixer.ch4.right.gate(self.four);
|
||||
[
|
||||
self.mix_channel(left, mixer.vol_left),
|
||||
self.mix_channel(right, mixer.vol_right),
|
||||
|
|
|
@ -34,10 +34,10 @@ pub(super) enum Volume {
|
|||
}
|
||||
|
||||
impl Volume {
|
||||
pub(super) fn scale(&self) -> f32 {
|
||||
pub(super) fn gate(&self, val: f32) -> f32 {
|
||||
match self {
|
||||
Volume::Muted => 0.,
|
||||
Volume::Enabled => 1.,
|
||||
Volume::Enabled => val,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue