Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 879127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:52:48+00:00 2026-05-15T11:52:48+00:00

Mabye someone over here can explain to me what am I doing wrong. This

  • 0

Mabye someone over here can explain to me what am I doing wrong. This is after reading a lot of articles over the net and doing what the articles say should work but it is not working for me.

I am developing a nice little game with a background music and an explosion sound. For the explosion I know I need to use threads or my music stops when the first explosion happens. I am using threads but the music still stops.

I need the background music to keep on playing all the time and it should continue playing during and after the explosion sound. I tried playing the explosion sync, It doesn’t make any difference, the background sound stops playing the second the thread method is triggered.

Here is my code. It is very simple, but the explosion sound is not working.

  1. This is the GLOBAL decleration in the *.h file:

    UINT CMonstersThread(LPVOID Param);

  2. This is the thread function in the *.cpp file:

    UINT CMonstersThread(LPVOID Param)
    {
        PlaySoundA("sounds\\expl06.wav", NULL, SND_ASYNC);
        AfxEndThread(0);
        return FALSE;
    }
  1. This is the call for the thread every time a “friendly” is hit, (in the same *.cpp file):

    AfxBeginThread(CMonstersThread,NULL,THREAD_PRIORITY_NORMAL,0,0,NULL);

That is all my code. And from what I got over the web, it should work but isn’t playing the music continuously while making explosion sounds as I expect it should.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:52:49+00:00Added an answer on May 15, 2026 at 11:52 am

    I would suggest using XAudio2 from the latest DirectX sdk to play your audio. I will take a little more work & code, but the end result will be better because you will be able to load the sound file separately from playing it.

    With ‘PlaySound’ you will notice a lag in the audio if you try to use it right after an event, like a mouse click or a monster dying / explosion and you won’t hit this with XAudio2. I know this from experience.

    Since you are already using Visual Studio, I also suggest you try using VS 2010 if possible because the [Concurrency Runtime, Parallel Pattern Library and Agents Library]]1 make threading and tasking take a little less code.

    There are samples as well at http://code.msdn.com/concrtextras and you may find something useful here as well.

    -Rick

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm going slidely mad over here, maybe someone can help me figure out what's
been confused about this for over two hours, so maybe someone can point me
I am struggling really hard to understand this behavior so maybe someone can shed
Can someone explain to me or maybe point a link or an example of
I am asking this here in the hope that someone has maybe come across
I found this problem all over the net but no answer yet, so maybe
Ok, so maybe my search syntax is wrong here, this could have very well
I've searched all over the net for a solution to this so lets hope
Over a year ago someone asked this question: Execute .sql files that are used
I have been looking all over for an answer to this question, but can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.