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

📄 sequencemanager.cpp

📁 LINUX下的混音软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                        m_reportTimer->start(5000, true);                    }                }            } else {                KStartupLogo::hideIfStillThere();                if ((*i)->getType() == MappedEvent::SystemFailure) {                    if ((*i)->getData1() == MappedEvent::FailureJackRestartFailed) {                        KMessageBox::error(                            dynamic_cast<QWidget*>(m_doc->parent())->parentWidget(),                            i18n("The JACK Audio subsystem has failed or it has stopped Rosegarden from processing audio.\nPlease restart Rosegarden to continue working with audio.\nQuitting other running applications may improve Rosegarden's performance."));                    } else if ((*i)->getData1() == MappedEvent::FailureJackRestart) {                        KMessageBox::error(                            dynamic_cast<QWidget*>(m_doc->parent())->parentWidget(),                            i18n("The JACK Audio subsystem has stopped Rosegarden from processing audio, probably because of a processing overload.\nAn attempt to restart the audio service has been made, but some problems may remain.\nQuitting other running applications may improve Rosegarden's performance."));                    } else if ((*i)->getData1() == MappedEvent::WarningImpreciseTimer &&                               shouldWarnForImpreciseTimer()) {                        std::cerr << "Rosegarden: WARNING: No accurate sequencer timer available" << std::endl;                        KStartupLogo::hideIfStillThere();                        CurrentProgressDialog::freeze();                        KMessageBox::information(                            dynamic_cast<QWidget*>(m_doc->parent())->parentWidget(),                            i18n("<h3>System timer resolution is too low</h3><p>Rosegarden was unable to find a high-resolution timing source for MIDI performance.</p><p>This may mean you are using a Linux system with the kernel timer resolution set too low.  Please contact your Linux distributor for more information.</p><p>Some Linux distributors already provide low latency kernels, see <a href=\"http://rosegarden.wiki.sourceforge.net/Low+latency+kernels\">http://rosegarden.wiki.sourceforge.net/Low+latency+kernels</a> for instructions.</p>"), 			    NULL, NULL, 			    KMessageBox::Notify + KMessageBox::AllowLink);                                                CurrentProgressDialog::thaw();                    }                }            }        }    }    // if we aren't playing or recording, consider invoking any    // step-by-step clients (using unfiltered composition).  send    // out any incoming external controller events    for (i = mC.begin(); i != mC.end(); ++i ) {        if (m_transportStatus == STOPPED ||            m_transportStatus == RECORDING_ARMED) {            if ((*i)->getType() == MappedEvent::MidiNote) {                if ((*i)->getVelocity() == 0) {                    emit insertableNoteOffReceived((*i)->getPitch(), (*i)->getVelocity());                } else {                    emit insertableNoteOnReceived((*i)->getPitch(), (*i)->getVelocity());                }            }        }        if ((*i)->getRecordedDevice() == Device::CONTROL_DEVICE) {            SEQMAN_DEBUG << "controllerDeviceEventReceived" << endl;            emit controllerDeviceEventReceived(*i);        }    }}voidSequenceManager::rewindToBeginning(){    SEQMAN_DEBUG << "SequenceManager::rewindToBeginning()\n";    m_doc->slotSetPointerPosition(m_doc->getComposition().getStartMarker());}voidSequenceManager::fastForwardToEnd(){    SEQMAN_DEBUG << "SequenceManager::fastForwardToEnd()\n";    Composition &comp = m_doc->getComposition();    m_doc->slotSetPointerPosition(comp.getDuration());}voidSequenceManager::setLoop(const timeT &lhs, const timeT &rhs){    // do not set a loop if JACK transport sync is enabled, because this is    // completely broken, and apparently broken due to a limitation of JACK    // transport itself.  #1240039 - DMM    //    KConfig* config = kapp->config();    //    config->setGroup(SequencerOptionsConfigGroup);    //    if (config->readBoolEntry("jacktransport", false))    //    {    //	//!!! message box should go here to inform user of why the loop was    //	// not set, but I can't add it at the moment due to to the pre-release    //	// freeze - DMM    //	return;    //    }    // Let the sequencer know about the loop markers    //    QByteArray data;    QDataStream streamOut(data, IO_WriteOnly);    RealTime loopStart =        m_doc->getComposition().getElapsedRealTime(lhs);    RealTime loopEnd =        m_doc->getComposition().getElapsedRealTime(rhs);    streamOut << (long)loopStart.sec;    streamOut << (long)loopStart.nsec;    streamOut << (long)loopEnd.sec;    streamOut << (long)loopEnd.nsec;    rgapp->sequencerSend("setLoop(long int, long int, long int, long int)", data);}voidSequenceManager::checkSoundDriverStatus(bool warnUser){    QByteArray data;    QCString replyType;    QByteArray replyData;    QDataStream streamOut(data, IO_WriteOnly);    streamOut << QString(VERSION);    if (! rgapp->sequencerCall("getSoundDriverStatus(QString)",                               replyType, replyData, data)) {        m_soundDriverStatus = NO_DRIVER;    } else {        QDataStream streamIn(replyData, IO_ReadOnly);        unsigned int result;        streamIn >> result;        m_soundDriverStatus = result;    }    SEQMAN_DEBUG << "Sound driver status is: " << m_soundDriverStatus << endl;    if (!warnUser) return;#ifdef HAVE_LIBJACK    if ((m_soundDriverStatus & (AUDIO_OK | MIDI_OK | VERSION_OK)) ==        (AUDIO_OK | MIDI_OK | VERSION_OK)) return;#else    if ((m_soundDriverStatus & (MIDI_OK | VERSION_OK)) ==        (MIDI_OK | VERSION_OK)) return;#endif    KStartupLogo::hideIfStillThere();    CurrentProgressDialog::freeze();    QString text = "";    if (m_soundDriverStatus == NO_DRIVER) {        text = i18n("<p>Both MIDI and Audio subsystems have failed to initialize.</p><p>You may continue without the sequencer, but we suggest closing Rosegarden, running \"alsaconf\" as root, and starting Rosegarden again.  If you wish to run with no sequencer by design, then use \"rosegarden --nosequencer\" to avoid seeing this error in the future.</p>");    } else if (!(m_soundDriverStatus & MIDI_OK)) {        text = i18n("<p>The MIDI subsystem has failed to initialize.</p><p>You may continue without the sequencer, but we suggest closing Rosegarden, running \"modprobe snd-seq-midi\" as root, and starting Rosegarden again.  If you wish to run with no sequencer by design, then use \"rosegarden --nosequencer\" to avoid seeing this error in the future.</p>");    } else if (!(m_soundDriverStatus & VERSION_OK)) {        text = i18n("<p>The Rosegarden sequencer module version does not match the GUI module version.</p><p>You have probably mixed up files from two different versions of Rosegarden.  Please check your installation.</p>");    }    if (text != "") {        KMessageBox::error(dynamic_cast<QWidget*>(m_doc->parent())->parentWidget(), i18n("<h3>Sequencer startup failed</h3>%1").arg(text));        CurrentProgressDialog::thaw();        return;    }#ifdef HAVE_LIBJACK    if (!(m_soundDriverStatus & AUDIO_OK)) {        KMessageBox::information(dynamic_cast<QWidget*>(m_doc->parent())->parentWidget(), i18n("<h3>Failed to connect to JACK audio server.</h3><p>Rosegarden could not connect to the JACK audio server.  This probably means the JACK server is not running.</p><p>If you want to be able to play or record audio files or use plugins, you should exit Rosegarden and start the JACK server before running Rosegarden again.</p>"),                                 i18n("Failed to connect to JACK"),                                 "startup-jack-failed");    }#endif    CurrentProgressDialog::thaw();}voidSequenceManager::preparePlayback(bool forceProgramChanges){    Studio &studio = m_doc->getStudio();    InstrumentList list = studio.getAllInstruments();    MappedComposition mC;    MappedEvent *mE;    std::set<InstrumentId> activeInstruments;    Composition &composition = m_doc->getComposition();    for (Composition::trackcontainer::const_iterator i =             composition.getTracks().begin();         i != composition.getTracks().end(); ++i) {        Track *track = i->second;        if (track) activeInstruments.insert(track->getInstrument());    }    // Send the MappedInstruments (minimal Instrument information    // required for Performance) to the Sequencer    //    InstrumentList::iterator it = list.begin();    for (; it != list.end(); it++) {        StudioControl::sendMappedInstrument(MappedInstrument(*it));        // Send program changes for MIDI Instruments        //        if ((*it)->getType() == Instrument::Midi) {            if (activeInstruments.find((*it)->getId()) ==                activeInstruments.end()) {//                std::cerr << "SequenceManager::preparePlayback: instrument "//                          << (*it)->getId() << " is not in use" << std::endl;                continue;            }                        // send bank select always before program change            //            if ((*it)->sendsBankSelect()) {                mE = new MappedEvent((*it)->getId(),                                     MappedEvent::MidiController,                                     MIDI_CONTROLLER_BANK_MSB,                                     (*it)->getMSB());                mC.insert(mE);                mE = new MappedEvent((*it)->getId(),                                     MappedEvent::MidiController,                                     MIDI_CONTROLLER_BANK_LSB,                                     (*it)->getLSB());                mC.insert(mE);            }            // send program change            //            if ((*it)->sendsProgramChange() || forceProgramChanges) {                RG_DEBUG << "SequenceManager::preparePlayback() : sending prg change for "                << (*it)->getPresentationName().c_str() << endl;                mE = new MappedEvent((*it)->getId(),                                     MappedEvent::MidiProgramChange,                                     (*it)->getProgramChange());                mC.insert(mE);            }        } else if ((*it)->getType() == Instrument::Audio ||                   (*it)->getType() == Instrument::SoftSynth) {        } else {            RG_DEBUG << "SequenceManager::preparePlayback - "            << "unrecognised instrument type" << endl;        }    }    // Send the MappedComposition if it's got anything in it    showVisuals(mC);    StudioControl::sendMappedComposition(mC);}voidSequenceManager::sendAudioLevel(MappedEvent *mE){    RosegardenGUIView *v;    QList<RosegardenGUIView>& viewList = m_doc->getViewList();    for (v = viewList.first(); v != 0; v = viewList.next()) {        v->showVisuals(mE);    }}voidSequenceManager::resetControllers(){    SEQMAN_DEBUG << "SequenceManager::resetControllers - resetting\n";    // Should do all Midi Instrument - not just guess like this is doing    // currently.    InstrumentList list = m_doc->getStudio().getPresentationInstruments();    InstrumentList::iterator it;    MappedComposition mC;    for (it = list.begin(); it != list.end(); it++) {        if ((*it)->getType() == Instrument::Midi) {            MappedEvent *mE = new MappedEvent((*it)->getId(),                                              MappedEvent::MidiController,                                              MIDI_CONTROLLER_RESET,                                              0);            mC.insert(mE);        }    }    StudioControl::sendMappedComposition(mC);    //showVisuals(mC);}voidSequenceManager::resetMidiNetwork(){    SEQMAN_DEBUG << "SequenceManager::resetMidiNetwork - resetting\n";    MappedComposition mC;    // Should do all Midi Instrument - not just guess like this is doing    // currently.    for (unsigned int i = 0; i < 16; i++) {        MappedEvent *mE =            new MappedEvent(MidiInstrumentBase + i,                            MappedEvent::MidiController,                            MIDI_SYSTEM_RESET,                            0);        mC.insert(mE);    }    showVisuals(mC);    StudioControl::sendMappedComposition(mC);}voidSequenceManager::sendMIDIRecordingDevice(const QString recordDeviceStr){    if (recordDeviceStr) {        int recordDevice = recordDeviceStr.toInt();        if (recordDevice >= 0) {            MappedEvent mE(MidiInstrumentBase,  // InstrumentId                           MappedEvent::SystemRecordDevice,                           MidiByte(recordDevice),                           MidiByte(true));            StudioControl::sendMappedEvent(mE);            SEQMAN_DEBUG << "set MIDI record device to "            << recordDevice << endl;        }    }}voidSequenceManager::restoreRecordSubscriptions(){    KConfig* config = kapp->config();    config->setGroup(SequencerOptionsConfigGroup);    //QString recordDeviceStr = config->readEntry("midirecorddevice");    QStringList devList = config->readListEntry("midirecorddevice");    for ( QStringList::ConstIterator it = devList.begin();            it != devList.end(); ++it) {        sendMIDIRecordingDevice(*it);    }}voidSequenceManager::reinitialiseSequencerStudio(){    KConfig* config = kapp->config();    config->setGroup(SequencerOptionsConfigGroup);    //QString recordDeviceStr = config->readEntry("midirecorddevice");    //sendMIDIRecordingDevice(recordDeviceStr);    restoreRecordSubscriptions();    // Toggle JACK audio ports appropriately    //    bool submasterOuts = config->readBoolEntry("audiosubmasterouts", false);    bool faderOuts = config->readBoolEntry("audiofaderouts", false);    unsigned int audioFileFormat = config->readUnsignedNumEntry("audiorecordfileformat", 1);    MidiByte ports = 0;    if (faderOuts) {        ports |= MappedEvent::FaderOuts;    }    if (submasterOuts) {        ports |= MappedEvent::SubmasterOuts;    }    MappedEvent mEports

⌨️ 快捷键说明

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