+ Reply to Thread
Results 1 to 6 of 6

Is BEEP all there is??

  1. #1
    Gary's Student
    Guest

    Is BEEP all there is??

    Is there any functionality in VBA to produce tones of varying pitch ,
    intensity, and duration similar to the SOUND command in earlier versions of
    BASIC?
    --
    Gary's Student

  2. #2
    Jim Thomlinson
    Guest

    RE: Is BEEP all there is??

    Here is an API to play whatever wav file makes you happy.

    Option Explicit

    Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
    (ByVal lpszName As String, hModule As Long, ByVal dwFlags As Long) As Long


    Private Sub Test()
    PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
    End Sub

    Public Function PlayWavFile(WavFile As String) As String
    Const SND_ASYNC = &H1
    Const SND_FILENAME = &H20000
    PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
    PlayWavFile = ""
    End Function

    HTH

    "Gary's Student" wrote:

    > Is there any functionality in VBA to produce tones of varying pitch ,
    > intensity, and duration similar to the SOUND command in earlier versions of
    > BASIC?
    > --
    > Gary's Student


  3. #3
    Gary's Student
    Guest

    RE: Is BEEP all there is??

    Thanks, I guess the burden has shifted from programming Basic to make sounds
    to programming some other software to make .wav files?
    --
    Gary's Student


    "Jim Thomlinson" wrote:

    > Here is an API to play whatever wav file makes you happy.
    >
    > Option Explicit
    >
    > Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
    > (ByVal lpszName As String, hModule As Long, ByVal dwFlags As Long) As Long
    >
    >
    > Private Sub Test()
    > PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
    > End Sub
    >
    > Public Function PlayWavFile(WavFile As String) As String
    > Const SND_ASYNC = &H1
    > Const SND_FILENAME = &H20000
    > PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
    > PlayWavFile = ""
    > End Function
    >
    > HTH
    >
    > "Gary's Student" wrote:
    >
    > > Is there any functionality in VBA to produce tones of varying pitch ,
    > > intensity, and duration similar to the SOUND command in earlier versions of
    > > BASIC?
    > > --
    > > Gary's Student


  4. #4
    Tom Ogilvy
    Guest

    Re: Is BEEP all there is??

    In xl9x I believe Beep is all there is. In NT/XP/2003, you can control the
    internal speaker (which makes the beep)

    Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration
    As Long) As Long

    Sub Beep1()
    Dim num As Single
    Dim num1 As Long
    Dim numLoops As Single
    num = 10
    NumSeconds = 4 '<== duration
    numLoops = (NumSeconds * num * 2) / 2
    If numLoops < 1 Then
    numLoops = 1
    End If
    num1 = 1000 / (num * 2)

    For i = 1 To numLoops
    'DoEvents
    Beep 500, num1
    'DoEvents
    Beep 10000, num1
    'DoEvents
    Next
    End Sub


    The first argument is the frequency. You can change the 10000 (you can't
    hear that) to 1000 to get a different affect for example.

    --
    Regards,
    Tom Ogilvy

    "Gary's Student" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks, I guess the burden has shifted from programming Basic to make

    sounds
    > to programming some other software to make .wav files?
    > --
    > Gary's Student
    >
    >
    > "Jim Thomlinson" wrote:
    >
    > > Here is an API to play whatever wav file makes you happy.
    > >
    > > Option Explicit
    > >
    > > Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
    > > (ByVal lpszName As String, hModule As Long, ByVal dwFlags As Long) As

    Long
    > >
    > >
    > > Private Sub Test()
    > > PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
    > > End Sub
    > >
    > > Public Function PlayWavFile(WavFile As String) As String
    > > Const SND_ASYNC = &H1
    > > Const SND_FILENAME = &H20000
    > > PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
    > > PlayWavFile = ""
    > > End Function
    > >
    > > HTH
    > >
    > > "Gary's Student" wrote:
    > >
    > > > Is there any functionality in VBA to produce tones of varying pitch ,
    > > > intensity, and duration similar to the SOUND command in earlier

    versions of
    > > > BASIC?
    > > > --
    > > > Gary's Student




  5. #5
    Gary's Student
    Guest

    Re: Is BEEP all there is??

    Thank you both very much.
    --
    Gary's Student


    "Tom Ogilvy" wrote:

    > In xl9x I believe Beep is all there is. In NT/XP/2003, you can control the
    > internal speaker (which makes the beep)
    >
    > Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration
    > As Long) As Long
    >
    > Sub Beep1()
    > Dim num As Single
    > Dim num1 As Long
    > Dim numLoops As Single
    > num = 10
    > NumSeconds = 4 '<== duration
    > numLoops = (NumSeconds * num * 2) / 2
    > If numLoops < 1 Then
    > numLoops = 1
    > End If
    > num1 = 1000 / (num * 2)
    >
    > For i = 1 To numLoops
    > 'DoEvents
    > Beep 500, num1
    > 'DoEvents
    > Beep 10000, num1
    > 'DoEvents
    > Next
    > End Sub
    >
    >
    > The first argument is the frequency. You can change the 10000 (you can't
    > hear that) to 1000 to get a different affect for example.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Gary's Student" <[email protected]> wrote in message
    > news:[email protected]...
    > > Thanks, I guess the burden has shifted from programming Basic to make

    > sounds
    > > to programming some other software to make .wav files?
    > > --
    > > Gary's Student
    > >
    > >
    > > "Jim Thomlinson" wrote:
    > >
    > > > Here is an API to play whatever wav file makes you happy.
    > > >
    > > > Option Explicit
    > > >
    > > > Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
    > > > (ByVal lpszName As String, hModule As Long, ByVal dwFlags As Long) As

    > Long
    > > >
    > > >
    > > > Private Sub Test()
    > > > PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
    > > > End Sub
    > > >
    > > > Public Function PlayWavFile(WavFile As String) As String
    > > > Const SND_ASYNC = &H1
    > > > Const SND_FILENAME = &H20000
    > > > PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
    > > > PlayWavFile = ""
    > > > End Function
    > > >
    > > > HTH
    > > >
    > > > "Gary's Student" wrote:
    > > >
    > > > > Is there any functionality in VBA to produce tones of varying pitch ,
    > > > > intensity, and duration similar to the SOUND command in earlier

    > versions of
    > > > > BASIC?
    > > > > --
    > > > > Gary's Student

    >
    >
    >


  6. #6
    Jim Thomlinson
    Guest

    Re: Is BEEP all there is??

    Thanks Tom... One more API for me ply with...

    "Tom Ogilvy" wrote:

    > In xl9x I believe Beep is all there is. In NT/XP/2003, you can control the
    > internal speaker (which makes the beep)
    >
    > Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration
    > As Long) As Long
    >
    > Sub Beep1()
    > Dim num As Single
    > Dim num1 As Long
    > Dim numLoops As Single
    > num = 10
    > NumSeconds = 4 '<== duration
    > numLoops = (NumSeconds * num * 2) / 2
    > If numLoops < 1 Then
    > numLoops = 1
    > End If
    > num1 = 1000 / (num * 2)
    >
    > For i = 1 To numLoops
    > 'DoEvents
    > Beep 500, num1
    > 'DoEvents
    > Beep 10000, num1
    > 'DoEvents
    > Next
    > End Sub
    >
    >
    > The first argument is the frequency. You can change the 10000 (you can't
    > hear that) to 1000 to get a different affect for example.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Gary's Student" <[email protected]> wrote in message
    > news:[email protected]...
    > > Thanks, I guess the burden has shifted from programming Basic to make

    > sounds
    > > to programming some other software to make .wav files?
    > > --
    > > Gary's Student
    > >
    > >
    > > "Jim Thomlinson" wrote:
    > >
    > > > Here is an API to play whatever wav file makes you happy.
    > > >
    > > > Option Explicit
    > > >
    > > > Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
    > > > (ByVal lpszName As String, hModule As Long, ByVal dwFlags As Long) As

    > Long
    > > >
    > > >
    > > > Private Sub Test()
    > > > PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
    > > > End Sub
    > > >
    > > > Public Function PlayWavFile(WavFile As String) As String
    > > > Const SND_ASYNC = &H1
    > > > Const SND_FILENAME = &H20000
    > > > PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
    > > > PlayWavFile = ""
    > > > End Function
    > > >
    > > > HTH
    > > >
    > > > "Gary's Student" wrote:
    > > >
    > > > > Is there any functionality in VBA to produce tones of varying pitch ,
    > > > > intensity, and duration similar to the SOUND command in earlier

    > versions of
    > > > > BASIC?
    > > > > --
    > > > > Gary's Student

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1