* Position Acquisition *

BlitzMax Forums/BlitzMax Programming/* Position Acquisition *

dw817(Posted 2013) [#1]
I have this code:

Extern "win32"
Function mciSendString(pstrCommand$z,lpstrReturnStr$z,wReturnLen:Int,CallBack:Int)="mciSendStringA@16"
End Extern

Which can indeed play MIDI:

' >> PLAYMID - PLAY MIDI FILE
Function playmid(t$)
mci "open "+t$+".mid alias mid"
mci "play mid"
EndFunction

' >> STOPMID - STOP PLAYING MID FILE
Function stopmid()
mci "close mid"
EndFunction

' >> MCI - DO A MCI COMMAND
Function mci(t$)
Local a=mcisendstring(t$,"",0,0)
EndFunction


, but how do I accomplish:

Stat$=mci$("status mid position")

Where mid is an open audio file and stat$ returns the digit position of it ?

Thanks in advance !


col(Posted 2013) [#2]
Hiya,

I'm not sure on the syntax of the mci messages but this may help getting you in the right direction of receiving messages and handling errors too...

Extern "win32"
Function mciSendString(pstrCommand$z,lpstrReturnStr:Byte Ptr,wReturnLen:Int,CallBack:Int)="mciSendStringA@16"
Function mciGetErrorString(fdwError,lpszErrorText:Byte Ptr,cchErrorText)="mciGetErrorStringA@12"
End Extern

'Which can indeed play MIDI:

' >> PLAYMID - PLAY MIDI FILE
Function playmid(t$)
 mci "open "+t$+".mid alias mid"
 mci "play mid"
EndFunction

' >> STOPMID - STOP PLAYING MID FILE
Function stopmid()
 mci "close mid"
EndFunction

' >> MCI - DO A MCI COMMAND
Function mci(t$)
 Local retmsg:Byte Ptr = MemAlloc(128)
 Local errmsg:Byte Ptr = MemAlloc(128)
 Local a=mcisendstring(t$,Varptr retmsg,0,0)

 mciGetErrorString(a,errmsg,128)
 Print
 Print "Sending Msg: '"+t$+"'"
 Print "Return Value: '"+a+"' : "+String.FromCString(errmsg)
 Print "Return Msg: '"+String.FromCString(retmsg)+"'"

 MemFree(retmsg)
 MemFree(errmsg)
EndFunction

playmid "test"

mci "set mid time format msf"
mci "status mid position"
Delay 20000

stopmid


The docs say to use the 'set' command before using 'status' but I get an error on the 'set' command which looks returned when trying to use the 'status' command. I might have the wrong syntax though.

Hope it helps a little for you figuring it out ;-)


dw817(Posted 2013) [#3]
That's better than what I have, I appreciate it !

Unfortunately, it's still not getting the results I want. I need it to display the MIDI position, I need MCI to give back string arguments so I can determine when I have reached the end of playing a MIDI so I can start it over again from the beginning, or to give me a numeric value for the middle of the song so I can play from that position.

Here is the current work:

http://www.mediafire.com/?mkelh95zvqosylf

If someone can help at this point I would sure appreciate it.


col(Posted 2013) [#4]
Here's an old link of some code that should be really easy to port across to BlitzMax, originally written in one of the other Blitz languages.

HERE

Any probs feel free to ask.


dw817(Posted 2013) [#5]
I'm not at all familiar with Blitz-Basic. Could you please post a true Blitz-Max working example for MCI() , Dave ?

Thanks ...


col(Posted 2013) [#6]
Specifically for that code... a few small symbols aside and the language functions used are practically the same. How well do you the BlitzMax language? Have you had a go at porting any of it yet? If so, where is it that you got stuck?


dw817(Posted 2013) [#7]
I know Blitz Max fairly well, it's Blitz Basic I have had no experience in. I definitely don't know how to port one language to another unless it's simple BASIC involving mathematical calculations.