コード例 #1
0
void GOrgueMidiRecorder::Clear()
{
	m_Mappings.clear();
	m_Preconfig.clear();
	m_NextChannel = 1;
	m_NextNRPN = 0;

	GOrgueMidiEvent e;
	e.SetMidiType(MIDI_SYSEX_GO_CLEAR);
	e.SetTime(wxGetLocalTimeMillis());
	SendEvent(e);
}
コード例 #2
0
void GOrgueMidiRecorder::SendEvent(GOrgueMidiEvent& e)
{
	e.SetDevice(m_OutputDevice);
	if (m_OutputDevice)
		m_organfile->SendMidiMessage(e);
	if (IsRecording())
		WriteEvent(e);
}
コード例 #3
0
void GOrgueMidiRecorder::WriteEvent(GOrgueMidiEvent& e)
{
	if (!IsRecording())
		return;
	std::vector<std::vector<unsigned char>> msg;
	e.ToMidi(msg, m_Map);
	for(unsigned i = 0; i < msg.size(); i++)
	{
		EncodeLength((e.GetTime() - m_Last).GetValue());
		if (msg[i][0] == 0xF0)
		{
			Write(&msg[i][0], 1);
			EncodeLength(msg[i].size() - 1);
			Write(&msg[i][1], msg[i].size() - 1);
		}
		else
			Write(&msg[i][0], msg[i].size());
		m_Last = e.GetTime();
	}
}
コード例 #4
0
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);
}
コード例 #5
0
void GOrgueMidiInPort::Receive(const std::vector<unsigned char> msg)
{
	if (!IsActive())
		return;

	GOrgueMidiEvent e;
	e.FromMidi(msg, m_midi->GetMidiMap());
	if (e.GetMidiType() == MIDI_NONE)
		return;
	e.SetDevice(GetID());
	e.SetTime(wxGetLocalTimeMillis());

	if (!m_merger.Process(e))
		return;

	/* Compat stuff */
	if (e.GetChannel() != -1)
		e.SetChannel(((e.GetChannel() - 1 + m_ChannelShift) & 0x0F) + 1);

	m_midi->Recv(e);
}
コード例 #6
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;
}