Posted to microsoft.public.excel.programming
|
|
Excel XP x Playing Sounds
Thank you very much! it's working!
Also: would it be possible to play a two-frequency tone with the Beep
function?
Thank you
Paulo Borelli.
"Tom Ogilvy" wrote in message
...
Here is a possibility that you might be able to adapt to your needs. This
is an old post I made:
From: Tom Ogilvy )
Subject: N beeps per second
View: Complete Thread (6 articles)
Original Format
Newsgroups: microsoft.public.excel.programming
Date: 2003-01-02 20:11:28 PST
I checked this in the API reference. The below will work for Win NT, Win
2000 and Win XP, but in Win 95/ Win 98/ and ME, the two arguments are
ignored - so it won't work in those versions.
Regards,
Tom Ogilvy
Tom Ogilvy wrote in message
news:#0KbU5qsCHA.1776@TK2MSFTNGP09...
This worked in Windows 2000
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 = 0.5
NumSeconds = 4
numLoops = (NumSeconds * num * 2) / 2
If numLoops < 1 Then
numLoops = 1
End If
num1 = 1000 / (num * 2)
For i = 1 To numLoops
Beep 500, num1
Beep 10000, num1
Next
End Sub
The arguments to Beep are Frequency and Duration. 1000 is 1 second for
duration. I beep twice - one with in an audible frequency (500 to 3000)
and
once with an inaudible frequency. Num represents the number of times
per
second (you can add an input box to get this). If the number of times
a
second is 1, I would see the sound as being half a second since it must
be
accompanied by an addition half second of quiet. Like wise, if number
per
second is 2, the duration would be a quarter second (quarter tone,
quarter
quiet, quarter tone, quarter quite). Anyway, I think that is the way it
behaves.
Regards,
Tom Ogilvy
"Jason Kanter" wrote in message
news:uXHH2zgsCHA.2448@TK2MSFTNGP09...
I need to make a macro that will force Excel to beep (or make some
sound,
which I would like to choose) x times per second. The x might be
anything
from 0.5 to 20 (though an upper limit of 15 would also work for my
purposes). I would want to click a button, have a dialog box ask
how
many
per second, enter the number and have the ticking start and
continue
until I
hit escape or click a Stop button. (This is for use in piano
tuning.)
Suggestions? /Thanks
--
..........
. jason kanter . .
...............................
"Paulo de Arruda Borelli" wrote in message
...
I need to play some very simple sounds on Excel XP. All that I need is
to
supply Excel with a frequency and a duration. That's all. How can this
be
done? The Visual Basic Help under Excel tells me that the sound
functions
have been removed from Excel! The only one that remained is beep, which
is
far from what I need.
Thank you!
Paulo.
|