Re: Beep Beep
- From: "Jim Mack" <jmack@xxxxxxxxxxxxxxx>
- Date: Tue, 24 Mar 2009 11:11:43 -0400
Rick Raisley wrote:
Jim, I notice when using your code that calling the sound does not
wait until it is done playing. I looped together some rising
sounds, each 200 ms long, expecting to hear a steadily increasing
frequency. But it kind of muddled together. Apparently, calling a
200 ms (or 1000 ms, whatever) sound returns to the program
immediately, while the sound continues to play. Now, that's not
unexpected, but it means you can't string several play commands
together, and have it sound like a "song".
I could add a Sleep command, to delay the duration of the note, but
my guess is that it will result in no sound playing for a brief
period. Still, that might be fine.
Is there anything within the DLL that could optionally keep code
from returning to the calling routine until the sound is done
playing?
Internally, the DLL uses PlaySound with the SND_ASNYC flag, which is
normally what you want. I could add an option to play sync or async,
but it's just as easy for you to do it. The .Play method is mainly a
fillip - the real power is in the .Generate method.
First, Declare PlaySound yourself, and the SND_MEMORY flag.
Then, use the DLL to .Generate each sound, and save the returned
buffers in local byte arrays. See the file save example code for
inspiration.
When you want to play a series of sounds, make your own calls to
PlaySound using the stored buffers in any sequence. You can use a
Variant array to hold a series of byte arrays, BTW.
Also, I believe PlaySound works just as well with a series of
concatenated WAV images. If so you could just string out a set of
..SoundBuffers into one big array.
Private Const SND_ASYNC As Long = 1 ' leave this out
Private Const SND_MEMORY As Long = 4
Private Declare Function PlaySound Lib "winmm" _
Alias "PlaySoundA" (ByRef snd As Byte, _
ByVal hFil As Long, ByVal flags As Long) As Long
PlaySound bytBuffer(0), 0, SND_MEMORY 'Or SND_ASYNC
--
Jim Mack
Twisted tees at http://www.cafepress.com/2050inc
"We sew confusion"
.
- Follow-Ups:
- Re: Beep Beep
- From: Rick Raisley
- Re: Beep Beep
- References:
- Beep Beep
- From: Lorin
- Re: Beep Beep
- From: Jim Mack
- Re: Beep Beep
- From: Abhishek
- Re: Beep Beep
- From: Jim Mack
- Re: Beep Beep
- From: Abhishek
- Re: Beep Beep
- From: Jim Mack
- Re: Beep Beep
- From: Rick Raisley
- Beep Beep
- Prev by Date: Fax messages simulation
- Next by Date: The application failed to initialize properly
- Previous by thread: Re: Beep Beep
- Next by thread: Re: Beep Beep
- Index(es):
Relevant Pages
|
Loading