Exemplo n.º 1
0
void MarkerMapper::fillBuffer()
{
    resize(0);

    Composition& comp = m_doc->getComposition();
    Composition::markercontainer &marks = comp.getMarkers();

    for (Composition::markerconstiterator i = marks.begin();
	 i != marks.end(); ++i) {

      std::string metaMessage = (*i)->getName();
      RealTime eventTime = comp.getElapsedRealTime((*i)->getTime());
#ifdef DEBUG_MARKER_MAPPER
    SEQUENCER_DEBUG
        << "MarkerMapper::fillBuffer inserting marker message"
        << metaMessage
        << "at" << eventTime
        << endl;
#endif

      MappedEvent e;
      e.setType(MappedEvent::Marker);
      e.setEventTime(eventTime);
      e.addDataString(metaMessage);
      mapAnEvent(&e);
    }
}
Exemplo n.º 2
0
void MetronomeMapper::fillBuffer()
{
    //RG_DEBUG << "fillBuffer(): instrument is " << m_metronome->getInstrument();

    Q_ASSERT_X(capacity() >= static_cast<int>(m_ticks.size()),
               "MetronomeMapper::fillBuffer()",
               "Buffer capacity is too small.");

    Composition &composition = m_doc->getComposition();

    const RealTime tickDuration(0, 100000000);

    int index = 0;

    // For each tick
    for (TickContainer::iterator tick = m_ticks.begin();
         tick != m_ticks.end();
         ++tick) {

        //RG_DEBUG << "fillBuffer(): velocity = " << int(velocity);

        RealTime eventTime = composition.getElapsedRealTime(tick->first);

        MappedEvent e;

        if (tick->second == MidiTimingClockTick) {
            e = MappedEvent(0,  // Instrument ID is irrelevant
                            MappedEvent::MidiSystemMessage);
            e.setData1(MIDI_TIMING_CLOCK);
            e.setEventTime(eventTime);
        } else {
            MidiByte velocity;
            MidiByte pitch;

            switch (tick->second) {
            case BarTick:
                velocity = m_metronome->getBarVelocity();
                pitch = m_metronome->getBarPitch();
                break;
            case BeatTick:
                velocity = m_metronome->getBeatVelocity();
                pitch = m_metronome->getBeatPitch();
                break;
            case SubBeatTick:
                velocity = m_metronome->getSubBeatVelocity();
                pitch = m_metronome->getSubBeatPitch();
                break;
            case MidiTimingClockTick:
            default:
                RG_WARNING << "fillBuffer(): Unexpected tick type";
            }

            e = MappedEvent(m_metronome->getInstrument(),
                            MappedEvent::MidiNoteOneShot,
                            pitch,
                            velocity,
                            eventTime,
                            tickDuration,
                            RealTime::zeroTime);  // audioStartMarker
        }

        // Add the event to the buffer.
        getBuffer()[index] = e;

        ++index;
    }

    //RG_DEBUG << "fillBuffer(): capacity: " << capacity();
    //RG_DEBUG << "  Total events written: " << index;

    resize(index);

    m_channelManager.reallocateEternalChannel();
    m_channelManager.setDirty();
}