Thread: c++ bool question pls help

  1. #1
    rderiu
    Guest

    c++ bool question pls help

    i want music to play in the background of my program which i have, but i want the music to stop when they press 's'. how can i do this.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Could you be a little less specific, please?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Code:
    ...
    
    case WM_KEYDOWN:
      
      if (wParam == 'S')
          ExitProcess(0);
      return 0;
    
    break;
    
    ...
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    What kind of program are you using? (Console,Win32)
    What compiler are you using? (Dev,MSVC,Borland)
    What kind of music do you want to play? (wav,mp3)

    [edit]

    By the way, what has the title got to do with your
    question?
    Last edited by Travis Dane; 01-06-2003 at 01:24 PM.

  5. #5
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >By the way, what has the title got to do with your
    question?

    I think he wants to use a boolean value to control whether the music is playing or not.

    But, as was mentioned previously, we need to know what platform, compiler, and music type you are using.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  6. #6
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    But, as was mentioned previously, we need to know what platform, compiler, and music type you are using.
    We actually don't need to know the music type he is using, but we do need to know the platform. He wants to stop sending music to the soundcard when 's' is pressed.

    So rderiu, what platform are you using and how are you driving your soundcard?

  7. #7
    rderiu
    Guest
    im using visual C++ and i want to use a bool function to turn the sound oof i am using PlaySound to play the .wav file. i want it so when u press 'p' the bool function becomes false and the sound stops.

  8. #8
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    >bool function

    Ah, you mean a toggle function, you want to be able to toggle the sound on or off using that function. If you're using Visual C++, you can use the Win32 API functions for handling wave devices. Take a look at MSDN and look for Waveform Functions.
    http://msdn.microsoft.com/

    There are function waveOutPause stops the playing for a while and waveOutRestart resumes the playing.

  9. #9
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    If you call PlaySound with the first(?) parameter as NULL, it will stop all sounds currently playing.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  10. #10
    ˇAmo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Or set the third parameter to SND_PURGE

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. Drawing Program
    By Max_Payne in forum C++ Programming
    Replies: 21
    Last Post: 12-21-2007, 05:34 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. DirectInput help
    By Muphin in forum Game Programming
    Replies: 2
    Last Post: 09-10-2005, 11:52 AM
  5. quick question pls help.
    By Ment in forum C++ Programming
    Replies: 4
    Last Post: 12-24-2002, 11:44 AM