Jump to content

  • Log In with Google      Sign In   
  • Create Account

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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 CdrTomalak   Members   -  Reputation: 272

Like
0Likes
Like

Posted 01 February 2014 - 03:02 PM

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!



Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS