当前位置: 首页>>代码示例>>C++>>正文


C++ MIDITimedBigMessage::IsNoOp方法代码示例

本文整理汇总了C++中MIDITimedBigMessage::IsNoOp方法的典型用法代码示例。如果您正苦于以下问题:C++ MIDITimedBigMessage::IsNoOp方法的具体用法?C++ MIDITimedBigMessage::IsNoOp怎么用?C++ MIDITimedBigMessage::IsNoOp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MIDITimedBigMessage的用法示例。


在下文中一共展示了MIDITimedBigMessage::IsNoOp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SoloMelodyConverter

void SoloMelodyConverter( const MIDIMultiTrack &src, MIDIMultiTrack &dst, int ignore_channel )
{
    // this simple code works better for src MultiTrack with 1 track,
    // if not, we can make before the call of CollapseMultiTrack()

    dst.ClearAndResize( src.GetNumTracks() );
    dst.SetClksPerBeat( src.GetClksPerBeat() );

    MIDIClockTime ev_time = 0;
    MIDISequencer seq( &src );
    seq.GoToTime( 0 );
    if ( !seq.GetNextEventTime ( &ev_time ) )
        return; // empty src multitrack

    MIDITimedBigMessage ev;
    int ev_track;

    int solo_note = -1; // highest midi note number in current time, valid values 0...127
    bool solo_note_on = false;
    MIDITimedBigMessage solo_note_on_ev; // last solo note on event
    solo_note_on_ev.SetNoOp();

    while ( seq.GetNextEvent( &ev_track, &ev ) )
    {
        if ( ev.IsServiceMsg() || ev.IsNoOp() )
            continue;

        if ( ev.IsChannelEvent() )
        {
            if ( ev.GetChannel() == ignore_channel )
                continue;

//          if ( ev.IsAllNotesOff() ) ... ; // for future work...

            if ( ev.IsNote() )
            {
                int new_note = ev.GetNote();

                // skip all note events if new note lower than solo note
                if ( new_note < solo_note )
                    continue;
                // else ( new_note >= solo_note )

                if ( ev.ImplicitIsNoteOn() ) // new note on event
                {
                    if ( solo_note_on ) // new note on after previous solo note on
                    {
                        // make noteoff message for previous solo note
                        solo_note_on_ev.SetTime( ev.GetTime() );
                        solo_note_on_ev.SetVelocity( 0 ); // note off
                        dst.GetTrack(ev_track)->PutEvent( solo_note_on_ev );

                        // make new solo note
                        solo_note_on_ev = ev;
                        solo_note = new_note;
                    }
                    else // ( solo_note_on == false ) - new note on after previous silence
                    {
                        // make new solo note
                        solo_note_on = true;
                        solo_note_on_ev = ev;
                        solo_note = new_note;
                    }
                }
                else // new note off event ( new_note >= solo_note )
                {
                    if ( solo_note_on ) // new note off after previous solo note on
                    {
                        if ( new_note == solo_note ) // solo note off event
                        {
                            // test channels of the events
                            if ( ev.GetChannel() == solo_note_on_ev.GetChannel() )
                            {
                                solo_note_on = false;
                                solo_note = -1; // erase solo_note
                            }
                            else
                                continue; // skip other note off stuff
                        }
                        else // ( new_note > solo_note ) any other note off event
                            continue; // skip other note off stuff
                    }
                    else // ( solo_note_on == false ) - new note off after previous silence
                        continue; // skip other note off stuff
                }
            }
        }
        dst.GetTrack(ev_track)->PutEvent(ev);
    }
}
开发者ID:bonzehan,项目名称:stm32-projects,代码行数:90,代码来源:jdksmidi_utils.cpp


注:本文中的MIDITimedBigMessage::IsNoOp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。