Skip to content

Commit

Permalink
Cleanup Voice::modulate_all method
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyMeilex committed Dec 29, 2024
1 parent 42ef7f9 commit 2b080ea
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions oxisynth/src/core/voice_pool/voice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ pub enum VoiceAddMode {
Default = 2,
}

const FLUID_OK: i32 = 0;

#[derive(PartialEq, Clone)]
enum VoiceStatus {
Clean,
Expand Down Expand Up @@ -550,26 +548,21 @@ impl Voice {
}
}

pub(super) fn modulate_all(&mut self, channel: &Channel) -> i32 {
let mut i = 0;
while i < self.mod_count {
let mod_0 = &mut self.mod_0[i];
let gen = mod_0.get_dest();
let mut modval = 0.0f32;
pub(super) fn modulate_all(&mut self, channel: &Channel) {
for i in 0..self.mod_count {
let gen = self.mod_0[i].get_dest();

let modval: f32 = self
.mod_0
.iter()
.take(self.mod_count)
.filter(|k| k.dest == gen)
.map(|k| k.get_value(channel, self))
.sum();

let mut k = 0;
while k < self.mod_count {
if self.mod_0[k].dest == gen {
modval += self.mod_0[k].get_value(channel, self)
}
k += 1
}
self.gen[gen].mod_0 = modval as f64;
self.update_param(gen);
i += 1
}

FLUID_OK
}

/// Turns off a voice, meaning that it is not processed
Expand Down

0 comments on commit 2b080ea

Please sign in to comment.