Results 1 to 10 of 10

Thread: Sounds

  1. #1

    Thread Starter
    Member insaneman's Avatar
    Join Date
    Oct 2001
    Posts
    63

    Sounds

    How can I get my program to play a sound when I press a key, or click somewhere? Like:

    If keycode = 17 then
    'play sound
    end if
    end sub

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Enter this in a code module:

    Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    Public Const SND_ASYNC = &H1 ' play asynchronously


    and call it fram the form like this:

    sndPlaySound soundName, SND_ASYNC

    where soundName is a string holding the directory and filename of your wav file...

  3. #3
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409
    it depends on what type of sound you want to play if you just want to make a windows beep type in Beep other wise youll have to use the code in the above post unless their are other ways i dont know of.

  4. #4
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    There is many ways to do a thing, but wav files....my way...beeps...dogfish227s way...would probably be the best for your game...

  5. #5

    Thread Starter
    Member insaneman's Avatar
    Join Date
    Oct 2001
    Posts
    63
    Yea, i already have sounds added that way, but what i want is some back ground music, and since MP3 is the only kind i have, is there a way to add that, and so the game doesnt actualy stop while its playing?

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    DirectShow should be able to play MP3 in the background.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Member insaneman's Avatar
    Join Date
    Oct 2001
    Posts
    63
    direct show?

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    lol ,
    he means Direct Sound
    which contains huge api functions giving you full control of the sound card , even its memory .

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    When I say DirectShow then I mean DirectShow.

    DirectSound is not capable of playing MP3s without you writing the decoder. But DirectShow is capable of reading and playing MP3s.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I might also suggest FMod, get your feet wet with professional sound features without going into DirectX

    www.fmod.org

    It can play wave, ogg vorbis, mp3, pcm, etc. and it's free if your app is.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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