Sorry I wasn't more helpful. I've been swamped. Todor -----Original Message----- From: directmusic-bounce@xxxxxxxxxxxxx [mailto:directmusic-bounce@xxxxxxxxxxxxx] On Behalf Of Abhijit Patait Sent: Friday, May 14, 2004 5:54 PM To: directmusic@xxxxxxxxxxxxx Subject: [directmusic] Re: Playing multiple MIDI segments, please help Ok, it looks like this was a weird problem. After a LOT of painful (and unsuccessful) debugging, I finally gave up and ended up playing the two MIDI files on separate audiopaths. Earlier, I was trying to play both MIDI files on the same audiopath and that was most likely causing some PChannel conflicts. Anyways, thanks to all of you all for help. Abhijit Abhijit Patait <abhijit_patait@xxxxxxxxx> wrote: Further experimentation in my saga of playing multiple MIDI files revealed something very interesting (and confusing). I started changing the parameters in the MIDI files that I was using. I discovered that if the primary segment's MIDI file uses patch 0, then the secondary segment does not mute the primary segment (both play simultaneously, as I expect). As soon as I change the instrument (patch) on primary segment to anything other than patch 0, the secondary segment causes it to mute. This is really strange. I have also tried inserting bank select (LSB = 0, MSB = 0) controller messages before patch change, but no effect! Here are the text versions of the MIDI files I am using (each file is MIDI format 1 file, with two tracks). File 1 (primary): MFile 1 2 480 MTrk 0:0:0 Tempo 500000 // 120 bpm 0:0:0 KeySig 0 major 0:0:0 TimeSig 4/4 48 8 2:3:0 Meta TrkEnd TrkEnd MTrk 0:0:0 Meta TrkName "0: Acoustic Grand" 0:0:3 ProgCh ch=1 prog=0 // Cannot chang this to prog=x (where x != 0) 0:0:4 On ch=1 note=c5 vol=105 0:0:239 Off ch=1 note=c5 vol=0 0:0:240 On ch=1 note=d5 vol=80 0:0:479 Off ch=1 note=d5 vol=0 // A few more note on/off messages 2:3:0 Meta TrkEnd TrkEnd File 2 (secondary, aligned): MFile 1 2 480 MTrk 0:0:0 Tempo 500000 // 120 bpm 0:0:0 KeySig 0 major 0:0:0 TimeSig 4/4 48 8 2:3:0 Meta TrkEnd TrkEnd MTrk 0:0:0 Meta TrkName "54: Oohs" 0:0:3 ProgCh ch=3 prog=54 0:0:4 On ch=3 note=c5 vol=105 0:0:239 Off ch=3 note=c5 vol=0 0:0:240 On ch=3 note=d5 vol=80 0:0:479 Off ch=3 note=d5 vol=0 // A few more note on/off messages 2:3:0 Meta TrkEnd TrkEnd This behavior is really strange, and I believe that I am doing something fundamentally incorrect. Any clues? -Abhijit Abhijit Patait wrote: Scott I am not playing any segment as controlling segment. As I mentioned in my previous post, both segments are created from MIDI files, and use different patches from default bank (on different MIDI channels). Why would the instruments get unloaded if they are played from the default bank? Aren't the instruments in the default bank "always" loaded? Thank you -Abhijit "Scott Morgan (Volt)" wrote: Doesn't look like you were using controlling segments. It sounds like the primary's instrument might be getting unloaded for some reason. -Scott Morgan This posting is provided "AS IS" with no warranties, and confers no rights. -----Original Message----- From: directmusic-bounce@xxxxxxxxxxxxx [mailto:directmusic-bounce@xxxxxxxxxxxxx] On Behalf Of Scott Morgan (Volt) Sent: Wednesday, May 12, 2004 6:33 PM To: directmusic@xxxxxxxxxxxxx Subject: [directmusic] Re: Playing multiple MIDI segments, aligned Is the secondary segment a controlling segment? That would force the patches in the primary to change to whatever was in the secondary segment's band. If you need to play a controlling segment, either make sure the band is the same on those channels, or just delete that pchannel from the controlling segment's band. -Scott Morgan This posting is provided "AS IS" with no warranties, and confers no rights. -----Original Message----- From: directmusic-bounce@xxxxxxxxxxxxx [mailto:directmusic-bounce@xxxxxxxxxxxxx] On Behalf Of Abhijit Patait Sent: Wednesday, May 12, 2004 6:12 PM To: directmusic@xxxxxxxxxxxxx Subject: [directmusic] Re: Playing multiple MIDI segments, aligned I played with the PlaySegmentEx(...) flags a little more and observed the following. I loaded the first MIDI file (which contains a few note on/off messages on MIDI channel 1, patch 54), as a DM segment, and played it as a primary segment (no flags set). Next, I loaded the second MIDI file (which contains the same note on/off messages, but on MIDI channel 3, patch 0) as a secondary segment, and with flags (DMUS_SEGF_SECONDARY | DMUS_SEGF_SEGMENTEND | DMUS_SEGF_ALIGN | DMUS_SEGF_VALID_START_BEAT). =3D20 I observed that the secondary segment's instrument somehow "overwrites" the primary segment's instrument. That is, as soon as the secondary segment starts playing, the primary segment stops making any sound. Further (and this could be an important clue), stopping secondary segment mid-way (without touching the primary segment) causes the primary segment to be played on the instrument with patch 0 (that of the secondary segment). This is really strange. =3D20 I hope this observation will help experts on this list provide me with some insight into what may be happening. =3D20 Thanks again Abhijit Abhijit Patait wrote: Hello Todor Thank you for responding. I am setting the flag DMUS_SEGF_SECONDARY for the second segment (second MIDI file). If you look at the code I sent earlier, the first segment uses all default flags (which I assume, means primary) and the second segment uses the following flags: DMUS_SEGF_SECONDARY | DMUS_SEGF_SEGMENTEND | DMUS_SEGF_ALIGN | DMUS_SEGF_VALID_START_BEAT I don't understand why the first one gets muted. Also, I tried the exact same thing with Jones application from your book, with same results. The display window in Jones, however, shows that both segments are playing (it shows two moving rectangles - playing in parallel) but I hear only one. Is there some fundamental limitation with DirectMusic that one cannot play two MIDI files simultaneously? Or I am missing something? Thanks for your help Abhijit PS: I am attaching the MIDI files (along with corresponding text files explaining the contents of those MIDI files) that I am trying to play. Todor Fay wrote: In this code, you set the segment default flags, but I don't think DMUS_SEGF_SECONDARY is available as a default flag. When you actually play the secondary segment, which flags do you use? If you aren't already, try setting DMUS_SEGF_SECONDARY and see if it solves your problem. I think that the second segment is replacing the first as the primary segment, hence the apparent muting. Todor -----Original Message----- From: directmusic-bounce@xxxxxxxxxxxxx [mailto:directmusic-bounce@xxxxxxxxxxxxx] On Behalf Of Abhijit Patait Sent: Tuesday, May 11, 2004 5:44 PM To: directmusic@xxxxxxxxxxxxx Subject: [directmusic] Playing multiple MIDI segments, aligned I am writing an application where I want to play multiple MIDI files simultaneously. In order to play these files, I load each file into a segment, and call PlaySegmentEx(...) on each of the segments (actually, I am using the class CSegment from Todor Fay's book "DirectX 9 Audio Exposed"). I want the segments to be aligned to the beginning, and therefore, I play the first segment as primary segment and all others as secondary segments with the appropriate alignment flags. Here is the code snippet that achieves the above. BOOL bFirstSegment =3D3D TRUE; // Assume that CString filename[] contains names of the MIDI files to be played for (i =3D3D 0; i < 2; i++) { WCHAR wzFileName[DMUS_MAX_FILENAME]; mbstowcs(wzFileName, filename[i].GetBuffer(DMUS_MAX_FILENAME), DMUS_MAX_FILENAME); CSegment *pSegment =3D3D pAudio->LoadSegment(wzFileName); // Use default flags for first segment if (!bFirstSegment) pSegment->SetFlags(DMUS_SEGF_SECONDARY | DMUS_SEGF_SEGMENTEND | DMUS_SEGF_ALIGN | DMUS_SEGF_VALID_START_BEAT); bFirstSegment =3D3D FALSE; } The first segment loads and starts playing, but as soon as the second segment starts playing, the first gets muted, even though the two segments are aligned as expected. However, I don't understand why the first segment gets muted. I have tried the experiment with the same two MIDI files, with "Segment Jones" application provided with the above-mentioned book, and have seen the same results (secondary segment muting the primary segment). How can I play both segments simultaneously? I would really appreciate someone helping me on this. Thank you in advance. -Abhijit PS: If needed, I can send additional code snippets and/or the MIDI files that I am using for this experiment. The test MIDI files contain a sequence of about 20 note on/off messages. Both midi files have the same length and same note on/off sequence, but on different channels with different patches (instruments). --------------------------------- Do you Yahoo!? Win a $20,000 Career Makeover at Yahoo! HotJobs=3D20 --------------------------------- Do you Yahoo!? Yahoo! Movies - Buy advance tickets for 'Shrek 2'=3D20 -- Binary/unsupported file stripped by Ecartis -- -- Type: application/x-zip-compressed -- File: Test Files.zip -- Desc: Test Files.zip =3D09 --------------------------------- Do you Yahoo!? Yahoo! Movies - Buy advance tickets for 'Shrek 2'=3D20 --------------------------------- Do you Yahoo!? Yahoo! Movies - Buy advance tickets for 'Shrek 2' --------------------------------- Do you Yahoo!? Yahoo! Movies - Buy advance tickets for 'Shrek 2' --------------------------------- Do you Yahoo!? SBC Yahoo! - Internet access at a great low price.