Example #1
0
bool GOrgueMidiMerger::Process(GOrgueMidiEvent& e)
{
    if (e.GetMidiType() == MIDI_CTRL_CHANGE && e.GetKey() == MIDI_CTRL_BANK_SELECT_MSB)
    {
        m_BankMsb[e.GetChannel() - 1] = e.GetValue();
        return false;
    }
    if (e.GetMidiType() == MIDI_CTRL_CHANGE && e.GetKey() == MIDI_CTRL_BANK_SELECT_LSB)
    {
        m_BankLsb[e.GetChannel() - 1] = e.GetValue();
        return false;
    }
    if (e.GetMidiType() == MIDI_CTRL_CHANGE && e.GetKey() == MIDI_CTRL_RPN_LSB)
    {
        m_RpnLsb[e.GetChannel() - 1] = e.GetValue();
        m_Rpn = true;
        return false;
    }
    if (e.GetMidiType() == MIDI_CTRL_CHANGE && e.GetKey() == MIDI_CTRL_RPN_MSB)
    {
        m_RpnMsb[e.GetChannel() - 1] = e.GetValue();
        m_Rpn = true;
        return false;
    }
    if (e.GetMidiType() == MIDI_CTRL_CHANGE && e.GetKey() == MIDI_CTRL_NRPN_LSB)
    {
        m_NrpnLsb[e.GetChannel() - 1] = e.GetValue();
        m_Rpn = false;
        return false;
    }
    if (e.GetMidiType() == MIDI_CTRL_CHANGE && e.GetKey() == MIDI_CTRL_NRPN_MSB)
    {
        m_NrpnMsb[e.GetChannel() - 1] = e.GetValue();
        m_Rpn = false;
        return false;
    }
    if (e.GetMidiType() == MIDI_PGM_CHANGE)
        e.SetKey(((e.GetKey() - 1) | (m_BankLsb[e.GetChannel() - 1] << 7) | (m_BankMsb[e.GetChannel() - 1] << 14)) + 1);

    if (e.GetMidiType() == MIDI_CTRL_CHANGE && e.GetKey() == MIDI_CTRL_DATA_ENTRY)
    {
        if (m_Rpn)
        {
            e.SetMidiType(MIDI_RPN);
            e.SetKey((m_RpnLsb[e.GetChannel() - 1] << 0) | (m_RpnMsb[e.GetChannel() - 1] << 7));
        }
        else
        {
            e.SetMidiType(MIDI_NRPN);
            e.SetKey((m_NrpnLsb[e.GetChannel() - 1] << 0) | (m_NrpnMsb[e.GetChannel() - 1] << 7));
        }
    }

    return true;
}
void GOrgueMidiRecorder::SendMidiRecorderMessage(GOrgueMidiEvent& e)
{
	if (!m_OutputDevice && !IsRecording())
		return;
	if (!SetupMapping(e.GetDevice(), e.GetMidiType() == MIDI_NRPN))
		return;

	e.SetTime(wxGetLocalTimeMillis());
	e.SetChannel(m_Mappings[e.GetDevice()].channel);
	if (e.GetMidiType() == MIDI_NRPN)
		e.SetKey(m_Mappings[e.GetDevice()].key);

	SendEvent(e);
}