For the past few days, I have been working hard on adding an audio system to my game. So far, I have managed to set-up two different audio systems.
The first is specialized for songs since they can be large. Note: all of my audio files are .ogg files. For the songs, I load them into an ALLEGRO_AUDIO_STREAM.
The second is designed for sound effects. Note: they are also .ogg files. This time around I use an ALLEGRO_SAMPLE_INSTANCE.
For some odd reason, when I play a song with multiple sound effects, I get static. I tried on other computers and on my headphones and its the same issue.
I tried isolating the issue with little luck. All I noticed is that if I play a single sound, be it a song, or a sound effect, it will be clear, and the moment I begin adding other audio, it begins to fill-up with static.
Note: For each song I am creating a new AUDIO_STREAM, MIXER, and VOICE. For each sound, I am creating a new MIXER, VOICE, SAMPLE, SAMPLE INSTANCE, AUDIO STREAM. I don't really know if its a bad thing having that many mixers/voices/samples.
Here is how I create my song class:
And here is how I create my sound class:
Additional info, here are my settings:
-Frequency: 44100
-Buffer Count: 2
-Samples: 2048
-Reserved Samples: 50
Why might it be creating static???
Generally you only need a single voice and mixer. You definitely should not be creating one per song.
If you call al_reserve_samples() that will automatically create a mixer. You can then call al_get_default_mixer(). Also, with al_reserve_samples() you can simply call al_play_sample() without creating your own instances... that's what it's for, after all.
I did exactly as you told me and it works great! No more static noise.
Thanks a bunch
Fixed in r14803. This was due to the use of a global mixing buffer which obviously is wrong when two mixers run in parallel (which only happens when there are multiple voices).
Not that you need multiple voices.