Results 1 to 6 of 6

Thread: 2 or more sounds simultaneously

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2014
    Posts
    21

    2 or more sounds simultaneously

    I'v been toying around with sounds as part of my projeckt. I really want to have background music running as well as sound effects.

    I'm using sndPlaySound Lib "winmm.dll" and I think I uderstand that this is a single channel as in I can't get two sounds in with it.
    I'v also been looking at Mmsystem.dll but my Visual basic 6.0 can't find the dll

    So i'm left with yet another question for you brilliant and friendly people.
    How can I play background music and sound effects.


    Code:
    Private Declare Function sndPlaySound Lib "winmm.dll" Alias _
          "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As _
          Long) As Long
       Const SND_ASYNC = &H1
       Const SND_NODEFAULT = &H2
    Code:
    SoundName$ = "nom.wav"
    wFlags% = SND_ASYNC Or SND_NODEFAULT
    x% = sndPlaySound(SoundName$, wFlags%)
    My background music starts with the 2nd form. It's my starting "screen" for the game and it does not get shut down when the game window is running, just get put in the background. It's the same code I use for the background music and sound effects.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Dec 2014
    Posts
    21

    Re: 2 or more sounds simultaneously

    I don't have that many sounds, would windows media player be a viable solution. One player per sound or rather one for background and winmm.dll for the rest?

  3. #3
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: 2 or more sounds simultaneously

    Here ya go
    Attached Files Attached Files


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Dec 2014
    Posts
    21

    Re: 2 or more sounds simultaneously

    Been trying to use your program, unfortunatly I get an error on this line

    Code:
    'Runtime error '53'
    PID2 = Shell(App.Path & "\Player.exe " & Path, vbHide)

  5. #5
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: 2 or more sounds simultaneously

    The attached project demonstrates a different solution using the Media Control Interface (MCI) APIs.
    Attached Files Attached Files
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  6. #6
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: 2 or more sounds simultaneously

    Quote Originally Posted by Zitrap View Post
    Been trying to use your program, unfortunatly I get an error on this line

    Code:
    'Runtime error '53'
    PID2 = Shell(App.Path & "\Player.exe " & Path, vbHide)

    Zip file has two VB projects, Player.vbp and Project1.vbp. Compile Player.vbp and save as Player.exe then run Project1.vbp and it will load Player.exe.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width