Jump to content

  • Log In with Google      Sign In   
  • Create Account

Playing the WHOLE midi file

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1   Members   


Posted 28 August 2000 - 02:11 PM

I am using Andre LaMothe's code to play a midi file, but for some reason not all of the tracks play, only like the main track and some auxilery tracks. Big bummer: the drum track doesn't play. When i execute his example apps, it plays fine (maybe its the midi file itself?), but when i copy the code and use it myself, it doesn't work. Here's the code for loading and playing the midi: Loading:
IDirectMusicSegment* LoadMIDISegment(IDirectMusicLoader* pLoader, 
                                     WCHAR *wszMidiFileName )
// this function loads a midi segment off disk

IDirectMusicSegment* pSegment = NULL;
// get current working directory
char szDir[_MAX_PATH];
if(_getcwd( szDir, _MAX_PATH ) == NULL)
  return NULL;
  } // end if

// convert to wide characters
MULTI_TO_WIDE(wszDir, szDir);

// set the search directory
hr = pLoader->SetSearchDirectory(GUID_DirectMusicAllTypes,wszDir, FALSE);

if (FAILED(hr)) 
   return NULL;
   } // end if
// setup object description
ZeroMemory(&ObjDesc, sizeof(DMUS_OBJECTDESC));
ObjDesc.dwSize = sizeof(DMUS_OBJECTDESC);
ObjDesc.guidClass = CLSID_DirectMusicSegment;
wcscpy(ObjDesc.wszFileName, wszMidiFileName );

// load the object and query it for the IDirectMusicSegment interface
// This is done in a single call to IDirectMusicLoader::GetObject
// note that loading the object also initializes the tracks and does 
// everything else necessary to get the MIDI data ready for playback.

hr = pLoader->GetObject(&ObjDesc,IID_IDirectMusicSegment, (void**) &pSegment);

if (FAILED(hr))
// ensure that the segment plays as a standard MIDI file
// you now need to set a parameter on the band track
// Use the IDirectMusicSegment::SetParam method and let 
// DirectMusic find the trackby passing -1 (or 0xFFFFFFFF) in the dwGroupBits method parameter.

hr = pSegment->SetParam(GUID_StandardMIDIFile,-1, 0, 0, (void*)dm_perf);

if (FAILED(hr))
// This step is necessary because DirectMusic handles program changes and 
// bank selects differently for standard MIDI files than it does for MIDI 
// content authored specifically for DirectMusic. 
// The GUID_StandardMIDIFile parameter must be set before the instruments are downloaded. 

// The next step is to download the instruments. 
// This is necessary even for playing a simple MIDI file 
// because the default software synthesizer needs the DLS data 
// for the General MIDI instrument set
// If you skip this step, the MIDI file will play silently.
// Again, you call SetParam on the segment, this time specifying the GUID_Download parameter:

hr = pSegment->SetParam(GUID_Download, -1, 0, 0, (void*)dm_perf);

if (FAILED(hr))

// return the pointer
return pSegment;
} // end LoadSegment
Playing: Basically, IDirectMusicPerformance:: PlaySegmant() ^ gotta watch out for ! Edited by - Zipster on 8/28/00 8:12:16 PM

#2   Members   


Posted 28 August 2000 - 08:38 PM

Are you sure the MIDI channels are set correctly on the MIDI file?

static music

Edited by - LJG on August 29, 2000 5:49:01 PM

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.