Exemplo n.º 1
0
// read the file ahead to collect info about the song first
void CSong::midiFileInfo()
{
    m_trackList->clear();
    setTimeSig(0,0);
    CStavePos::setKeySignature( NOT_USED, 0 );

    // Read the next events to find the active channels
    CMidiEvent event;
    while ( true )
    {
        event = m_midiFile->readMidiEvent();
        m_trackList->examineMidiEvent(event);

        if (event.type() == MIDI_PB_timeSignature)
        {
            setTimeSig(event.data1(),event.data2());
        }

        if (event.type() == MIDI_PB_EOF)
            break;
    }
}
Exemplo n.º 2
0
void CConductor::playTransposeEvent(CMidiEvent event)
{
    if (m_transpose != 0 && event.channel() != MIDI_DRUM_CHANNEL &&
                (event.type() == MIDI_NOTE_ON || event.type() == MIDI_NOTE_OFF) )
        event.transpose(m_transpose);

    if (event.type() == MIDI_NOTE_ON && isChannelMuted(event.channel()) == true &&
                                CChord::isNotePlayable(event.note(), m_transpose) == true)
        return; // mute the note by not playing it

    // boost any volume events
    if (event.type() == MIDI_CONTROL_CHANGE && event.data1() == MIDI_MAIN_VOLUME)
        event.setDatat2(calcBoostVolume(event.channel(), event.data2() ));

    // Don't output note on if we are seeking to bar
    if (!seekingBarNumber())
        playTrackEvent(event); // Play the midi note or event
    else
    {
        if (event.type() == MIDI_PROGRAM_CHANGE || event.type() == MIDI_CONTROL_CHANGE)
            playTrackEvent(event); // Play the midi note or event
    }
}
Exemplo n.º 3
0
//! add a midi event to be played immediately
void CMidiDeviceRt::playMidiEvent(const CMidiEvent & event)
{
    if (m_midiPorts[1] < 0)
        return;

    unsigned int channel;
    std::vector<unsigned char> message;

    channel = event.channel() & 0x0f;

    switch(event.type())
    {
        case MIDI_NOTE_OFF: // NOTE_OFF
            message.push_back( channel | MIDI_NOTE_OFF );
            message.push_back( event.note());
            message.push_back( event.velocity());
            break;
        case MIDI_NOTE_ON:      // NOTE_ON
            message.push_back( channel | MIDI_NOTE_ON );
            message.push_back( event.note());
            message.push_back( event.velocity());
            break;

        case MIDI_NOTE_PRESSURE: //POLY_AFTERTOUCH: 3 bytes
            message.push_back( channel | MIDI_NOTE_PRESSURE);
            message.push_back( event.data1());
            message.push_back( event.data2());
            break;

        case MIDI_CONTROL_CHANGE: //CONTROL_CHANGE:
            message.push_back( channel | MIDI_CONTROL_CHANGE);
            message.push_back( event.data1());
            message.push_back( event.data2());
            break;

        case MIDI_PROGRAM_CHANGE: //PROGRAM_CHANGE:
            message.push_back( channel | MIDI_PROGRAM_CHANGE);
            message.push_back( event.programme());
            break;

        case MIDI_CHANNEL_PRESSURE: //AFTERTOUCH: 2 bytes only
            message.push_back( channel | MIDI_CHANNEL_PRESSURE);
            message.push_back( event.data1());
            break;

        case MIDI_PITCH_BEND: //PITCH_BEND:
            message.push_back( channel | MIDI_PITCH_BEND);
            message.push_back( event.data1());
            message.push_back( event.data2());
            break;

        case  MIDI_PB_collateRawMidiData: //used for a SYSTEM_EVENT
            if (m_rawDataIndex < arraySize(m_savedRawBytes))
                m_savedRawBytes[m_rawDataIndex++] = event.data1();
            return; // Don't output any thing yet so just return

        case  MIDI_PB_outputRawMidiData: //used for a SYSTEM_EVENT
            for (size_t i = 0; i < m_rawDataIndex; i++)
                message.push_back( m_savedRawBytes[i]);
            m_rawDataIndex = 0;
            break;
    }

    m_midiout->sendMessage( &message );

    //event.printDetails(); // useful for debugging
}