Results 1 to 3 of 3

Thread: Sounds

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    23

    Question

    I'm sorry this is a very simple question but i have just forgotten... How do you get a sound to play when you clik on a button or image? Thanks...

    Bye Bye... XXX...

    http://www.c-interactive.co.uk
    Rember to visit my website at www.c-interactive.co.uk

  2. #2
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305

    What exactly do you mean?

    There are lots of different sounds. If you want a simple beep, try this one:

    Code:
    Beep
    If you want to play a wave, try this:

    (in a module)
    Code:
    Public Declare Function sndPlaySound& lib "winmm.dll" Alias 
    "sndPlaySoundA" (byval lpszSoundName as string, byval 
    uFlags as long) 
    
    'WAV Sound values 
    Global Const SND_SYNC = &H0 
    Global Const SND_ASYNC = &H1 
    Global Const SND_NODEFAULT = &H2 
    Global Const SND_LOOP = &H8 
    Global Const SND_NOSTOP = &H10
    (in the form)
    Code:
    Dim wFlags%
    Dim x%
    Dim tmpSoundName As String
    
        tmpSoundName = "c:\windows\chimes.wav"
        wFlags% = SND_ASYNC Or SND_NODEFAULT
        x% = sndPlaySound(tmpSoundName, wFlags%)
    If you want to play a note at any frequency for any duration, try this:

    note: you need to get win95io.dll from http://www.lvr.com/parport.htm

    In the form, put a two command buttons and a horizontal scroll bar. Command1 is Stop, and command two is Go. The scroll bar changes the frequency, and is limited to above 37. The code:

    Code:
    Private Declare Sub vbOut Lib "WIN95IO.DLL" (ByVal nPort As Integer, ByVal nData As Integer)
    Private Declare Function vbInp Lib "WIN95IO.DLL" (ByVal nPort As Integer) As Integer
    
    Private Sub Sounds(Freq)
    Dim LoByte As Integer
    Dim HiByte As Integer
    Dim Clicks As Integer
    Dim SpkrOn As Integer
    Clicks = CInt(1193280 / Freq)
    LoByte = Clicks And &HFF
    HiByte = Clicks \ 256
    vbOut 67, 182
    vbOut 66, LoByte
    vbOut 66, HiByte
    SpkrOn = vbInp(97) Or &H3
    vbOut 97, SpkrOn
    End Sub
    
    Private Sub Command1_Click()
    vbOut 97, 0
    End Sub
    
    Private Sub Command2_Click()
    Freq = HScroll1.Value
    Sounds Freq
    End Sub
    
    Private Sub HScroll1_Change()
    Freq = HScroll1.Value
    Sounds Freq
    End Sub
    
    Private Sub HScroll1_Scroll()
    Freq = HScroll1.Value
    Sounds Freq
    End Sub
    hope this helps,

    bob

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    23

    Smile

    Thank you so much. It's the sencond option i needed. Thankyou.
    Rember to visit my website at www.c-interactive.co.uk

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