• Advertisement
Sign in to follow this  

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

This topic is 1411 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

 

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

(accidental double post - apparently can not be deleted)

Edited by tanzanite7

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement