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

📄 trackbuttons.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    Instrument *instrument = m_doc->getStudio().getInstrumentById                             (track->getInstrument());    bool audio = (instrument &&                  instrument->getType() == Instrument::Audio);    if (audio && state) {        try {            m_doc->getAudioFileManager().testAudioPath();        } catch (AudioFileManager::BadAudioPathException e) {            if (KMessageBox::warningContinueCancel                    (this,                     i18n("The audio file path does not exist or is not writable.\nPlease set the audio file path to a valid directory in Document Properties before recording audio.\nWould you like to set it now?"),                     i18n("Warning"),                     i18n("Set audio file path")) == KMessageBox::Continue) {                RosegardenGUIApp::self()->slotOpenAudioPathSettings();            }        }    }    // can have any number of audio instruments armed, but only one    // track armed per instrument.    // Need to copy this container, as we're implicitly modifying it    // through calls to comp.setTrackRecording    Composition::recordtrackcontainer oldRecordTracks =        comp.getRecordTracks();    for (Composition::recordtrackcontainer::const_iterator i =                oldRecordTracks.begin();            i != oldRecordTracks.end(); ++i) {        if (!comp.isTrackRecording(*i)) {            // We've already reset this one            continue;        }        Track *otherTrack = comp.getTrackById(*i);        if (otherTrack &&                otherTrack != track) {            /* Obsolete code: audio, MIDI and plugin tracks behave the same now.                      plcl, 06/2006 - Multitrack MIDI recording                                         bool unselect;            if (audio) {            unselect = (otherTrack->getInstrument() == track->getInstrument());            } else {            // our track is not an audio track, check that the            // other isn't either            Instrument *otherInstrument =             m_doc->getStudio().getInstrumentById(otherTrack->getInstrument());            bool otherAudio = (otherInstrument &&              otherInstrument->getType() ==               Instrument::Audio);            unselect = !otherAudio;            }            if (unselect) { */            if (otherTrack->getInstrument() == track->getInstrument()) {                // found another record track of the same type (and                // with the same instrument, if audio): unselect that                //!!! should we tell the user, particularly for the                //audio case? might seem odd otherwise                int otherPos = otherTrack->getPosition();                setRecordTrack(otherPos, false);            }        }    }    setRecordTrack(position, state);    emit recordButton(track->getId(), state);}voidTrackButtons::setRecordTrack(int position, bool state){    setRecordButton(position, state);    m_doc->getComposition().setTrackRecording    (m_trackLabels[position]->getId(), state);}voidTrackButtons::setRecordButton(int position, bool state){    if (position < 0 || position >= (int)m_tracks)        return ;    KLedButton* led = m_recordLeds[position];    led->setState(state ? KLed::On : KLed::Off);}voidTrackButtons::selectLabel(int position){    if (m_lastSelected >= 0 && m_lastSelected < (int)m_trackLabels.size()) {        m_trackLabels[m_lastSelected]->setSelected(false);    }    if (position >= 0 && position < (int)m_trackLabels.size()) {        m_trackLabels[position]->setSelected(true);        m_lastSelected = position;    }}std::vector<int>TrackButtons::getHighlightedTracks(){    std::vector<int> retList;    for (unsigned int i = 0; i < m_trackLabels.size(); ++i) {        if (m_trackLabels[i]->isSelected())            retList.push_back(i);    }    return retList;}voidTrackButtons::slotRenameTrack(QString newName, TrackId trackId){    m_doc->getCommandHistory()->addCommand        (new RenameTrackCommand(&m_doc->getComposition(),                                trackId,                                qstrtostr(newName)));    changeTrackLabel(trackId, newName);}voidTrackButtons::slotSetTrackMeter(float value, int position){    //Composition &comp = m_doc->getComposition();    //Studio &studio = m_doc->getStudio();    //Track *track;    for (unsigned int i = 0; i < m_trackMeters.size(); ++i) {        if (i == ((unsigned int)position)) {            m_trackMeters[i]->setLevel(value);            return ;        }    }}voidTrackButtons::slotSetMetersByInstrument(float value,                                        InstrumentId id){    Composition &comp = m_doc->getComposition();    //Studio &studio = m_doc->getStudio();    Track *track;    for (unsigned int i = 0; i < m_trackMeters.size(); ++i) {        track = comp.getTrackByPosition(i);        if (track != 0 && track->getInstrument() == id) {            m_trackMeters[i]->setLevel(value);        }    }}voidTrackButtons::slotInstrumentSelection(int trackId){    RG_DEBUG << "TrackButtons::slotInstrumentSelection(" << trackId << ")\n";    Composition &comp = m_doc->getComposition();    Studio &studio = m_doc->getStudio();    int position = comp.getTrackById(trackId)->getPosition();    QString instrumentName = i18n("<no instrument>");    Track *track = comp.getTrackByPosition(position);    Instrument *instrument = 0;    if (track != 0) {        instrument = studio.getInstrumentById(track->getInstrument());        if (instrument)            instrumentName = strtoqstr(instrument->getPresentationName());    }    //    // populate this instrument widget    m_trackLabels[position]->getInstrumentLabel()->setText(instrumentName);    // Ensure the instrument name is shown    m_trackLabels[position]->showLabel(TrackLabel::ShowInstrument);    // Yes, well as we might've changed the Device name in the    // Device/Bank dialog then we reload the whole menu here.    //    QPopupMenu instrumentPopup(this);    populateInstrumentPopup(instrument, &instrumentPopup);    // Store the popup item position    //    m_popupItem = position;    instrumentPopup.exec(QCursor::pos());    // Restore the label back to what it was showing    m_trackLabels[position]->showLabel(m_trackInstrumentLabels);    // Do this here as well as in slotInstrumentPopupActivated, so as    // to restore the correct alternative label even if no other    // program was selected from the menu    if (track != 0) {        instrument = studio.getInstrumentById(track->getInstrument());        if (instrument) {            m_trackLabels[position]->getInstrumentLabel()->                setText(strtoqstr(instrument->getPresentationName()));            m_trackLabels[position]->clearAlternativeLabel();            if (instrument->sendsProgramChange()) {                m_trackLabels[position]->setAlternativeLabel                    (strtoqstr(instrument->getProgramName()));            }        }    }}voidTrackButtons::populateInstrumentPopup(Instrument *thisTrackInstr, QPopupMenu* instrumentPopup){    static QPixmap connectedPixmap, unconnectedPixmap,    connectedUsedPixmap, unconnectedUsedPixmap,    connectedSelectedPixmap, unconnectedSelectedPixmap;    static bool havePixmaps = false;    if (!havePixmaps) {        QString pixmapDir =            KGlobal::dirs()->findResource("appdata", "pixmaps/");        connectedPixmap.load            (QString("%1/misc/connected.xpm").arg(pixmapDir));        connectedUsedPixmap.load            (QString("%1/misc/connected-used.xpm").arg(pixmapDir));        connectedSelectedPixmap.load            (QString("%1/misc/connected-selected.xpm").arg(pixmapDir));        unconnectedPixmap.load            (QString("%1/misc/unconnected.xpm").arg(pixmapDir));        unconnectedUsedPixmap.load            (QString("%1/misc/unconnected-used.xpm").arg(pixmapDir));        unconnectedSelectedPixmap.load            (QString("%1/misc/unconnected-selected.xpm").arg(pixmapDir));        havePixmaps = true;    }    Composition &comp = m_doc->getComposition();    Studio &studio = m_doc->getStudio();    // clear the popup    instrumentPopup->clear();    std::vector<QPopupMenu*> instrumentSubMenus;    // position index    int i = 0;    // Get the list    InstrumentList list = studio.getPresentationInstruments();    InstrumentList::iterator it;    int currentDevId = -1;    bool deviceUsedByAnyone = false;    for (it = list.begin(); it != list.end(); it++) {        if (! (*it))            continue; // sanity check        QString iname(strtoqstr((*it)->getPresentationName()));        QString pname(strtoqstr((*it)->getProgramName()));        Device *device = (*it)->getDevice();        DeviceId devId = device->getId();        bool connected = false;        if ((*it)->getType() == Instrument::SoftSynth) {            pname = "";            AudioPluginInstance *plugin = (*it)->getPlugin                (Instrument::SYNTH_PLUGIN_POSITION);            if (plugin) {                pname = strtoqstr(plugin->getProgram());                QString identifier = strtoqstr(plugin->getIdentifier());                if (identifier != "") {                    connected = true;                    QString type, soName, label;                    PluginIdentifier::parseIdentifier                        (identifier, type, soName, label);                    if (pname == "") {                        pname = strtoqstr(plugin->getDistinctiveConfigurationText());                    }                    if (pname != "") {                        pname = QString("%1: %2").arg(label).arg(pname);                    } else {                        pname = label;                    }                } else {                    connected = false;                }            }        } else if ((*it)->getType() == Instrument::Audio) {            connected = true;        } else {            connected = (device->getConnection() != "");        }        bool instrUsedByMe = false;        bool instrUsedByAnyone = false;        if (thisTrackInstr && thisTrackInstr->getId() == (*it)->getId()) {            instrUsedByMe = true;            instrUsedByAnyone = true;        }        if (devId != (DeviceId)(currentDevId)) {            deviceUsedByAnyone = false;            if (instrUsedByMe)                deviceUsedByAnyone = true;            else {                for (Composition::trackcontainer::iterator tit =                         comp.getTracks().begin();                     tit != comp.getTracks().end(); ++tit) {                    if (tit->second->getInstrument() == (*it)->getId()) {                        instrUsedByAnyone = true;                        deviceUsedByAnyone = true;                        break;                    }                    Instrument *instr =                        studio.getInstrumentById(tit->second->getInstrument());                    if (instr && (instr->getDevice()->getId() == devId)) {                        deviceUsedByAnyone = true;                    }                }            }            QIconSet iconSet                (connected ?                 (deviceUsedByAnyone ?                  connectedUsedPixmap : connectedPixmap) :                 (deviceUsedByAnyone ?                  unconnectedUsedPixmap : unconnectedPixmap));            currentDevId = int(devId);            QPopupMenu *subMenu = new QPopupMenu(instrumentPopup);            QString deviceName = strtoqstr(device->getName());            instrumentPopup->insertItem(iconSet, deviceName, subMenu);            instrumentSubMenus.push_back(subMenu);            // Connect up the submenu            //            connect(subMenu, SIGNAL(activated(int)),                    SLOT(slotInstrumentPopupActivated(int)));        } else if (!instrUsedByMe) {

⌨️ 快捷键说明

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