• Advertisement
Sign in to follow this  

elays in wav playback using Naudio. Mis-use of threading?

This topic is 1452 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

Hi,

I'm looking to use Naudio for a game I'm making.

I've coded a simple initialisation routine, which currently has:

                    IWavePlayer wavePlayer1;
                    AudioFileReader file1;
                    string filename1 = "D:\\Programming\\SFX\\MUSIC\\IN_GAME_1.wav";
                    
                    wavePlayer1 = new WaveOut();
                    file1 = new AudioFileReader(filename1);
                    wavePlayer1.Init(file1);
                    Thread thread1 = new Thread(new ThreadStart(wavePlayer1.Play));
                    thread1.Start();

When I run the game, the wav file plays for maybe half a second, then it stops, and a second later it resumes.

If I place System.Threading.Thread.Sleep(5000) immediately after starting the thread, the delay has an additional 5 seconds. This seems to prove that 'thread1.Start();' isn't actually starting the sound in it's own thread at all.

Being a bit of a threading and Naudio noob can anyone tell me what I'm doing wrong here? My requirement for the game is to simply have the ability to play several sounds at once. Nothing major.

Any ideas?

Thanks in advance!

Share this post


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

  • Advertisement