maybe fixed audio issues

This commit is contained in:
Rolf Martin Glomsrud 2023-03-05 04:16:59 +01:00
parent 44c04dbdc2
commit 49b0e69299

View file

@ -80,7 +80,7 @@ impl SortingList for GuiVec{
//Generate sounds //Generate sounds
let mut sounds = Vec::with_capacity(1000); let mut sounds = Vec::with_capacity(1000);
for i in (50..2051).step_by(2){ for i in (50..2051).step_by(2){
sounds.push(soundGenerator::generateTone(i as f32, 0.05).await); sounds.push(soundGenerator::generateTone(i as f32, 0.1).await);
} }
GuiVec{ GuiVec{
@ -178,12 +178,12 @@ impl SortingList for GuiVec{
self.list.swap(index1, index2); self.list.swap(index1, index2);
if time::get_time() + 0.05 >= self.lastPlayed{ if time::get_time() + 0.1 >= self.lastPlayed{
play_sound(self.sounds[ (self.list[index1].position * 1000 / self.list.len()) ], PlaySoundParams{ play_sound(self.sounds[ (self.list[index1].position * 1000 / self.list.len()) ], PlaySoundParams{
looped:false, looped:false,
volume:0.5 volume:0.5
}); });
self.lastPlayed = time::get_time()+0.05; self.lastPlayed = time::get_time()+0.1;
} }
self.lastTouched.clear(); self.lastTouched.clear();
@ -234,12 +234,12 @@ impl SortingList for GuiVec{
self.reads += 1; self.reads += 1;
self.list[i] = elem; self.list[i] = elem;
self.draw().await; self.draw().await;
if time::get_time() + 0.05 >= self.lastPlayed{ if time::get_time() + 0.1 >= self.lastPlayed{
play_sound(self.sounds[ (self.list[i].position * 1000 / self.list.len()) ], PlaySoundParams{ play_sound(self.sounds[ (self.list[i].position * 1000 / self.list.len()) ], PlaySoundParams{
looped:false, looped:false,
volume:1. volume:1.
}); });
self.lastPlayed = time::get_time()+0.05; self.lastPlayed = time::get_time()+0.1;
} }
self.lastTouched.clear(); self.lastTouched.clear();
self.lastTouched.push(i); self.lastTouched.push(i);