Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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 Zipster   Crossbones+   -  Reputation: 769

Like
Likes
Like

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

DMUS_OBJECTDESC ObjDesc; 
HRESULT hr;
IDirectMusicSegment* pSegment = NULL;
 
// get current working directory
char szDir[_MAX_PATH];
WCHAR wszDir[_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 );

ObjDesc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_FILENAME;
 
// 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))
   return(0);
 
// 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))
   return(0);
  
// 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(0);

// 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

Sponsor:

#2 LJG   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 August 2000 - 08:38 PM

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

zero
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.



PARTNERS