Followers 0

How do I prevent clicking at the end of each sound play in OpenAL?

3 posts in this topic

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?

0

Share on other sites

first of all, it's likely stopping to play sound because you run out of buffers, don't load and generate buffers each time a pill is eaten.

load it once, and store it, then re-use it when the pill is eaten.

i woudn't be surprised if after fixing this issue, the clicking noise goes away as well, but i don't make that guarantee.

0

Share on other sites

1. An annoying click at the end of each sound.

Are you sure your wav is not just badly cut? The wave form should end on a neutral level. Edited by tanzanite7
0

Share on other sites

(accidental double post - apparently can not be deleted)

Edited by tanzanite7
0

Create an account

Register a new account