| | |
wav file problem
![]() |
•
•
Join Date: Jun 2005
Posts: 70
Reputation:
Solved Threads: 2
Hi All,
I wrote a guitar-related program, one of the options is a guitar tuner which works fine, each note is in a separate 3second wav file. However, when I tried to write an option to play a full chord i.e. play 6 files, one after the other, only the last one plays.
What I need, I think, is a way to delay starting the next file until the current one has finished. I have been using VB for a while, but have not used API's until this program, so I don't know much about them. I don't want code written for me, just need pointing in the right direction, maybe a tutorial that doesn't give me a headache trying to follow it. Can you help?
I wrote a guitar-related program, one of the options is a guitar tuner which works fine, each note is in a separate 3second wav file. However, when I tried to write an option to play a full chord i.e. play 6 files, one after the other, only the last one plays.
What I need, I think, is a way to delay starting the next file until the current one has finished. I have been using VB for a while, but have not used API's until this program, so I don't know much about them. I don't want code written for me, just need pointing in the right direction, maybe a tutorial that doesn't give me a headache trying to follow it. Can you help?
Well I would suggest getting the length of the wav file.... how long it plays in seconds, and then stick a timer control on your form, with it's interval set to 1000. That way the timer executes every second, and you set a static or public variable to increment every second. If the variable size is the same as (use greater than or equal to) the size of the file in seconds, don't try to play the next one, otherwise just exit sub.... that's how I would go about doing it.
•
•
Join Date: Jun 2005
Posts: 70
Reputation:
Solved Threads: 2
Thanks for that, Comatose,
I did toy with that one, but I guess I'm not thinking clearly today, people keep interrupting me. I was trying to do it with the Timer function and got confusing results so I gave up and shot off at a tangent. Deja vu
However, I'll get back on it with your suggestion. Let you know how I get on. Thanks again.
I did toy with that one, but I guess I'm not thinking clearly today, people keep interrupting me. I was trying to do it with the Timer function and got confusing results so I gave up and shot off at a tangent. Deja vu
However, I'll get back on it with your suggestion. Let you know how I get on. Thanks again.
•
•
Join Date: Jun 2005
Posts: 70
Reputation:
Solved Threads: 2
Hi again,
just for the benefit of other viewers, here's a version which works - in this particular case there's no need to get the length of the wav files, since they are all the same size, the length is set with the Timer control interval property.
Thanks again Comatose for refocussing me.
Option Explicit
Dim NextNote As Integer
Private Const SND_ASYNC = &H1
Private Const SND_FILENAME = &H20000
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Sub cmdEchord_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
NextNote = NextNote + 1
Select Case NextNote
Case Is = 1
PlaySound "C:\ChordWavs\E6.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
Case Is = 2
PlaySound "C:\ChordWavs\E5.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
Case Is = 3
PlaySound "C:\ChordWavs\E4.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
Case Is = 4
PlaySound "C:\ChordWavs\E3.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
Case Is = 5
PlaySound "C:\ChordWavs\E2.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
Case Is = 6
PlaySound "C:\ChordWavs\E1.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
Timer1.Enabled = False
NextNote = 0
End Select
End Sub
just for the benefit of other viewers, here's a version which works - in this particular case there's no need to get the length of the wav files, since they are all the same size, the length is set with the Timer control interval property.
Thanks again Comatose for refocussing me.
Option Explicit
Dim NextNote As Integer
Private Const SND_ASYNC = &H1
Private Const SND_FILENAME = &H20000
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Sub cmdEchord_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
NextNote = NextNote + 1
Select Case NextNote
Case Is = 1
PlaySound "C:\ChordWavs\E6.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
Case Is = 2
PlaySound "C:\ChordWavs\E5.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
Case Is = 3
PlaySound "C:\ChordWavs\E4.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
Case Is = 4
PlaySound "C:\ChordWavs\E3.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
Case Is = 5
PlaySound "C:\ChordWavs\E2.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
Case Is = 6
PlaySound "C:\ChordWavs\E1.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
Timer1.Enabled = False
NextNote = 0
End Select
End Sub
![]() |
Similar Threads
- RE: reading .wav file and putting ito inot the array (C)
- help executing a .wav file with php code (PHP)
- How do I play a .wav file from Resources? (VB.NET)
- Play a .wav file (Java)
- Create .wav file with C# (C#)
- Append to beginning of file (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Adding Horizondal Scroll bar to Combo Box
- Next Thread: Collecting Statistics from fields
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






