Results 1 to 4 of 4

Thread: change beep tone

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Location
    WARRINGTON ENNGLAND
    Posts
    4

    change beep tone

    Other than the standard BEEP is it possible to generate any other sounds and if so how?

  2. #2
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
    4.  
    5. Private Const SND_APPLICATION = &H80         '  look for application specific association
    6. Private Const SND_ALIAS = &H10000     '  name is a WIN.INI [sounds] entry
    7. Private Const SND_ALIAS_ID = &H110000    '  name is a WIN.INI [sounds] entry identifier
    8. Private Const SND_ASYNC = &H1         '  play asynchronously
    9. Private Const SND_FILENAME = &H20000     '  name is a file name
    10. Private Const SND_LOOP = &H8         '  loop the sound until next sndPlaySound
    11. Private Const SND_MEMORY = &H4         '  lpszSoundName points to a memory file
    12. Private Const SND_NODEFAULT = &H2         '  silence not default, if sound not found
    13. Private Const SND_NOSTOP = &H10        '  don't stop any currently playing sound
    14. Private Const SND_NOWAIT = &H2000      '  don't wait if the driver is busy
    15. Private Const SND_PURGE = &H40               '  purge non-static events for task
    16. Private Const SND_RESOURCE = &H40004     '  name is a resource name or atom
    17. Private Const SND_SYNC = &H0         '  play synchronously (default)


    Usage:
    'This will play a sound located in your apps path
    Private Sub Command1_Click()
    PlaySound App.Path & "\clap.wav", 0&, SND_ASYNC Or SND_NODEFAULT
    End Sub

    Stop playing Wav:
    PlaySound "C:\welcome.wav", 0&, &H4

  3. #3
    sunnyl
    Guest
    I think redwing was referring to VBs ability to generate a sound, like QB's Sound statement.

    If you are using NT, you can use the Beep API, which will let you specify the frequency and the duration. However in Win95/98 you cannot, the parameters that you pass will be ignored.

    VB Code:
    1. Declare Function Beep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I posted some code for a DLL to do this somewhere a while ago - it's basically a replacement for Beep that actually takes into account the parameters. Note that you shouldn't use it on NT
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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