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


C++ MIDITimedBigMessage类代码示例

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


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

示例1: CollapseMultiTrack

void CollapseMultiTrack( const MIDIMultiTrack &src, MIDIMultiTrack &dst )
{
    dst.ClearAndResize( 1 );
    dst.SetClksPerBeat( src.GetClksPerBeat() );

    MIDISequencer seq( &src );
    seq.GoToZero();

    MIDITimedBigMessage ev;
    int ev_track;
    while ( seq.GetNextEvent( &ev_track, &ev ) )
    {
        // ignore all src EndOfTrack messages!!
        if ( ev.IsDataEnd() )
            continue;

        // ignore NoOp, BeatMarker and other Service messages
        if ( ev.IsServiceMsg() || ev.IsNoOp() )
            continue;

        dst.GetTrack(0)->PutEvent(ev);
    }

    // set (single!) dst EndOfTrack message
    MIDITimedBigMessage end(ev); // copy time of last src event
    end.SetDataEnd();
    dst.GetTrack(0)->PutEvent(end);
}
开发者ID:bonzehan,项目名称:stm32-projects,代码行数:28,代码来源:jdksmidi_utils.cpp

示例2: CopyWithoutChannel

void CopyWithoutChannel( const MIDIMultiTrack &src, MIDIMultiTrack &dst, int ignore_channel )
{
    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;

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

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

        dst.GetTrack(ev_track)->PutEvent(ev);
    }
}
开发者ID:bonzehan,项目名称:stm32-projects,代码行数:25,代码来源:jdksmidi_utils.cpp

示例3: ClipMultiTrack

void ClipMultiTrack( const MIDIMultiTrack &src, MIDIMultiTrack &dst, double max_time_sec )
{
    dst.ClearAndResize( src.GetNumTracks() );
    dst.SetClksPerBeat( src.GetClksPerBeat() );

    double max_event_time = 1000.*max_time_sec; // msec
    double event_time = 0.; // msec

    MIDISequencer seq( &src );
    seq.GoToTimeMs( 0.f );
    if ( !seq.GetNextEventTimeMs ( &event_time ) )
        return; // empty src multitrack

    MIDITimedBigMessage ev;
    int ev_track;
    while ( seq.GetNextEvent( &ev_track, &ev ) )
    {
        // ignore NoOp, BeatMarker and other Service messages
        if ( ev.IsServiceMsg() || ev.IsNoOp() )
            continue;

        dst.GetTrack(ev_track)->PutEvent(ev);

        if ( event_time >= max_event_time )
            break; // end of max_time_sec

        if ( !seq.GetNextEventTimeMs( &event_time ) )
            break; // end of src multitrack
    }
}
开发者ID:bonzehan,项目名称:stm32-projects,代码行数:30,代码来源:jdksmidi_utils.cpp

示例4:

GenePool::MIDIEventList *GenePool::getEvents(void)
{
	list<MIDITimedBigMessage*> *events = new list<MIDITimedBigMessage*>;

    for (EventPool::iterator i = pool_.begin(); i != pool_.end(); ++i)
    {
		for (BreadNoteCluster::iterator j = (*i)->begin(); j != (*i)->end(); ++j)
		{
            BreadNote *e = (*j);
			
            u_int8_t pitch = e->pitch();
            u_int32_t ontime = e->ontime();
            u_int32_t duration = e->duration();
            u_int8_t channel = e->channel();
            u_int8_t dynamic = e->dynamic();

			MIDITimedBigMessage *m = new MIDITimedBigMessage;
			m->SetTime(ontime);
			m->SetNoteOn(channel, pitch, dynamic);
			events->push_back(m);
			m = new MIDITimedBigMessage;
			m->SetTime(ontime+duration);
			m->SetNoteOff(channel, pitch, dynamic);
			events->push_back(m);

//            printf("(%d %d %d %d %d) ", ontime, pitch, duration, channel,
//                   dynamic);
        }
	}

	return events;
}
开发者ID:mishan,项目名称:quickhacks,代码行数:32,代码来源:GenePool.cpp

示例5: FindFirstChannelOnTrack

int AdvancedSequencer::FindFirstChannelOnTrack ( int trk )
{
    if ( !file_loaded )
    {
        return -1;
    }

    int first_channel = -1;
    MIDITrack *t = tracks.GetTrack ( trk );

    if ( t )
    {
        // go through all events
        // until we find a channel message
        // and then return the channel number plus 1
        for ( int i = 0; i < t->GetNumEvents(); ++i )
        {
            MIDITimedBigMessage *m = t->GetEventAddress ( i );

            if ( m )
            {
                if ( m->IsChannelMsg() )
                {
                    first_channel = m->GetChannel() + 1;
                    break;
                }
            }
        }
    }

    return first_channel;
}
开发者ID:jdkoftinoff,项目名称:jdksmidi-historic,代码行数:32,代码来源:jdksmidi_advancedsequencer.cpp

示例6: AddEndingPause

bool AddEndingPause( MIDIMultiTrack &tracks, int track_num, MIDIClockTime pause_ticks )
{
    MIDIClockTime t = tracks.GetTrack( track_num )->GetLastEventTime();
    MIDITimedBigMessage msg;
    msg.SetTime( t + pause_ticks );
    // add lowest "note on" in channel 0 with velocity 0 (i.e. "note off")
    msg.SetNoteOn( 0, 0, 0 );
    return tracks.GetTrack( track_num )->PutEvent( msg );
}
开发者ID:bonzehan,项目名称:stm32-projects,代码行数:9,代码来源:jdksmidi_utils.cpp

示例7: EventAsText

std::string EventAsText(const MIDITimedBigMessage &ev)
{
    char buf[256];
    ev.MsgToText( buf );
    MIDIClockTime time = ev.GetTime();

    /*std::ostringstream ostr;
    ostr << " Midi tick " << time;
    ostr << "  MSG " << buf << " ";
    return ostr.str();*/
	  return std::string("EventAsText Stub");
}
开发者ID:bonzehan,项目名称:stm32-projects,代码行数:12,代码来源:jdksmidi_utils.cpp

示例8: HardwareMsgOut

 bool MIDIDriverDump::HardwareMsgOut ( const MIDITimedBigMessage &msg )
 {
   char buf[256];
   
   fprintf ( f, "OUTPUT: %s\n", msg.MsgToText ( buf ) );
   return true;
 }
开发者ID:grimtraveller,项目名称:koblo_software,代码行数:7,代码来源:jdkmidi_driverdump.cpp

示例9: GetEventAddress

 bool	MIDITrack::PutEvent( const MIDITimedMessage &msg, MIDISystemExclusive *sysex )	
 {
   if( num_events >= buf_size )
   {
     if( !Expand() )
       return false;
   }
   
   MIDITimedBigMessage *e = GetEventAddress( num_events );
   
   e->Copy( msg );
   e->CopySysEx( sysex );
   
   ++num_events;
   
   return true;
 } 
开发者ID:MisterZeus,项目名称:SNES-Tracker,代码行数:17,代码来源:jdkmidi_track.cpp

示例10: LastEventsProlongation

void LastEventsProlongation( MIDIMultiTrack &tracks, int track_num, MIDIClockTime add_ticks )
{
    MIDITrack *track = tracks.GetTrack( track_num );
    int index = track->GetNumEvents() - 1;
    if ( add_ticks == 0 || index < 0 )
        return;

    MIDITimedBigMessage *msg = track->GetEvent( index );
    MIDIClockTime tmax = msg->GetTime();

    while ( msg->GetTime() == tmax )
    {
        msg->SetTime( tmax + add_ticks );
        if ( --index < 0 )
            break;
        msg = track->GetEvent( index );
    }
}
开发者ID:bonzehan,项目名称:stm32-projects,代码行数:18,代码来源:jdksmidi_utils.cpp

示例11: CompressStartPause

void CompressStartPause( const MIDIMultiTrack &src, MIDIMultiTrack &dst, int ignore_channel )
{
    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;
    bool compress = true;
    MIDIClockTime old_ev_time = 0, delta_ev_time = 0, ev_time0 = 0;

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

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

        ev_time = ev.GetTime();
        if ( compress )
        {
            // compress time intervals between adjacent messages to 1 tick
            if (ev_time > old_ev_time)
                ++delta_ev_time;

            old_ev_time = ev_time;

            ev.SetTime( delta_ev_time );

            if ( ev.ImplicitIsNoteOn() )
            {
                compress = false;
                ev_time0 = ev_time - delta_ev_time;
            }
        }
        else
        {
            ev.SetTime( ev_time - ev_time0 );
        }

        dst.GetTrack(ev_track)->PutEvent(ev);
    }
}
开发者ID:bonzehan,项目名称:stm32-projects,代码行数:49,代码来源:jdksmidi_utils.cpp

示例12: GoToNextEventOnTrack

 bool MIDIMultiTrackIterator::GoToNextEventOnTrack ( int track_num )
 {
   // Get the track that we are dealing with
   MIDITrack *track = multitrack->GetTrack ( track_num );
   
   // Get ptr to the current event number for this track
   int *event_num = &state.next_event_number[ track_num ];
   
   // skip this track if this event number is <0 - This track has hit end already.
   
   if ( *event_num <0 )
   {
     return false; // at end of track
   }
   
   // increment *event_num to next event on track
   
   ( *event_num ) += 1;
   
   // are we at end of track?
   if ( *event_num >= track->GetNumEvents() )
   {
     // yes, set *event_num to -1
     *event_num=-1;
     return false; // at end of track
   }
   else
   {
     // not at end of track yet - get the time of the event
     MIDITimedBigMessage *msg;
     
     msg = track->GetEventAddress ( *event_num );
     
     state.next_event_time[ track_num ] = msg->GetTime();
   }
   
   
   
   return true;
 }
开发者ID:grimtraveller,项目名称:koblo_software,代码行数:40,代码来源:jdkmidi_multitrack.cpp

示例13: GetMusicDurationInSeconds

double MIDISequencer::GetMusicDurationInSeconds()
{
    double event_time = 0.; // in milliseconds

    MIDITimedBigMessage ev;
    int ev_track;

    GoToZero();

    while ( GetNextEvent( &ev_track, &ev ) )
    {
        // std::cout << "MIDISequencer::GetMusicDurationInSeconds: " << EventAsText( ev ) << std::endl;

        // skip these events
        if ( ev.IsEndOfTrack() || ev.IsBeatMarker() )
            continue;

        // end of music is the time of last not end of track midi event!
        event_time = GetCurrentTimeInMs();
    }

    return ( 0.001 * event_time );
}
开发者ID:cheetahray,项目名称:of_0071_osx_release,代码行数:23,代码来源:jdksmidi_sequencer.cpp

示例14: DeleteAllTracksText

// delete all text events from multitrack object
bool DeleteAllTracksText( MIDIMultiTrack &tracks )
{
    bool text_deleted = false;
    int num_tracks = tracks.GetNumTracksWithEvents();

    for ( int nt = 0; nt < num_tracks; ++nt )
    {
        MIDITrack &trk = *tracks.GetTrack( nt );
        int num_events = trk.GetNumEvents();

        for ( int ne = 0; ne < num_events; ++ne )
        {
            MIDITimedBigMessage *msg = trk.GetEvent( ne );
            // convert any text midi event to NoOp event
            if ( msg->IsTextEvent() )
            {
                trk.MakeEventNoOp( ne );
                text_deleted = true;
            }
        }
    }

    return text_deleted;
}
开发者ID:jdkoftinoff,项目名称:jdksmidi-bsd,代码行数:25,代码来源:rewrite_midifile.cpp

示例15: AllNotesOff

void MIDIDriver::AllNotesOff ( int chan )
{
    MIDITimedBigMessage msg;
    // send a note off for every note on in the out_matrix

    if ( out_matrix.GetChannelCount ( chan ) > 0 )
    {
        for ( int note = 0; note < 128; ++note )
        {
            while ( out_matrix.GetNoteCount ( chan, note ) > 0 )
            {
                // make a note off with note on msg, velocity 0
                msg.SetNoteOn ( ( unsigned char ) chan,
                                ( unsigned char ) note, 0 );
                OutputMessage ( msg );
            }
        }
    }

    msg.SetControlChange ( chan, C_DAMPER, 0 );
    OutputMessage ( msg );
    msg.SetAllNotesOff ( ( unsigned char ) chan );
    OutputMessage ( msg );
}
开发者ID:jdkoftinoff,项目名称:jdksmidi-historic,代码行数:24,代码来源:jdksmidi_driver.cpp


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