|
-
Feb 12th, 2004, 06:05 AM
#1
Thread Starter
PowerPoster
Playing Midi files through a Resource file [RESOLVED]
I know you can load wav, ico, cur, bmp, avi, txt and use them in a resource file. Does anyone know how to load and play Midi files from a resource file?
Last edited by Keithuk; Oct 5th, 2004 at 01:36 PM.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Feb 12th, 2004, 07:52 AM
#2
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Feb 12th, 2004, 08:19 AM
#3
-= B u g S l a y e r =-
Hi Keithuk, I dont think you can load the midi data directly, think you have to temp save the info to disk when you want to play the midi.
I made a sample a long time ago for someone else at this forum.
hope that can get you going.
VB Code:
Private Sub StartSong()
Dim ret As Integer
Dim sBuffer As String
'sSong contains the name of the temp. file
sSong = App.Path & "\miditmp.mid"
'if it exists kill it
If Dir(sSong) <> "" Then Kill sSong
'get the file from the resource file
'and save it to disk
sBuffer = StrConv(LoadResData("TO_TOWN", "MDI"), vbUnicode)
Open sSong For Output As #1
Print #1, sBuffer
Close #1
'start playing the song
ret = mciSendString("open " & Chr(34) & sSong & Chr(34) & " type sequencer alias to_town", 0&, 0, 0)
ret = mciSendString("play to_town", 0&, 0, 0)
End Sub
-
Feb 12th, 2004, 08:21 AM
#4
-= B u g S l a y e r =-
u might want this too :
VB Code:
Private Sub StopSong()
Dim ret As Integer
'stop playing the song
ret = mciSendString("close to_town", 0&, 0, 0)
'delete the temp. midi file
If Dir(sSong) <> "" Then Kill sSong
End Sub
-
Feb 12th, 2004, 06:45 PM
#5
Thread Starter
PowerPoster
Playing Midi files through a Resource [RESOLVED]
Thanks Peet your code works a treat.
Last edited by Keithuk; Dec 5th, 2004 at 09:10 AM.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Oct 4th, 2004, 01:00 PM
#6
Fanatic Member
Question
Ok, I'm trying to get this code to work and im coming across a few problems that I don't understand.
I've loaded a midi into a resource file, it says that It's type is "CUSTOM" and It's ID is 101. So I took the code and replaced all instances of "TO_TOWN" with 101 and all instances of "MDI" with "CUSTOM". I'm not sure if that's what I was supposed to do or not.
I also need to know what "mciSendString" is. I just get a compile error. Thanks.
-
Oct 4th, 2004, 02:17 PM
#7
you need the MCI API. google it or search the forums.
-
Oct 4th, 2004, 06:02 PM
#8
Fanatic Member
Sorry, this will sound really dumb, but what exactly is an API?
-
Oct 5th, 2004, 01:30 PM
#9
Thread Starter
PowerPoster
Application Programming Interface.
It extracts information out of dll files normally.
e.g.
Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
See if you have "Program Files\Microsoft Visual Studio\Common\Tools\Winapi\APILOAD.EXE" installed.
Last edited by Keithuk; Oct 5th, 2004 at 01:34 PM.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
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
|