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

📄 trackparameterbox.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        if (devId != (DeviceId)(currentDevId)) {            currentDevId = int(devId);            QString deviceName = strtoqstr(device->getName());            m_playDevice->insertItem(deviceName);            m_playDeviceIds.push_back(currentDevId);        }        if (pname != "")            iname += " (" + pname + ")";        m_instrumentIds[currentDevId].push_back((*it)->getId());        m_instrumentNames[currentDevId].append(iname);    }    m_playDevice->setCurrentItem( -1);    m_instrument->setCurrentItem( -1);}voidTrackParameterBox::populateRecordingDeviceList(){    RG_DEBUG << "TrackParameterBox::populateRecordingDeviceList()\n";    if (m_selectedTrackId < 0)        return ;    Composition &comp = m_doc->getComposition();    Track *trk = comp.getTrackById(m_selectedTrackId);    if (!trk)        return ;    Instrument *inst = m_doc->getStudio().getInstrumentById(trk->getInstrument());    if (!inst)        return ;    if (m_lastInstrumentType != (char)inst->getInstrumentType()) {        m_lastInstrumentType = (char)inst->getInstrumentType();        m_recDevice->clear();        m_recDeviceIds.clear();        m_recChannel->clear();        if (inst->getInstrumentType() == Instrument::Audio) {            m_recDeviceIds.push_back(Device::NO_DEVICE);            m_recDevice->insertItem(i18n("Audio"));            m_recChannel->insertItem(i18n("Audio"));            m_recDevice->setEnabled(false);            m_recChannel->setEnabled(false);            // hide these for audio instruments            m_defaultsGroup->parentWidget()->setShown(false);        } else { // InstrumentType::Midi and InstrumentType::SoftSynth            // show these if not audio instrument            m_defaultsGroup->parentWidget()->setShown(true);            m_recDeviceIds.push_back(Device::ALL_DEVICES);            m_recDevice->insertItem(i18n("All"));            DeviceList *devices = m_doc->getStudio().getDevices();            DeviceListConstIterator it;            for (it = devices->begin(); it != devices->end(); it++) {                MidiDevice *dev =                    dynamic_cast<MidiDevice*>(*it);                if (dev) {                    if (dev->getDirection() == MidiDevice::Record                            && dev->isRecording()) {                        QString connection = strtoqstr(dev->getConnection());                        // remove trailing "(duplex)", "(read only)", "(write only)" etc                        connection.replace(QRegExp("\\s*\\([^)0-9]+\\)\\s*$"), "");                        m_recDevice->insertItem(connection);                        m_recDeviceIds.push_back(dev->getId());                    }                }            }            m_recChannel->insertItem(i18n("All"));            for (int i = 1; i < 17; ++i) {                m_recChannel->insertItem(QString::number(i));            }            m_recDevice->setEnabled(true);            m_recChannel->setEnabled(true);        }    }    if (inst->getInstrumentType() == Instrument::Audio) {        m_recDevice->setCurrentItem(0);        m_recChannel->setCurrentItem(0);    } else {        m_recDevice->setCurrentItem(0);        m_recChannel->setCurrentItem((int)trk->getMidiInputChannel() + 1);        for (unsigned int i = 0; i < m_recDeviceIds.size(); ++i) {            if (m_recDeviceIds[i] == trk->getMidiInputDevice()) {                m_recDevice->setCurrentItem(i);                break;            }        }    }}voidTrackParameterBox::updateHighLow(){    Composition &comp = m_doc->getComposition();    Track *trk = comp.getTrackById(comp.getSelectedTrack());    if (!trk)        return ;    trk->setHighestPlayable(m_highestPlayable);    trk->setLowestPlayable(m_lowestPlayable);    Accidental accidental = Accidentals::NoAccidental;    Pitch highest(m_highestPlayable, accidental);    Pitch lowest(m_lowestPlayable, accidental);    KConfig *config = kapp->config();    config->setGroup(GeneralOptionsConfigGroup);    int base = config->readNumEntry("midipitchoctave", -2);    bool useSharps = true;    bool includeOctave = true;//    m_highButton->setText(i18n("High: %1").arg(highest.getAsString(useSharps, includeOctave, base)));//    m_lowButton->setText(i18n("Low: %1").arg(lowest.getAsString(useSharps, includeOctave, base)));    m_highButton->setText(QString("%1").arg(highest.getAsString(useSharps, includeOctave, base)));    m_lowButton->setText(QString("%1").arg(lowest.getAsString(useSharps, includeOctave, base)));    m_presetLbl->setEnabled(false);}voidTrackParameterBox::slotUpdateControls(int /*dummy*/){    RG_DEBUG << "TrackParameterBox::slotUpdateControls()\n";    slotPlaybackDeviceChanged( -1);    slotInstrumentChanged( -1);    if (m_selectedTrackId < 0)        return ;    Composition &comp = m_doc->getComposition();    Track *trk = comp.getTrackById(m_selectedTrackId);    if (!trk)        return ;    m_presetLbl->setText(trk->getPresetLabel());    m_presetLbl->setEnabled(true);    m_defClef->setCurrentItem(trk->getClef());    m_defTranspose->setCurrentItem(QString("%1").arg(trk->getTranspose()), true);    m_defColor->setCurrentItem(trk->getColor());    m_highestPlayable = trk->getHighestPlayable();    m_lowestPlayable = trk->getLowestPlayable();}voidTrackParameterBox::slotSelectedTrackChanged(){    RG_DEBUG << "TrackParameterBox::slotSelectedTrackChanged()\n";    Composition &comp = m_doc->getComposition();    TrackId newTrack = comp.getSelectedTrack();    if ( newTrack != m_selectedTrackId ) {        m_presetLbl->setEnabled(true);        m_selectedTrackId = newTrack;        slotSelectedTrackNameChanged();        slotUpdateControls( -1);    }}voidTrackParameterBox::slotSelectedTrackNameChanged(){    RG_DEBUG << "TrackParameterBox::sotSelectedTrackNameChanged()\n";    Composition &comp = m_doc->getComposition();    Track *trk = comp.getTrackById(m_selectedTrackId);    QString m_trackName = trk->getLabel();    if (m_trackName.isEmpty())        m_trackName = i18n("<untitled>");    else        m_trackName.truncate(20);    int m_trackNum = m_selectedTrackId + 1;    m_trackLabel->setText(i18n("[ Track %1 - %2 ]").arg(m_trackNum).arg(m_trackName));}voidTrackParameterBox::slotPlaybackDeviceChanged(int index){    RG_DEBUG << "TrackParameterBox::slotPlaybackDeviceChanged(" << index << ")\n";    DeviceId devId;    if (index == -1) {        if (m_selectedTrackId < 0)            return ;        Composition &comp = m_doc->getComposition();        Track *trk = comp.getTrackById(m_selectedTrackId);        if (!trk)            return ;        Instrument *inst = m_doc->getStudio().getInstrumentById(trk->getInstrument());        if (!inst)            return ;        devId = inst->getDevice()->getId();        int pos = -1;        IdsVector::const_iterator it;        for ( it = m_playDeviceIds.begin(); it != m_playDeviceIds.end(); ++it) {            pos++;            if ((*it) == devId)                break;        }        m_playDevice->setCurrentItem(pos);    } else {        devId = m_playDeviceIds[index];    }    m_instrument->clear();    m_instrument->insertStringList(m_instrumentNames[devId]);    populateRecordingDeviceList();    if (index != -1) {        m_instrument->setCurrentItem(0);        slotInstrumentChanged(0);    }}voidTrackParameterBox::slotInstrumentChanged(int index){    RG_DEBUG << "TrackParameterBox::slotInstrumentChanged(" << index << ")\n";    DeviceId devId;    Instrument *inst;    if (index == -1) {        Composition &comp = m_doc->getComposition();        Track *trk = comp.getTrackById(comp.getSelectedTrack());        if (!trk)            return ;        inst = m_doc->getStudio().getInstrumentById(trk->getInstrument());        if (!inst)            return ;        devId = inst->getDevice()->getId();        int pos = -1;        IdsVector::const_iterator it;        for ( it = m_instrumentIds[devId].begin(); it != m_instrumentIds[devId].end(); ++it ) {            pos++;            if ((*it) == trk->getInstrument())                break;        }        m_instrument->setCurrentItem(pos);    } else {        devId = m_playDeviceIds[m_playDevice->currentItem()];        // set the new selected instrument for the track        int item = 0;        std::map<DeviceId, IdsVector>::const_iterator it;        for ( it = m_instrumentIds.begin(); it != m_instrumentIds.end(); ++it) {            if ( (*it).first == devId )                break;            item += (*it).second.size();        }        item += index;        RG_DEBUG << "TrackParameterBox::slotInstrumentChanged() item = " << item << "\n";        emit instrumentSelected( m_selectedTrackId, item );    }}voidTrackParameterBox::slotRecordingDeviceChanged(int index){    RG_DEBUG << "TrackParameterBox::slotRecordingDeviceChanged(" << index << ")" << endl;    Composition &comp = m_doc->getComposition();    Track *trk = comp.getTrackById(comp.getSelectedTrack());    if (!trk)        return ;    Instrument *inst = m_doc->getStudio().getInstrumentById(trk->getInstrument());    if (!inst)        return ;    if (inst->getInstrumentType() == Instrument::Audio) {        //Not implemented yet    } else {        trk->setMidiInputDevice(m_recDeviceIds[index]);    }}voidTrackParameterBox::slotRecordingChannelChanged(int index){    RG_DEBUG << "TrackParameterBox::slotRecordingChannelChanged(" << index << ")" << endl;    Composition &comp = m_doc->getComposition();    Track *trk = comp.getTrackById(comp.getSelectedTrack());    if (!trk)        return ;    Instrument *inst = m_doc->getStudio().getInstrumentById(trk->getInstrument());    if (!inst)        return ;    if (inst->getInstrumentType() == Instrument::Audio) {        //Not implemented yet    } else {        trk->setMidiInputChannel(index - 1);    }}voidTrackParameterBox::slotInstrumentLabelChanged(InstrumentId id, QString label){    RG_DEBUG << "TrackParameterBox::slotInstrumentLabelChanged(" << id << ") = " << label << "\n";    populatePlaybackDeviceList();    slotUpdateControls( -1);}voidTrackParameterBox::showAdditionalControls(bool showThem){    //    m_defaultsGroup->parentWidget()->setShown(showThem);}voidTrackParameterBox::slotClefChanged(int clef){    RG_DEBUG << "TrackParameterBox::slotClefChanged(" << clef << ")" << endl;    Composition &comp = m_doc->getComposition();    Track *trk = comp.getTrackById(comp.getSelectedTrack());    trk->setClef(clef);    m_presetLbl->setEnabled(false);}voidTrackParameterBox::slotTransposeChanged(int transpose){    RG_DEBUG << "TrackParameterBox::slotTransposeChanged(" << transpose << ")" << endl;    Composition &comp = m_doc->getComposition();    Track *trk = comp.getTrackById(comp.getSelectedTrack());    trk->setTranspose(transpose);    m_presetLbl->setEnabled(false);}voidTrackParameterBox::slotTransposeIndexChanged(int index){    slotTransposeTextChanged(m_defTranspose->text(index));}voidTrackParameterBox::slotTransposeTextChanged(QString text){    if (text.isEmpty())        return ;    int value = text.toInt();    slotTransposeChanged(value);}voidTrackParameterBox::slotDocColoursChanged(){    RG_DEBUG << "TrackParameterBox::slotDocColoursChanged()" << endl;    m_defColor->clear();    m_colourList.clear();    // Populate it from composition.m_segmentColourMap    ColourMap temp = m_doc->getComposition().getSegmentColourMap();    unsigned int i = 0;    for (RCMap::const_iterator it = temp.begin(); it != temp.end(); ++it) {        QString qtrunc(strtoqstr(it->second.second));        QPixmap colour(15, 15);        colour.fill(GUIPalette::convertColour(it->second.first));        if (qtrunc == "") {            m_defColor->insertItem(colour, i18n("Default"), i);        } else {            // truncate name to 15 characters to avoid the combo forcing the            // whole kit and kaboodle too wide            if (qtrunc.length() > 15)                qtrunc = qtrunc.left(12) + "...";            m_defColor->insertItem(colour, qtrunc, i);        }        m_colourList[it->first] = i; // maps colour number to menu index        ++i;    }    m_addColourPos = i;    m_defColor->insertItem(i18n("Add New Color"), m_addColourPos);    m_defColor->setCurrentItem(0);}voidTrackParameterBox::slotColorChanged(int index){    RG_DEBUG << "TrackParameterBox::slotColorChanged(" << index << ")" << endl;    Composition &comp = m_doc->getComposition();    Track *trk = comp.getTrackById(comp.getSelectedTrack());    //!!! Tentative fix for #1527462.  I haven't worked out where the -1    // comes from, but it is consistent.  I'm going to try a +1 here to see if    // it cures this, though I don't quite understand why it would.//    trk->setColor(index + 1);    trk->setColor(index);    if (index == m_addColourPos) {        ColourMap newMap = m_doc->getComposition().getSegmentColourMap();        QColor newColour;        bool ok = false;        QString newName = KLineEditDlg::getText(i18n("New Color Name"), i18n("Enter new name"),                                                i18n("New"), &ok);        if ((ok == true) && (!newName.isEmpty())) {            KColorDialog box(this, "", true);            int result = box.getColor(newColour);            if (result == KColorDialog::Accepted) {                Colour newRColour = GUIPalette::convertColour(newColour);                newMap.addItem(newRColour, qstrtostr(newName));                slotDocColoursChanged();            }        }        // Else we don't do anything as they either didn't give a name

⌨️ 快捷键说明

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