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
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
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
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
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
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
>
>
>
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
>
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks