⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrixview.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    }    updateView();}void MatrixView::slotEditCut(){    MATRIX_DEBUG << "MatrixView::slotEditCut()\n";    if (!m_currentEventSelection)        return ;    KTmpStatusMsg msg(i18n("Cutting selection to clipboard..."), this);    addCommandToHistory(new CutCommand(*m_currentEventSelection,                                       getDocument()->getClipboard()));}void MatrixView::slotEditCopy(){    if (!m_currentEventSelection)        return ;    KTmpStatusMsg msg(i18n("Copying selection to clipboard..."), this);    addCommandToHistory(new CopyCommand(*m_currentEventSelection,                                        getDocument()->getClipboard()));    emit usedSelection();}void MatrixView::slotEditPaste(){    if (getDocument()->getClipboard()->isEmpty()) {        slotStatusHelpMsg(i18n("Clipboard is empty"));        return ;    }    KTmpStatusMsg msg(i18n("Inserting clipboard contents..."), this);    PasteEventsCommand *command = new PasteEventsCommand                                  (m_staffs[0]->getSegment(), getDocument()->getClipboard(),                                   getInsertionTime(), PasteEventsCommand::MatrixOverlay);    if (!command->isPossible()) {        slotStatusHelpMsg(i18n("Couldn't paste at this point"));    } else {        addCommandToHistory(command);        setCurrentSelection(new EventSelection(command->getPastedEvents()));    }}void MatrixView::slotEditDelete(){    if (!m_currentEventSelection)        return ;    KTmpStatusMsg msg(i18n("Deleting selection..."), this);    addCommandToHistory(new EraseCommand(*m_currentEventSelection));    // clear and clear    setCurrentSelection(0, false);}void MatrixView::slotKeyPressed(unsigned int y, bool repeating){    slotHoveredOverKeyChanged(y);    getCanvasView()->slotScrollVertSmallSteps(y);    Composition &comp = getDocument()->getComposition();    Studio &studio = getDocument()->getStudio();    MatrixStaff& staff = *(m_staffs[0]);    MidiByte evPitch = staff.getHeightAtCanvasCoords( -1, y);    // Don't do anything if we're part of a run up the keyboard    // and the pitch hasn't changed    //    if (m_lastNote == evPitch && repeating)        return ;    // Save value    m_lastNote = evPitch;    if (!repeating)        m_firstNote = evPitch;    Track *track = comp.getTrackById(                       staff.getSegment().getTrack());    Instrument *ins =        studio.getInstrumentById(track->getInstrument());    // check for null instrument    //    if (ins == 0)        return ;    MappedEvent mE(ins->getId(),                   MappedEvent::MidiNote,                   evPitch + staff.getSegment().getTranspose(),                   MidiMaxValue,                   RealTime::zeroTime,                   RealTime::zeroTime,                   RealTime::zeroTime);    StudioControl::sendMappedEvent(mE);}void MatrixView::slotKeySelected(unsigned int y, bool repeating){    slotHoveredOverKeyChanged(y);    getCanvasView()->slotScrollVertSmallSteps(y);    MatrixStaff& staff = *(m_staffs[0]);    Segment &segment(staff.getSegment());    MidiByte evPitch = staff.getHeightAtCanvasCoords( -1, y);    // Don't do anything if we're part of a run up the keyboard    // and the pitch hasn't changed    //    if (m_lastNote == evPitch && repeating)        return ;    // Save value    m_lastNote = evPitch;    if (!repeating)        m_firstNote = evPitch;    EventSelection *s = new EventSelection(segment);    for (Segment::iterator i = segment.begin();            segment.isBeforeEndMarker(i); ++i) {        if ((*i)->isa(Note::EventType) &&                (*i)->has(BaseProperties::PITCH)) {            MidiByte p = (*i)->get                         <Int>                         (BaseProperties::PITCH);            if (p >= std::min(m_firstNote, evPitch) &&                    p <= std::max(m_firstNote, evPitch)) {                s->addEvent(*i);            }        }    }    if (m_currentEventSelection) {        // allow addFromSelection to deal with eliminating duplicates        s->addFromSelection(m_currentEventSelection);    }    setCurrentSelection(s, false);    // now play the note as well    Composition &comp = getDocument()->getComposition();    Studio &studio = getDocument()->getStudio();    Track *track = comp.getTrackById(segment.getTrack());    Instrument *ins =        studio.getInstrumentById(track->getInstrument());    // check for null instrument    //    if (ins == 0)        return ;    MappedEvent mE(ins->getId(),                   MappedEvent::MidiNoteOneShot,                   evPitch + segment.getTranspose(),                   MidiMaxValue,                   RealTime::zeroTime,                   RealTime(0, 250000000),                   RealTime::zeroTime);    StudioControl::sendMappedEvent(mE);}void MatrixView::slotKeyReleased(unsigned int y, bool repeating){    MatrixStaff& staff = *(m_staffs[0]);    int evPitch = staff.getHeightAtCanvasCoords(-1, y);    if (m_lastNote == evPitch && repeating)        return;    Rosegarden::Segment &segment(staff.getSegment());    // send note off (note on at zero velocity)    Rosegarden::Composition &comp = getDocument()->getComposition();    Rosegarden::Studio &studio = getDocument()->getStudio();    Rosegarden::Track *track = comp.getTrackById(segment.getTrack());    Rosegarden::Instrument *ins =        studio.getInstrumentById(track->getInstrument());    // check for null instrument    //    if (ins == 0)        return;    evPitch = evPitch + segment.getTranspose();    if (evPitch < 0 || evPitch > 127) return;    Rosegarden::MappedEvent mE(ins->getId(),                               Rosegarden::MappedEvent::MidiNote,                               evPitch,                               0,                               Rosegarden::RealTime::zeroTime,                               Rosegarden::RealTime::zeroTime,                               Rosegarden::RealTime::zeroTime);    Rosegarden::StudioControl::sendMappedEvent(mE);}void MatrixView::slotVerticalScrollPianoKeyboard(int y){    if (m_pianoView) // check that the piano view still exists (see dtor)        m_pianoView->setContentsPos(0, y);}void MatrixView::slotInsertNoteFromAction(){    const QObject *s = sender();    QString name = s->name();    Segment &segment = *getCurrentSegment();    int pitch = 0;    Accidental accidental =        Accidentals::NoAccidental;    timeT time(getInsertionTime());    ::Rosegarden::Key key = segment.getKeyAtTime(time);    Clef clef = segment.getClefAtTime(time);    try {        pitch = getPitchFromNoteInsertAction(name, accidental, clef, key);    } catch (...) {        KMessageBox::sorry        (this, i18n("Unknown note insert action %1").arg(name));        return ;    }    KTmpStatusMsg msg(i18n("Inserting note"), this);    MATRIX_DEBUG << "Inserting note at pitch " << pitch << endl;    Event modelEvent(Note::EventType, 0, 1);    modelEvent.set<Int>(BaseProperties::PITCH, pitch);    modelEvent.set<String>(BaseProperties::ACCIDENTAL, accidental);    timeT endTime(time + m_snapGrid->getSnapTime(time));    MatrixInsertionCommand* command =        new MatrixInsertionCommand(segment, time, endTime, &modelEvent);    addCommandToHistory(command);    if (!isInChordMode()) {        slotSetInsertCursorPosition(endTime);    }}void MatrixView::closeWindow(){    delete this;}bool MatrixView::canPreviewAnotherNote(){    static time_t lastCutOff = 0;    static int sinceLastCutOff = 0;    time_t now = time(0);    ++sinceLastCutOff;    if ((now - lastCutOff) > 0) {        sinceLastCutOff = 0;        lastCutOff = now;    } else {        if (sinceLastCutOff >= 20) {            // don't permit more than 20 notes per second, to avoid            // gungeing up the sound drivers            MATRIX_DEBUG << "Rejecting preview (too busy)" << endl;            return false;        }    }    return true;}void MatrixView::playNote(Event *event){    // Only play note events    //    if (!event->isa(Note::EventType))        return ;    Composition &comp = getDocument()->getComposition();    Studio &studio = getDocument()->getStudio();    // Get the Instrument    //    Track *track = comp.getTrackById(                       m_staffs[0]->getSegment().getTrack());    Instrument *ins =        studio.getInstrumentById(track->getInstrument());    if (ins == 0)        return ;    if (!canPreviewAnotherNote())        return ;    // Get a velocity    //    MidiByte velocity = MidiMaxValue / 4; // be easy on the user's ears    long eventVelocity = 0;    if (event->get            <Int>(BaseProperties::VELOCITY, eventVelocity))        velocity = eventVelocity;    RealTime duration =        comp.getElapsedRealTime(event->getDuration());    // create    MappedEvent mE(ins->getId(),                   MappedEvent::MidiNoteOneShot,                   (MidiByte)                   event->get                   <Int>                   (BaseProperties::PITCH) +                   m_staffs[0]->getSegment().getTranspose(),                   velocity,                   RealTime::zeroTime,                   duration,                   RealTime::zeroTime);    StudioControl::sendMappedEvent(mE);}void MatrixView::playNote(const Segment &segment, int pitch,                          int velocity){    Composition &comp = getDocument()->getComposition();    Studio &studio = getDocument()->getStudio();    Track *track = comp.getTrackById(segment.getTrack());    Instrument *ins =        studio.getInstrumentById(track->getInstrument());    // check for null instrument    //    if (ins == 0)        return ;    if (velocity < 0)        velocity = getCurrentVelocity();    MappedEvent mE(ins->getId(),                   MappedEvent::MidiNoteOneShot,                   pitch + segment.getTranspose(),                   velocity,                   RealTime::zeroTime,                   RealTime(0, 250000000),                   RealTime::zeroTime);    StudioControl::sendMappedEvent(mE);}MatrixStaff*MatrixView::getStaff(const Segment &segment){    for (unsigned int i = 0; i < m_staffs.size(); ++i) {        if (&(m_staffs[i]->getSegment()) == &segment)            return m_staffs[i];    }    return 0;}voidMatrixView::setSingleSelectedEvent(int staffNo, Event *event,                                   bool preview, bool redrawNow){    setSingleSelectedEvent(getStaff(staffNo)->getSegment(), event,                           preview, redrawNow);}voidMatrixView:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -