CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Posts
    1

    VB3-VB6 generated tones; How to?

    I need to find a way for VB6 to generate tones as I did in VB3. Many of my installations do not have sound cards and I need the PC to make noise. From VB3 I had the following:


    Sub Sound (byval Frequency as Long, byval SoundDuration as Integer)
    Dim i as Integer

    If Frequency < 300 then
    Frequency = 300 * 65536
    else
    If Frequency > 15000 then
    Frequency = 15000 * 65636
    else
    Frequency = Frequency * 65536
    End If
    End If
    i = SetVoiceSound(1, Frequency, SoundDuration)
    i = StartSound()
    Do While (WaitSoundState(1) <> 0)
    i = WaitSoundState(1)
    Loop

    End Sub
    '
    ' Make a rise/fall siren noise
    '
    Sub Siren (Frequency as Integer)
    Dim i as Integer
    Dim result as Integer
    Dim StepSize as Integer
    Dim Freq as Integer

    result = OpenSound()
    If result < 0 then
    ' "OpenSound Failed; Sound.Drv not available. Restart windows to correct problem."
    Beep
    else
    If Frequency < 300 then
    Frequency = 300
    End If
    SirenFreq1 = Frequency
    SirenFreq2 = Frequency * 3
    SirenDur = 6
    i = true
    StepSize = (SirenFreq2 - SirenFreq1) / 30
    for Freq = SirenFreq1 to SirenFreq2 step StepSize
    Call Sound(Freq, SirenDur)
    next Freq

    for Freq = SirenFreq2 to SirenFreq1 step -StepSize
    Call Sound(Freq, SirenDur)
    next Freq
    result = CloseSound()
    End If

    End Sub




    I'd call Siren(3000) to get a rise/fall siren from the PC's speaker. Good enough. From VB6 I have not found any way to accomplish this except .wav files, but most existing users have (and can't add) sound cards. All I can think of is Thunking to the "Sound.Drv", but I don't know how to do this. Any advise would be appreciated, lack of this functionality has prevented me from moving many existing users to my 32 bit applications. As a stop gap I've used beep but this is WAY to limited.

    Thanks,


  2. #2
    Join Date
    Apr 2002
    Posts
    2

    Re: VB3-VB6 generated tones; How to?

    Hi, I'm having the same problem as you. Do you find a solution?
    Please help me


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

Featured