|
-
Sep 30th, 2000, 01:04 PM
#1
Thread Starter
Lively Member
Please help a poor guy with your knowledge
I want a short sound to be repeated continuously but I want this rhythmical, in time. I tried this with a timer control but that doesn't work like I want it (sometimes it goes fast than slow...). Does somebody know how I can play the sound with exactly the same time between every beat?
(PS: I'm using DirectSound to play the wav file)
Thanx
-
Sep 30th, 2000, 01:23 PM
#2
Use the Timer control to reduce the variance on the elapsed time by using a variable within the Timer to measure the actual time elapsed more accurately, i.e.
Code:
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_ASYNC = &H1
Private Const SND_NOWAIT = &H2000
Private Sub Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
Static tTimer As Single
If tTimer = 0 Then tTimer = Timer
If Timer - tTimer >= 1 Then
Call sndPlaySound("C:\Windows\Media\Start.wav", SND_ASYNC Or SND_NOWAIT)
tTimer = Timer
End If
End Sub
-
Sep 30th, 2000, 01:39 PM
#3
Thread Starter
Lively Member
I tried Aaron Young's code but it seems to go fast and slow too. When I play a sound the program waits until the sound is completly finished, when I try to play the sound with DirectSound it isn't in time too.
And something else, when I play sounds with DirectSound I alway get a click between the sounds. Does anybody know how to fix that problem?
-
Sep 30th, 2000, 02:00 PM
#4
Thread Starter
Lively Member
Help me please I realy need the code to do this!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|