Qbasicnews.com
July 07, 2020, 08:57:48 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Problems looping a MIDI file with mcisendstring.  (Read 2590 times)
Vance
Member
*
Posts: 40



WWW
« on: February 11, 2005, 08:28:12 PM »

The following code, which is a modified version of the MCI Helper that comes with FB v.11b, was my attempt to make a MIDI file loop. It doesn't work:
Code:

' Modified MCI helper.
' By Vance Velez.


'  *** Function Declarations. ***

declare function PlayMidi(filename as string, musicID as string) as integer
declare function CheckMidi(musicID as string) as integer
declare function StopMidi( ) as integer

'$include: 'win\mmsystem.bi'

'  *** Initialize MIDI. ***
mciSendString("open sequencer",byval NULL,0,0)

'  *** Play MIDI. ***
PlayMidi("c:\vance\music\mario.mid", musicID$)

do
   a$=inkey$  
   CheckMidi(musicID$)
   if a$="a" then mciSendString("play mymidi from 0",byval NULL,0,0)
loop until a$=" "

'  *** Close MIDI. ***
mciSendString("close sequencer",byval NULL,0,0)

end

'  *** Midi Routines. ***

function PlayMidi(filename as string, musicID as string) as integer
   
   if(mciSendString("open "+filename+" alias mymidi",byval NULL,0,0)<>0) then
    winmmPlayMidi = 0
    exit function
end if  
   
   musicID="A"  
   mciSendString("status mymidi mode", musicID, 5, 0)      
   PlayMidi=mciSendString("play mymidi",byval NULL,0,0) = 0    
   
end function

function CheckMidi(musicID as string) as integer

   retStr$="A"
   mciSendString("status mymidi mode",retStr$,5,0)      
   ?"RET: ";retStr$;" ID: ";musicID;  
   if retStr$=musicID then
      ?" ACTIVE"      
      PlayMidi("c:\vance\music\mario.mid", musicID)
      mciSendString("play mymidi from 0",byval NULL,0,0)
   else
      ?
   end if
   CheckMidi=0  
end function

function StopMidi() as integer    
    mciSendString("stop mymidi",byval NULL,0,0)
    StopMidi=mciSendString("close mymidi",byval NULL,0,0)=0    
end function

' *** End of Code. ***


Instead, it plays through the MIDI once and goes silent after that. What am I doing wrong? Sad
Logged

eese Witherspoon is so pretty
Her and Ryan Philippe make such a cute couple I think
My dream is that QB and all OSes share such a wonderful relationship
V Planet! QB Magazine
http://www.vplanetmag.com/
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!