PB Application & Windows 7 Sound Mixer

Just starting out? Need help? Post your questions and find answers here.
Phantomas
User
User
Posts: 96
Joined: Wed Jul 01, 2009 12:59 pm

PB Application & Windows 7 Sound Mixer

Post by Phantomas »

Hello.
I create application with Sound sub-system and planning to PlaySound's in some cases.
I want have possibility to Mute my application via Windows 7 Sound Mixer.

The problem that application added in Windows 7 Sound Mixer only after PlaySound() function execute. Example:

Code: Select all

#ogg_file = "D:\sound.ogg"

If InitSound() And UseOGGSoundDecoder() And LoadSound(0, #ogg_file) And OpenWindow(0, 0, 0, 200, 100, "")
  ButtonGadget(0, 10, 10, 60, 60, "Play")
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 0
            PlaySound(0)
        EndSelect
      Case #PB_Event_CloseWindow
        Break
    EndSelect
  ForEver
EndIf
Run this code and check Sound Mixer, application not was added. Click on button — added.

I can use this "hack":

Code: Select all

#ogg_file = "D:\sound.ogg"

If InitSound() And UseOGGSoundDecoder() And LoadSound(0, #ogg_file) And OpenWindow(0, 0, 0, 200, 100, "")
  PlaySound(0, 0, 0)
  
  ButtonGadget(0, 10, 10, 60, 60, "Play")
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 0
            PlaySound(0, 0, 100)
        EndSelect
      Case #PB_Event_CloseWindow
        Break
    EndSelect
  ForEver
EndIf
But, whether there is a better way? Maybe some WinAPI?

And another question:
PlaySound have flags, I use 0 value for ignore it, this is correct? #PB_Ignore not corred (exactly as #PB_Sound_Loop).