I have put together a basic sound handler class for use in my game. It uses OpenAL.
It's a simple method at the moment to play sounds - here's an extract from a switch block:
case "EATEN_PILL": wavPath = "D:\\Programming\\SFX\\EATEN_PILL\\Hit_43.wav"; ALfilename = Path.Combine(Path.Combine("Data", "Audio"), wavPath); sound_data = LoadWave(File.Open(ALfilename, FileMode.Open), out channels, out bits_per_sample, out sample_rate); buffer_EATEN_PILL = AL.GenBuffer(); AL.BufferData(buffer_EATEN_PILL, GetSoundFormat(channels, bits_per_sample), sound_data, sound_data.Length, sample_rate); AL.Source(source, ALSourcei.Buffer, buffer_EATEN_PILL); AL.SourcePlay(source); break;
Problems: 1. An annoying click at the end of each sound. 2. Eventually sound stops playing completely. This is after perhaps playing 100 sounds.
Has anyone hit this problem before?