   DirectMusic MIDI issue
  Hello,I''m relatively new to both DirectMusic and this board and I have a question. I look on the board and haven''t found anything that helps my issue, so I hope I''m not repeating something. Anyway, here it goes...I have been writting (what I thought to be) a simple DM midi player class in VC++. I have two test songs. The object of the class is, I store the two music files names in the class and I run a function that will play them like a play list (one emmidiately after the other stops).Anyway, always, the first song plays perfectly. However, when it gets to the second song, the music does not play right. It seems to me that I am, somehow, not getting the full "band" for the second song. When I play the second song first, it works fine. I think I might not be closing my segment properly?Here''s how I stop the music:DMPerformance->Stop(DMSegment, NULL, 0, 0);if (FAILED(DMSegment->Unload(DMPerformance)))return DMIDI_ERROR;if (FAILED(DMLoader->ReleaseObjectByUnknown(DMSegment)))return DMIDI_ERROR;DMSegment->Release();DMSegment = NULL;Am I doing anything wrong? Does someone have any ideas?Thank you in advance for any help you could give me!!   --occamrzr 
  When you say you're not getting the full band, does that mean you only hear some instruments but not others? You may not be using enough audio channels. If that's not the case, post some code on how you initialize the audio system, initialize a segment, and play a segment, I think I may know what's wrong (Remember to use the "source" tags when you post it here). And let me know if you're using audio paths other than the default one.I'm also looking at your code to stop the music. If you're simply stopping a sound but not closing the application, there isn't a need to call anything other than Stop().   [edited by - Weston on February 15, 2004 12:21:01 AM];  Hello,Yes, I''m only hearing some instruments but not others. Please, keep in mind that this problem ONLY happens on the second MIDI and all others following. The first MIDI plays fine. Also, I have switched the MIDIs around in the play order. The one that doesn''t play right as the second MIDI played, sounds fine when it''s the first.As to the code... I''m only using a default channel (remember, I''m pretty new to DM, so I know very little beyond the information in books I already have on it) as far as I know. //Following is my class constructor. Only called once, obviouslydreamer_midi::dreamer_midi(HWND hwnd){SongList = NULL;CurrentSong = NULL;NumSongs = NULL;PlayStyle = DMIDI_PLAY_ALL | DMIDI_PLAY_INORDER | DMIDI_PLAY_NOLOOP;SongPlaying = false;DSInit = false;// DirectSound componentDSound = NULL;// DirectMusic Performance, loader, and segment objectsDMPerformance = NULL;DMLoader = NULL;DMSegment = NULL;CoInitialize(0);if (FAILED(DirectSoundCreate8(NULL, &DSound, NULL)))return;DSInit = true;DSound->SetCooperativeLevel(hwnd, DSSCL_NORMAL);// Create the DirectMusic loader objectCoCreateInstance(CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, IID_IDirectMusicLoader8, (void**)&DMLoader);// Create the DirectMusic performance objectCoCreateInstance(CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC, IID_IDirectMusicPerformance8, (void**)&DMPerformance);// Initialize the performance with the standard audio path.// This initializes both DirectMusic and DirectSound and // sets up the synthesizer. DMPerformance->InitAudio(NULL, NULL, hwnd, DMUS_APATH_SHARED_STEREOPLUSREVERB, 128, DMUS_AUDIOF_ALL, NULL);}//Next is the function I call to play the MIDI songsint dreamer_midi::playMIDI(int SongID){if (SongID < 0 || SongID >= NumSongs)return DMIDI_ERROR;_song* Temp = GetSong(SongID);DMUS_OBJECTDESC dmod;// Get the objectZeroMemory(&dmod, sizeof(DMUS_OBJECTDESC));dmod.dwSize = sizeof(DMUS_OBJECTDESC);dmod.guidClass = CLSID_DirectMusicSegment;dmod.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_FILENAME | DMUS_OBJ_FULLPATH;mbstowcs(dmod.wszFileName, Temp->SongFile, MAX_PATH);if(FAILED(DMLoader->GetObject(&dmod, IID_IDirectMusicSegment8, (LPVOID*)&DMSegment)))return DMIDI_ERROR;// Setup MIDI playingif(FAILED(DMSegment->SetParam(GUID_StandardMIDIFile, 0xFFFFFFFF, 0, 0, NULL)))return DMIDI_ERROR;// Download the bandif(FAILED(DMSegment->Download(DMPerformance)))return DMIDI_ERROR;// Set to loop foreverDMSegment->SetRepeats(0);// Play on default audio pathDMPerformance->PlaySegmentEx(DMSegment, NULL, NULL, 0, 0, NULL, NULL, NULL);DMPerformance->AddNotificationType(GUID_NOTIFICATION_PERFORMANCE);SongPlaying = true;CurrentSong = Temp;Temp->Played = true;return DMIDI_OK;}//Finally, this is how I stop a song and attempt to clear it//to load in the next song.int dreamer_midi::stopMIDI(){if (!SongPlaying)return DMIDI_OK;DMPerformance->RemoveNotificationType(GUID_NOTIFICATION_PERFORMANCE);DMPerformance->Stop(DMSegment, NULL, 0, 0);if (FAILED(DMSegment->Unload(DMPerformance)))return DMIDI_ERROR;if (FAILED(DMLoader->ReleaseObjectByUnknown(DMSegment)))return DMIDI_ERROR;DMSegment->Release();DMSegment = NULL;SongPlaying = false;return DMIDI_OK;}Please note, the songs stored in the class are NOT actually the song data, just a path to the midi file.Again, thank you very much for any help, --occamrzr ;  Everything looks fine to me in the code, so my guess (and I''m not 100% sure on this) is that you''re removing instruments that were downloaded to the performance with a call to Unload(), so the next time you try to play a file, the instruments aren''t there. But that doesn''t make sense though when I look at the code, because you''re Downloading new instruments when you play another file, so I wouldn''t think it would be a problem. I guess it would have to be the order in which things were created. That''s about as much as I can suggest right now.   ---n00bHaTeR: i got fired todaygamer2000: lol!noobHaTeR: 