http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programming a MIDI Player



need a password to access Site : http://www.iquebec.com/Beastudio   ?
----- Original Message -----
From: Seb
Sent: Wednesday, September 08, 1999 9:27 AM
Subject: Programming a MIDI Player

Hello everybody ,
 
I'm looking to code a MIDI Player using the low-level API of Windows ( WINMM.DLL and Stream Buffer).
In the SDK of DirectX 5, there's an example called MSTREAM and I only want to do almost the same
thing, but instead of translating MIDI File during playing, my own file is ALREADY translated. 
So I only have to read part of my own file (THIS WORKS), put in into a buffer and then send 
it to the MIDI API. But this don't work ! I need help on that !! 
 
Here is the small code I use for initialization :
 
 
"
// Var and definitions
 
#define    MAX_STREAMBUF_SIZE = 4096;

HMIDISTRM   My_MIDIDevice;
MIDIHDR       MIDIBuf;
MIDIPROPTIMEDIV   My_MIDIProp 
UINT             midiDeviceID = -1; 
 
 
// Code
 
midiStreamOpen( &My_MIDIDevice, &midiDeviceID,  
                (DWORD) 1, (DWORD) &My_MIDIProc, (DWORD) 0, CALLBACK_FUNCTION); 
MIDIBuf.dwBufferLength = MAX_STREAMBUF_SIZE;
MIDIBuf.lpData = (BYTE *) GlobalAllocPtr(GHND, MAX_STREAMBUF_SIZE ); 
 

ZeroMemory( &My_MIDIProp, sizeof(My_MIDIProp) );
My_MIDIProp.cbStruct = sizeof(My_MIDIProp);
My_MIDIProp.dwTimeDiv = MyMidAudio.TimeDivision;
midiStreamProperty(My_MIDIDevice, (LPBYTE) &My_MIDIProp, MIDIPROP_SET | MIDIPROP_TIMEDIV);
 

// Here I fill my Buf "lpData" with MIDI data like that (3 DWORD per MIDI event) :
//   the event (1 DWORD) , the time stamp (1 DWORD) , the Stream ID (1 DWORD)
 

midiOutPrepareHeader( (HMIDIOUT) My_MIDIDevice, &MIDIBuf, sizeof(MIDIHDR) );
midiStreamOut( My_MIDIDevice, &MIDIBuf, sizeof(MIDIHDR) );
midiStreamRestart( My_MIDIDevice );

"
 
 
There is one thing that I'm not sure :
 1)  What must the format of the buffer be ? I fill it in this order : the event (it seem to be always 0 ??? ?), the time stamp,
      and the Stream ID. Moreover, I don't know what the Stream ID is. Is it the ID of the MIDI Device ? 
 
 
 
Thank you for your help !
See You Soon !
SEB