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


C++ MidiEvent::getFrameOffset方法代码示例

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


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

示例1: while

/**
 * process this MIDI input: pack LV2 input buffer from EventBuffer + EventConnection
 */
void Lv2MidiInput::process(bool rolling, jack_position_t &pos, jack_nframes_t nframes, jack_nframes_t time) {
    // clear atom sequence
    lv2_atom_sequence_clear(atomSequence);

    // send all notes off messages if newly stopped
    if(localRolling && !rolling) {
        Lv2MidiEvent lv2Event;
        lv2Event.event.time.frames = 0;
        lv2Event.buffer[1] = 0x7b; // CC 123 = all notes off
        lv2Event.buffer[2] = 0;
        for(uint8_t channel = 0; channel < 16; channel++) {
            lv2Event.buffer[0] = MidiEvent::TYPE_CONTROL + channel;
            lv2_atom_sequence_append_event(atomSequence, CAPACITY, &lv2Event.event);
        }
    }
    localRolling = rolling;

    // get connection and event count
    MidiConnection *connection = eventConnector.getConnection();
    uint32_t eventCount = 0;
    if(connection) {
        connection->getSource()->process(rolling, pos, nframes, time);
        eventCount = connection->getEventCount();
    }

    // get top events from buffer + connection
    MidiEvent* bufferEvent = eventBuffer.getNextEvent(rolling, pos, nframes);
    MidiEvent *connectionEvent = eventCount ? connection->getEvent(0) : 0;
    uint32_t eventIndex = 1;

    // loop while events on either buffer or connection
    while(bufferEvent || connectionEvent) {
        bool bufferNext = bufferEvent &&
                (!connectionEvent || bufferEvent->getFrameOffset() < connectionEvent->getFrameOffset());
        MidiEvent *event = bufferNext ? bufferEvent : connectionEvent;
        // lv2 event
        Lv2MidiEvent lv2Event;
        long frame = event->getFrameOffset();
        lv2Event.event.time.frames = frame >= 0 ? frame : 0;
        // copy event data
        event->pack(&lv2Event.buffer);
        // append this event to sequence
        lv2_atom_sequence_append_event(atomSequence, CAPACITY, &lv2Event.event);
        // get next event
        if(bufferNext) {
            // recycle and get next buffer event
            ObjectCollector::scriptCollector().recycle(bufferEvent);
            bufferEvent = eventBuffer.getNextEvent(rolling, pos, nframes);
        } else {
            connectionEvent = eventIndex < eventCount ? connection->getEvent(eventIndex++) : 0;
        }
    }
}
开发者ID:bipscript,项目名称:bipscript,代码行数:56,代码来源:lv2plugin.cpp


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