Exemplo n.º 1
0
void
SegmentJoinCommand::execute()
{
    Composition *composition = m_oldSegments[0]->getComposition();
    if (!composition) {
        RG_DEBUG << "SegmentJoinCommand::execute: ERROR: old segments are not in composition!";
        return ;
    }

    if (!m_newSegment) {
        m_newSegment = makeSegment(m_oldSegments);
    }

    composition->addSegment(m_newSegment);

    // Select this new joined segment.
    RosegardenMainWindow::self()->getView()->getTrackEditor()->
        getCompositionView()->getModel()->setSelected(m_newSegment);
    
    for (size_t i = 0; i < m_oldSegments.size(); ++i) {
        composition->detachSegment(m_oldSegments[i]);
    }

    m_detached = true;
}
void
AudioSegmentResizeFromStartCommand::execute()
{
    Composition *c = m_segment->getComposition();

    if (!m_newSegment) {
        RealTime oldRT = c->getElapsedRealTime(m_oldStartTime);
        RealTime newRT = c->getElapsedRealTime(m_newStartTime);

        m_newSegment = m_segment->clone(false);
        m_newSegment->setStartTime(m_newStartTime);

        // Compute an audio start time that will keep the audio exactly where
        // it was in time.
        RealTime audioStartTime = 
            m_segment->getAudioStartTime() - (oldRT - newRT);

        // Do not allow a negative audio start time.
        // ??? This is a stopgap measure as the audio segment preview code 
        //   will crash if the audio start time is negative.  Need to fix the
        //   preview code, then check to see if the playback code works
        //   properly given a negative start time.  Then this can be removed.
        if (audioStartTime <= RealTime::zeroTime)
            m_newSegment->setAudioStartTime(RealTime::zeroTime);
        else
            m_newSegment->setAudioStartTime(
                m_segment->getAudioStartTime() - (oldRT - newRT));
    }

    c->addSegment(m_newSegment);
    m_newSegment->setEndMarkerTime(m_segment->getEndMarkerTime());
    c->detachSegment(m_segment);

    m_detached = false;
}
void
AudioSegmentResizeFromStartCommand::unexecute()
{
    Composition *c = m_newSegment->getComposition();
    c->addSegment(m_segment);
    c->detachSegment(m_newSegment);

    m_detached = true;
}