mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2024-11-29 08:42:50 +00:00
remove the fader, hasn't helped much
This commit is contained in:
parent
74010e789e
commit
e89f08804d
|
@ -221,7 +221,7 @@ impl PixToneParameters {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub struct PlaybackState(u8, f32, f32, u32);
|
||||
pub struct PlaybackState(u8, f32, u32);
|
||||
|
||||
pub struct PixTonePlayback {
|
||||
pub samples: HashMap<u8, Vec<i16>>,
|
||||
|
@ -244,17 +244,17 @@ impl PixTonePlayback {
|
|||
|
||||
pub fn play_sfx(&mut self, id: u8) {
|
||||
for state in self.playback_state.iter_mut() {
|
||||
if state.0 == id && state.3 == 0 {
|
||||
state.2 = 200.0;
|
||||
state.3 = 0xffffffff;
|
||||
if state.0 == id && state.2 == 0 {
|
||||
state.1 = 0.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
self.playback_state.push(PlaybackState(id, 0.0, 0.0, 0));
|
||||
self.playback_state.push(PlaybackState(id, 0.0, 0));
|
||||
}
|
||||
|
||||
pub fn play_concurrent(&mut self, id: u8, tag: u32) {
|
||||
self.playback_state.push(PlaybackState(id, 0.0, 0.0, tag));
|
||||
self.playback_state.push(PlaybackState(id, 0.0, tag));
|
||||
}
|
||||
|
||||
pub fn mix(&mut self, dst: &mut [u16], sample_rate: f32) {
|
||||
|
@ -282,21 +282,9 @@ impl PixTonePlayback {
|
|||
let s3 = (sample[clamp(pos + 2, 0, sample.len() - 1)] as f32) / 32768.0;
|
||||
let s4 = (sample[pos.saturating_sub(1)] as f32) / 32768.0;
|
||||
|
||||
let mut s = cubic_interp(s1, s2, s4, s3, state.1.fract()) * 32768.0;
|
||||
|
||||
if state.2 > 0.0 {
|
||||
s *= (state.2 / 200.0);
|
||||
|
||||
state.2 -= delta;
|
||||
|
||||
if state.2 <= 0.0 {
|
||||
remove = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let s = cubic_interp(s1, s2, s4, s3, state.1.fract()) * 32768.0;
|
||||
let sam = (*result ^ 0x8000) as i16;
|
||||
*result = sam.wrapping_add(s as i16) as u16 ^ 0x8000;
|
||||
*result = sam.saturating_add(s as i16) as u16 ^ 0x8000;
|
||||
|
||||
state.1 += delta;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue