// copied from the SDL2 SDL_MixAudioFormat function
// adapted for mixing two individual floats
copied from the SDL2 SDL_MixAudioFormat function
adapted for mixing two individual floats
copied from the SDL2 SDL_MixAudioFormat function adapted for mixing two individual floats
fn mix_audio(dst: &mut f32, src: f32, volume: i32) {
        let fmax_volume = 1.0f32 / 128f32;
        let fvolume = volume as f32;
        let max_audioval = std::f32::MAX as f64;
        let min_audioval = std::f32::MIN as f64;
        let src1 = src * fvolume * fmax_volume;
        let src2 = *dst;
        let mut dst_sample = src1 as f64 + src2 as f64;
        if dst_sample > max_audioval {
            dst_sample = max_audioval;
        } else if dst_sample < min_audioval {
            dst_sample = min_audioval;
        }
        *dst = dst_sample as f32;
    }
fn mix_audio ( dst : & mut f32 , src : f32 , volume : i32 ) { let fmax_volume = 1.0f32 / 128f32 ; let fvolume = volume as f32 ; let max_audioval = std :: f32 :: MAX as f64 ; let min_audioval = std :: f32 :: MIN as f64 ; let src1 = src * fvolume * fmax_volume ; let src2 = * dst ; let mut dst_sample = src1 as f64 + src2 as f64 ; if dst_sample > max_audioval { dst_sample = max_audioval ; } else if dst_sample < min_audioval { dst_sample = min_audioval ; } * dst = dst_sample as f32 ; }
copied from the SDL2 SDL_MixAudioFormat function
adapted for mixing two individual floats
copied from the SDL2 SDL_MixAudioFormat function adapted for mixing two individual floats
dst
&mut f32
src
f32
volume
i32