1

Can someone provide sample code on how in one Performance, one MusicPort, load and play two midis (Channels 0-15 in midi 1 and use another channel group to play midi 2's 0-15?) I tried AssignPChannelBlock on music port and SetPChannel on segment, but it plays 1st midi for a moment before only playing second after. I can't find any examples, and it's just not working unfortunately for me.

Basically in my test I do (some steps are skipped, but are default)

Port is Microsoft Synthesizer

HRESULT hr = S_OK;
DMUS_PORTPARAMS portParams;

ZeroMemory(&portParams, sizeof(DMUS_PORTPARAMS));
portParams.dwSize = sizeof(DMUS_PORTPARAMS);
portParams.dwChannelGroups = 2;
portParams.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS;   

if (midiPort.dwFlags & DMUS_PC_AUDIOPATH)
    portParams.dwFeatures = DMUS_PORT_FEATURE_AUDIOPATH;

portParams.dwEffectFlags = DMUS_EFFECT_REVERB;

if (FAILED(hr = mMusic8->CreatePort(midiPort.guidPort, &portParams, &mMusicPort, NULL)))
    return hr;

...

if (FAILED(hr = mPerformance->AddPort(mMusicPort)))
    return hr;

if (FAILED(hr = mPerformance->AssignPChannelBlock(0, mMusicPort, 1)))
    return hr;

if (FAILED(hr = mPerformance->AssignPChannelBlock(1, mMusicPort, 2)))
    return hr;

...

// chan1 is DWORD array 0 to 0xF
mSegment1->SetPChannelsUsed(0x10, chan1);

// chan2 is DWORD array 10 to 0x1F
mSegment2->SetPChannelsUsed(0x10, chan2);

if (FAILED(hr = mSegment1->SetParam(GUID_StandardMIDIFile, 0xFFFFFFFF, 0, 0, NULL)))
    return hr;

if (FAILED(hr = mSegment1->Download(mPerformance)))
    return hr;


if (FAILED(hr = mSegment2->SetParam(GUID_StandardMIDIFile, 0xFFFFFFFF, 0, 0, NULL)))
    return hr;

if (FAILED(hr = mSegment2->Download(mPerformance)))
    return hr;

...

if (FAILED(hr = mPerformance->PlaySegment(mSegment1, 0, 0, &segmentState1)))
    return hr;

if (FAILED(hr = mPerformance->PlaySegment(mSegment2, 0, 0, &segmentState2)))
    return hr;

...

Mary Ellen Bench
  • 589
  • 1
  • 8
  • 28
  • Could you please show us a sample of code, indicating what you are trying now? – Brad Apr 17 '16 at 23:50
  • Included some snippets. I guess if it's not enough, I can write a simple test program version, but I'd imagine would be enough, or ask me what part if need clarification. – Mary Ellen Bench Apr 18 '16 at 01:35

0 Answers0