jammable again - and autoconnects!

This commit is contained in:
🪞👃🪞 2024-07-05 01:28:27 +03:00
parent 3ed9ebddd4
commit 768c2337e7
5 changed files with 98 additions and 59 deletions

View file

@ -70,6 +70,7 @@ impl Sampler {
// dropping voices that have reached their ends.
let mut voices = vec![];
std::mem::swap(&mut voices, &mut self.voices);
let gain = 0.5;
loop {
if voices.len() < 1 {
break
@ -79,7 +80,7 @@ impl Sampler {
for (i, channel) in chunk.iter().enumerate() {
let buffer = &mut mixed[i % channel_count];
for (i, sample) in channel.iter().enumerate() {
buffer[i] += sample;
buffer[i] += sample * gain;
}
}
self.voices.push(voice);