Phobos-developers / Phobos

Ares-compatible C&C Red Alert 2: Yuri's Revenge engine extension
GNU Lesser General Public License v3.0
254 stars 83 forks source link

Weird bug that audio emitting low quality sound. #1289

Closed silentrzk closed 1 day ago

silentrzk commented 1 week ago

Description

A weird bug that the unit's voice was producing low quality audio(Deep voice and in slow motion) which the cause is by using attack and decay sounds. However, the voice's quality is normal as intended if I do not use attack and decay.

I have tried several attempts such as renaming the .wav files, decreasing the number of attack/decay/voice audios on the Sounds tag.

Conditions to reproduce

Unfortunately, I am not sure how to reproduce this bug because it was random as I have never experienced this kind of issue before.

INI code

[BMIGMove]
Sounds= gradio1a gradio1b gradio1c gradio1d gradio1e gradio1f gradio1g $vbmgmoa $vbmgmob $vbmgmoc $vbmgmod $vbmgmoe gradio3a gradio3b gradio3c gradio3d gradio3e gradio3f gradio3g 
Control= random attack decay
Attack=7
Decay=7
Volume=90

Steps to reproduce

  1. Nothing. Just copy any existing aircraft sound code and replace it with your own custom voices.
  2. ...

Expected behaviour

The sound quality should be the same as from the original .wav file. With using the attack and decay sounds just like any normal aircraft voices.

Actual behaviour

Low quality output(Deep voice and in slow motion) if I use the attack and decay sounds.

Additional context

https://github.com/Phobos-developers/Phobos/assets/173544238/de9f938f-f6d9-4a9c-a476-dd2920927e45

audio bug.zip

Inside the .zip file, it contains the .wav files that cause the bug. I have used different sounds with using attack and decay, but they worked as intended. However, I'd still like to find a way to solve this issue to avoid encountering this complicated bug and of course I want to use those voices in my mod.

Checklist

Starkku commented 1 week ago

This appears to be a quirk of the audio engine, it will play any listed Sounds using the sampling rate/frequency of the first sample. Your new sounds are 48000hz and vanilla game's radio sounds are 22050hz. Because gradio1X will always be the first sound played, it will play the rest using same frequency, resulting in slowed-down playback for the 48khz ones.

Use same sampling rate across all listed sounds for a single event. Hard to say if it is a 'bug' caused by the developers taking a shortcut or an actual technical limitation. Either way, it is unlikely this will get changed in Phobos especially since a practical solution already exists.