MIDI-record problem, trying MFX to solve. Help me
I have keyboard KB-930 (it is can be by Bravis or Techno trademark, device is single =) ).
KB-930 have MIDI output. I use USB MIDI cable with black-box on it with 2 LEDs - red and green (lights when out/in).
In live-mode Sonar 7 receive MIDI messages and echoes it to "Microsoft Synthesizer" device. And when I release key - sonar stop sounds.
But when I try to record MIDI with Sonar 7 - key release not affected to record stream. And all pushed notes continue playing until record stopped. It is bad.
I read articles about it, and setup MIDI-OX software to see what my keyboard sends to PC.
For one key
Pushed
00000B59 1 1 C0 00 -- 1 --- PC: Acc. Grand Piano - grandpiano instrument in 0 channel
00000B59 1 1 B0 7B 00 1 --- CC: All Notes Off - all notes off in 0 channel
00000B59 1 1 90 48 42 1 C 5 Note On - note С5 on in 0 channel
Release
00000E1F 1 1 B0 7B 00 1 --- CC: All Notes Off - all notes off in channel 0, including С5
For two keys:
Push first key
00001C38 1 1 C0 00 -- 1 --- PC: Acc. Grand Piano - grandpiano instrument in 0 channel
00001C38 1 1 B0 7B 00 1 --- CC: All Notes Off - all notes off in 0 channel
00001C38 1 1 90 4C 33 1 E 5 Note On - note E5 on in 0 channel
Push second key
00001D6F 1 1 C1 00 -- 2 --- PC: Acc. Grand Piano - grandpiano instrument in 1 channel
00001D6F 1 1 B1 7B 00 2 --- CC: All Notes Off - all notes off in 1 channel
00001D6F 1 1 91 4D 42 2 F 5 Note On - note F5 on in 1 channel
Release first key
000020B7 1 1 B0 7B 00 1 --- CC: All Notes Off - all notes off in 0 channel, including E5
Release second key
000021D9 1 1 B1 7B 00 2 --- CC: All Notes Off - all notes off in 1 channel, including F5
I understand that my midi-keyboard automatically split all pushed keys to channel from 0 to 15 (excluding 10 may be, its for drums). And i see than in ONE moment in ONE channel can be sound only ONE note. And because of it - message "All notes off" in this channel will off only this single note (it is what i need when i release key on keyboard, and it is sended by keyboard to PC).
BUT Sonar in Live mode understand this All notes off, but
in Record mode - sonar "not seeing" all-notes-off messages, and because of it Sonar don't break notes, continuing them to end of record.
How Can I force Sonar to undersand All-notes-off message in Record mode? I download DXI SDK and tried to wrote MFX plugin. I think that if I change All-notes-off to single-note-off (previously pushed in that channel) - sonar will understand it.
But in MFX plugin - 2 events can be handled:
OnInput and OnEvents.
In OnInput I can change messages:
HRESULT CPlugKb930::OnInput( IMfxDataQueue* pqIn, IMfxDataQueue* pqOut )
{
// This gives us a chance to process live MIDI input
int nCount;
if (SUCCEEDED( pqIn->GetCount( &nCount ) ))
{
for (int ix = 0; ix < nCount; ++ix)
{
MfxData data;
if (SUCCEEDED( pqIn->GetAt( ix, &data ) ))
{
// Note on (0x90)? - catch this event
BYTE const byKind = data.m_byStatus & 0xF0;
if (0x90 == byKind)
{
//record number of channel with pushed note - data.m_byStatus & 0x0F - from 0 to 15
n_chan[data.m_byStatus & 0x0F]=data.m_byData1;
pqOut->Add( data ); // send this message
} else if (0xB0 == byKind) { //it is control?
//it is All Notes Off?
if ((data.m_byData1 == 0x7B)&(data.m_byData2 == 0)&(n_chan[data.m_byStatus & 0x0F]!=0)) {//yeah, we change it to disables only single last pushed note
data.m_byStatus = (0x80|(data.m_byStatus & 0x0F));//message "note off"
data.m_byData1 = n_chan[data.m_byStatus & 0x0F];//in that recorded channel number
data.m_byData2 = 0; //volume - zero
n_chan[data.m_byStatus & 0x0F] = 0;
}
pqOut->Add( data );//write this message
}
else
{
// and write message if it another, not note-on, not all-notes-off
pqOut->Add( data );
}
}
}
}
return S_OK;
}
and in OnEvents i simple pass all events to pqOut, not changing.
But it not affect to Record mode!! And in LiveInput mode there is no changes when i enable this plugin - because without plugin it is good sound too, and understand Allnotesoff message =)
After it i think than OnEvents - is my solve. But in OnEvents i cannot hook Note-Off message, only Duration can be catched with Note-pushing. But i dont understand HOW CAKEWALK CAN KNOW about duration when i ONLY PUSH KEY AND HOLD IT ?
And there is one big question -
How can I force Cakewalk Sonar to understand All-notes-off messages from my midi-keyboard and to include this messages in Recorded Midi stream? Help me please. What I need to change in MIDI-stream? Or may be there is simplier way to solve it? May be special flag "Use All-notes-off message" exists in sonar options?
Or is it canbe changed in Instruments menu? I try to add 123 controller to all lists - Standart, Roland, Yamaha XG in Controllers sub-note. But it is not solve my problem =(
post edited by blackstrip - 2009/02/08 03:48:23