[directmusic] Re: Playing multiple MIDI segments, aligned

  • From: "Scott Morgan (Volt)" <a-smorg@xxxxxxxxxxxxx>
  • To: <directmusic@xxxxxxxxxxxxx>
  • Date: Wed, 12 May 2004 18:45:08 -0700

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 <abhijit_patait@xxxxxxxxx> 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




Other related posts: