Announcement

Collapse
No announcement yet.

Playing Two Sound Files Simultaneously

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Playing Two Sound Files Simultaneously

    I'm just wondering how I'd go about playing two sound files in background simultaneously, either a MIDI and a wave or, if possible, two wave files. What I want to do is straightforward enough, I have a game that I'm writing with numerous sound effects. I'm hoping to have background music throughout the program, but I've had no luck with any of my somewhat clumsy attempts. I was told that I would need to use low-level API calls to do this, but I'm spoiled with the ease that PB can play a single sound and can't make head nor tale of the information on MSDN. I don't suppose any of you would have written this already? I know it's a long shot, but I thought I'd give it a try anyway.

    Thanks in advance.

    Danny.

  • #2
    Haven't tried it myself, but if you are playing the background music in a separate thread, can you THREAD SUSPEND that and play your sound effect, then THREAD RESUME your background?

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Thanks Michael for the suggestion. I tried it, but unfortunately had no success. The thread suspend had no effect on the music that was playing, so when I tried to play a sound on top of it, the music stopped and did not continue when the thread resume command was processed. Brillient idea, though, I Wish I'd thought of it. Any other ideas? THANKS!

      ------------------

      Comment


      • #4
        I should think you can try the DirectX DirectSound API's, i've heard somewhere that you can play, mix and do almost anything with waveforms with DirectSound, although I don't know if its compatible with PB (Check MSDN).

        Otherwise, you always could mix the waveform manually, but thats the long way (and its sooo slow).

        Regards,

        ------------------
        Kev G Peel
        KGP Software
        Bridgwater, UK.
        mailto:[email protected][email protected]</A>

        Comment


        • #5
          You could use the very common and free dll WAVMIX32.DLL.
          It comes with a sample in VB, but it is just a DLL. PB Has no problem using it. On my P200 computer it can play 5 sounds at once an not use more than 8% of the CPU time.

          If you can not find it on the net email me at: [email protected] and I will email you a copy of the file.

          Tim


          ------------------

          Comment


          • #6
            Have you looked at MIDAS?

            It can play MODs(music) and sounds at the same time.
            And it's quite easy to use too
            http://www.s2.org/midas/

            You can download the .inc along with 1 example at our site.


            ------------------
            http://www.sublevel6.f2s.com/

            Comment


            • #7
              Thank you all for your helpful and prompt replies. I greatly appreciate your time. I've found a copy of WavMix32.DLL on the net, and have run the test executable bundled with it. The capability of the dll is remarkable, this is certainly what I've been looking for! My problem, now, is that I don't know how to use the DLL. I was kindly given some VB code with various subs and functions to accomplish this in as streightforward a manner as possible, but I don't know how to convert the VB code over to functioning PB code. Thus, I'm just wondering if any of you have already successfully used WavMix to mix wave files, interrupt specific chanels of audio, Etc. and might be able to give me a couple of pointers. Any help you could offer would be fantastic!
              Thanks. Danny.

              ------------------

              Comment


              • #8
                Providing you have the legal right to do so, you can post the VB code you want to convert and maybe we can help you with the translation... most VB code needs little alteration.

                The most common change is where the VB code is passing a dynamic string to a DLL as a sub/function parameter - most often it is done with BYVAL XYZ AS STRING in VB, and this converts to XYZ AS ASCIIZ in PB.

                If you have any C headers for this then post some of these too - sometimes it is easier to translate the C code than the VB code.

                However (as I noted above) before you actually do post the code, be sure that you have the legal right to do so... many headers and declarations are Copyrighted and we cannot accept postings that may infringe this.

                ------------------
                Lance
                PowerBASIC Support
                mailto:[email protected][email protected]</A>
                Lance
                mailto:[email protected]

                Comment

                Working...
                X