Base *Reader::parseExpression() { skipWhitespace(); auto c = current(); if(c == kObjectBegin) { return parseObject(); } else if(c == kArrayBegin) { return parseArray(); } else if(c == kStringBegin) { return parseString(); } else if(is_number(c, true)) { return parseNumber(); } else if(borrow(gTrueString->length())->isEqual(gTrueString)) { fastForward(gTrueString->length() - 1); return Number::True(); } else if(borrow(gFalseString->length())->isEqual(gFalseString)) { fastForward(gFalseString->length() - 1); return Number::False(); } else if(borrow(gNullString->length())->isEqual(gNullString)) { fastForward(gNullString->length() - 1); return Null::shared(); } else { fail(String::Builder() << "unexpected '" << c << "'."); } return nullptr; }
void ComplementFile::processHits(RecordOutputMgr *outputMgr, RecordKeyVector &hits) { _outputMgr = outputMgr; const Record *rec = hits.getKey(); //test for chrom change. const string &newChrom = rec->getChrName(); if (_currChrom != newChrom) { outPutLastRecordInPrevChrom(); //if record's chrom doesn't exist in the genome file, do //nothing if (!fastForward(newChrom)) return; //we've switched to a new chromosome that is in both the DB //and genome file. _currStartPos = 0; _currChrom = newChrom; _outRecord.setChrName(newChrom); } // warn if the record's interval is beyond the // length of the chromosome checkCoordinatesAgainstChromLength(rec); // safe guard against the first record for the chrom // starting with 0. if (rec->getStartPos() != 0) { CHRPOS endPos = rec->getStartPos(); printRecord(endPos); } _currStartPos = rec->getEndPos(); }
void ComplementFile::processHits(RecordOutputMgr *outputMgr, RecordKeyVector &hits) { _outputMgr = outputMgr; const Record *rec = hits.getKey(); //test for chrom change. const QuickString &newChrom = rec->getChrName(); if (_currChrom != newChrom) { outPutLastRecordInPrevChrom(); //if record's chrom doesn't exist in the genome file, do //nothing if (!fastForward(newChrom)) return; //we've switched to a new chromosome that is in both the DB //and genome file. _currStartPos = 0; _currChrom = newChrom; _outRecord.setChrName(newChrom); } int endPos = rec->getStartPos(); printRecord(endPos); _currStartPos = rec->getEndPos(); }
void handleKeypress1(unsigned char key, int x, int y) { if(!board.getGameEnded()){ if(!board.striker.moving()){ if(key == 'a' || key == 'A') board.striker.changeAngle(ANGLE_FACTOR); if(key == 'c' || key =='C') board.striker.changeAngle(-1*ANGLE_FACTOR); if(key == ' '){ board.striker.startMoving(); time_t t; t=time(NULL); board.updateSTime(t); board.striker.release(); } } if (key == 'r' || key == 'R'){ fastForward(); board.striker.reset(); } } else{ if(key == 'n' || key== 'N') exit(0); if(key=='y' || key=='Y'|| key == 13){ board.init(0.0f,0.0f); a=1; } } if (key == 27) exit(0); // escape key is pressed }
bool Stream::didSeek(const Timer& timer, sf::Time oldPosition) { if (timer.getOffset() != sf::Time::Zero) return fastForward(timer.getOffset()); return true; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), timer(new QTimer(this)) { ui->setupUi(this); this->setWindowIcon(QIcon(":/icon.png")); Qt::WindowFlags flags = this->windowFlags(); this->setWindowFlags(flags | Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); // this->setAttribute(Qt::WA_TranslucentBackground, true); timer->setTimerType(Qt::PreciseTimer); // fixes subtitle delay connect(timer, SIGNAL(timeout()), this, SLOT(update())); connect(ui->backwardButton, SIGNAL(clicked()), this, SLOT(fastBackward())); connect(ui->forwardButton, SIGNAL(clicked()), this, SLOT(fastForward())); connect(ui->toggleButton, SIGNAL(clicked()), this, SLOT(togglePlay())); connect(ui->loadButton, SIGNAL(clicked()), this, SLOT(openFileDialog())); connect(ui->prefButton, SIGNAL(clicked()), this, SLOT(openSettingsWindow())); connect(ui->quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); connect(ui->horizontalSlider, SIGNAL(sliderMoved(int)), this, SLOT(sliderMoved(int))); if (QSystemTrayIcon::isSystemTrayAvailable()) { trayIcon = new QSystemTrayIcon(); trayIcon->setIcon(QIcon(":/icon.png")); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); menu = new QMenu(); QAction *settings = new QAction("Preferences", 0); connect(settings, SIGNAL(triggered()), this, SLOT(openSettingsWindow())); menu->addAction(settings); QAction *quit = new QAction("Quit", 0); connect(quit, SIGNAL(triggered()), qApp, SLOT(quit())); menu->addAction(quit); trayIcon->setContextMenu(menu); trayIcon->show(); } this->setAttribute(Qt::WA_Hover, true); ui->bottomWidgets->setAttribute(Qt::WA_NoMousePropagation); // fix window disappear problem this->loadPref(); setAcceptDrops(true); }
void AsyncTimerFactoryMock::fastForward(Milliseconds time) { stdx::lock_guard<stdx::recursive_mutex> lk(_timersMutex); _curTime += time; // Timers may be reset, so keep them in our set even if they have expired. for (auto elem = _timers.begin(); elem != _timers.end(); elem++) { auto timer = *elem; timer->fastForward(time); } }
LircCommander::LircCommander(LircClient *lirc, RosegardenMainWindow *rgGUIApp) : QObject() { m_lirc = lirc; m_rgGUIApp = rgGUIApp; connect(m_lirc, SIGNAL(buttonPressed(const char *)), this, SLOT(slotExecute(const char *)) ); connect(this, SIGNAL(play()), m_rgGUIApp, SLOT(slotPlay()) ); connect(this, SIGNAL(stop()), m_rgGUIApp, SLOT(slotStop()) ); connect(this, SIGNAL(record()), m_rgGUIApp, SLOT(slotRecord()) ); connect(this, SIGNAL(rewind()), m_rgGUIApp, SLOT(slotRewind()) ); connect(this, SIGNAL(rewindToBeginning()), m_rgGUIApp, SLOT(slotRewindToBeginning()) ); connect(this, SIGNAL(fastForward()), m_rgGUIApp, SLOT(slotFastforward()) ); connect(this, SIGNAL(fastForwardToEnd()), m_rgGUIApp, SLOT(slotFastForwardToEnd()) ); connect(this, SIGNAL(toggleRecord()), m_rgGUIApp, SLOT(slotToggleRecord()) ); connect(this, SIGNAL(trackDown()), m_rgGUIApp, SLOT(slotTrackDown()) ); connect(this, SIGNAL(trackUp()), m_rgGUIApp, SLOT(slotTrackUp()) ); connect(this, SIGNAL(trackMute()), m_rgGUIApp, SLOT(slotToggleMute()) ); connect(this, SIGNAL(trackRecord()), m_rgGUIApp, SLOT(slotToggleRecordCurrentTrack()) ); connect(this, SIGNAL(undo()), CommandHistory::getInstance(), SLOT(undo()) ); connect(this, SIGNAL(redo()), CommandHistory::getInstance(), SLOT(redo()) ); connect(this, SIGNAL(aboutrg()), m_rgGUIApp, SLOT(slotHelpAbout()) ); connect(this, SIGNAL(editInMatrix()), m_rgGUIApp, SLOT(slotEditInMatrix()) ); connect(this, SIGNAL(editInPercussionMatrix()), m_rgGUIApp, SLOT(slotEditInPercussionMatrix()) ); connect(this, SIGNAL(editInEventList()), m_rgGUIApp, SLOT(slotEditInEventList()) ); connect(this, SIGNAL(editAsNotation()), m_rgGUIApp, SLOT(slotEditAsNotation()) ); connect(this, SIGNAL(quit()), m_rgGUIApp, SLOT(slotQuit()) ); connect(this, SIGNAL(closeTransport()), m_rgGUIApp, SLOT(slotCloseTransport()) ); connect(this, SIGNAL(toggleTransportVisibility()), m_rgGUIApp, SLOT(slotToggleTransportVisibility()) ); }
void Player::connectTransport(const TransportControllable* receiver) { if (receiver == m_currentTransport) return; if (m_currentTransport) disconnect(m_currentTransport); m_currentTransport = receiver; connect(this, SIGNAL(played(double)), receiver, SLOT(play(double))); connect(this, SIGNAL(paused()), receiver, SLOT(pause())); connect(this, SIGNAL(stopped()), receiver, SLOT(stop())); connect(this, SIGNAL(seeked(int)), receiver, SLOT(seek(int))); connect(this, SIGNAL(rewound()), receiver, SLOT(rewind())); connect(this, SIGNAL(fastForwarded()), receiver, SLOT(fastForward())); connect(this, SIGNAL(previousSought(int)), receiver, SLOT(previous(int))); connect(this, SIGNAL(nextSought(int)), receiver, SLOT(next(int))); connect(this, SIGNAL(inChanged(int)), receiver, SLOT(setIn(int))); connect(this, SIGNAL(outChanged(int)), receiver, SLOT(setOut(int))); }
void AsyncTimerFactoryMock::fastForward(Milliseconds time) { stdx::lock_guard<stdx::mutex> lk(_timersMutex); _curTime += time; // erase after iterating to be safe stdx::unordered_set<std::shared_ptr<AsyncTimerMockImpl>> expired; for (auto elem = _timers.begin(); elem != _timers.end(); elem++) { auto timer = *elem; // If timer has expired, register it for removal from our set. if (!timer->fastForward(time)) { expired.insert(timer); } } for (auto elem = expired.begin(); elem != expired.end(); elem++) { _timers.erase(*elem); } }
ReplayConductor::ReplayConductor( orcalog::MasterFileReader &masterFileReader, std::vector<orcalog::Replayer*> &replayers, const IceUtil::Time &beginTime, double replayRate, const orcaice::Context &context ) : SubsystemThread( context.tracer(), context.status() ), isPlaying_(false), isPlayingOrAboutToStart_(false), masterFileReader_(masterFileReader), replayers_(replayers), context_(context) { clock_.setReplayRate(replayRate); bool cursorValid = masterFileReader_.getCursorTime( firstItemSec_, firstItemUsec_ ); assert( cursorValid ); // Fast-forward if non-zero beginTime if ( beginTime > orcalog::iceUtilTime(0,0) ) { fastForward( beginTime ); } }
//----------------------------------------------------------------------- void ParticleSystem::start(void) { // Generate the event; this must be done at the start _pushSystemEvent(PU_EVT_SYSTEM_STARTING); setVisible(true); mState = ParticleSystem::PSS_STARTED; mTimeElapsedSinceStart = 0; mLastVisibleFrame = 0; mTimeSinceLastVisible = 0; mTimeSinceLastUpdate = 0; mBoundsUpdateTime = mOriginalBoundsUpdateTime; ParticleTechniqueIterator it; ParticleTechniqueIterator itEnd = mTechniques.end(); mAABB.setExtents(0, 0, 0, 0, 0, 0); mFastForwardSet = mOriginalFastForwardSet; position = Vector3::ZERO; mDerivedPosition = Vector3::ZERO; latestPosition = getDerivedPosition(); mLatestOrientation = getDerivedOrientation(); // Added for 1.3 (orientation not pr) mEnabled = true; mStopFadeSet = false; mAtLeastOneParticleEmitted = false; mLastLodIndex = 0; // This triggers the event at least once if lod distances are used. // Run through the ParticleTechniques to perform some start-initialisation actions. for (it = mTechniques.begin(); it != itEnd; ++it) { (*it)->_notifyStart(); } // Perform fast forward if needed (the fastforward() function determines whether it is needed) fastForward(); // Generate the event; this must be done at the end _pushSystemEvent(PU_EVT_SYSTEM_STARTED); }
void PhMediaPanel::onFastForward() { if(_clock) _clock->setRate(3); emit fastForward(); }
Player::Player(QWidget *parent) : QWidget(parent) , m_position(0) , m_isMeltedPlaying(-1) , m_zoomToggleFactor(Settings.playerZoom() == 0.0f? 1.0f : Settings.playerZoom()) , m_pauseAfterOpen(false) , m_monitorScreen(-1) , m_currentTransport(0) { setObjectName("Player"); Mlt::Controller::singleton(); setupActions(this); m_playIcon = actionPlay->icon(); m_pauseIcon = actionPause->icon(); // Create a layout. QVBoxLayout *vlayout = new QVBoxLayout(this); vlayout->setObjectName("playerLayout"); vlayout->setContentsMargins(0, 0, 0, 0); vlayout->setSpacing(4); // Add tab bar to indicate/select what is playing: clip, playlist, timeline. m_tabs = new QTabBar; m_tabs->setShape(QTabBar::RoundedSouth); m_tabs->addTab(tr("Source")); m_tabs->addTab(tr("Program")); m_tabs->setTabEnabled(ProgramTabIndex, false); QHBoxLayout* tabLayout = new QHBoxLayout; tabLayout->addWidget(m_tabs); tabLayout->addStretch(); connect(m_tabs, SIGNAL(tabBarClicked(int)), SLOT(onTabBarClicked(int))); // Add the layouts for managing video view, scroll bars, and audio controls. m_videoLayout = new QHBoxLayout; m_videoLayout->setSpacing(4); m_videoLayout->setContentsMargins(0, 0, 0, 0); vlayout->addLayout(m_videoLayout, 10); vlayout->addStretch(); m_videoScrollWidget = new QWidget; m_videoLayout->addWidget(m_videoScrollWidget, 10); m_videoLayout->addStretch(); QGridLayout* glayout = new QGridLayout(m_videoScrollWidget); glayout->setSpacing(0); glayout->setContentsMargins(0, 0, 0, 0); // Add the video widgets. m_videoWidget = QWidget::createWindowContainer(qobject_cast<QWindow*>(MLT.videoWidget())); m_videoWidget->setMinimumSize(QSize(320, 180)); glayout->addWidget(m_videoWidget, 0, 0); m_verticalScroll = new QScrollBar(Qt::Vertical); glayout->addWidget(m_verticalScroll, 0, 1); m_verticalScroll->hide(); m_horizontalScroll = new QScrollBar(Qt::Horizontal); glayout->addWidget(m_horizontalScroll, 1, 0); m_horizontalScroll->hide(); // Add the volume and signal level meter m_volumePopup = new QFrame(this, Qt::Popup); QVBoxLayout *volumeLayoutV = new QVBoxLayout(m_volumePopup); volumeLayoutV->setContentsMargins(0, 0, 0, 0); volumeLayoutV->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); QBoxLayout *volumeLayoutH = new QHBoxLayout; volumeLayoutH->setSpacing(0); volumeLayoutH->setContentsMargins(0, 0, 0, 0); volumeLayoutH->addWidget(new AudioScale); m_volumeSlider = new QSlider(Qt::Vertical); m_volumeSlider->setFocusPolicy(Qt::NoFocus); m_volumeSlider->setMinimumHeight(VOLUME_SLIDER_HEIGHT); m_volumeSlider->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); volumeLayoutH->addWidget(m_volumeSlider); volumeLayoutV->addLayout(volumeLayoutH); m_volumeSlider->setRange(0, 99); m_volumeSlider->setValue(Settings.playerVolume()); onVolumeChanged(m_volumeSlider->value()); m_savedVolume = MLT.volume(); m_volumeSlider->setToolTip(tr("Adjust the audio volume")); connect(m_volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(onVolumeChanged(int))); // Add mute-volume buttons layout #ifdef Q_OS_MAC if (Settings.theme() == "system") volumeLayoutH = new QVBoxLayout; else #endif volumeLayoutH = new QHBoxLayout; volumeLayoutH->setContentsMargins(0, 0, 0, 0); volumeLayoutH->setSpacing(0); volumeLayoutV->addLayout(volumeLayoutH); // Add mute button QPushButton* muteButton = new QPushButton(this); muteButton->setFocusPolicy(Qt::NoFocus); muteButton->setObjectName(QString::fromUtf8("muteButton")); muteButton->setIcon(QIcon::fromTheme("dialog-cancel", QIcon(":/icons/oxygen/16x16/actions/dialog-cancel.png"))); muteButton->setToolTip(tr("Silence the audio")); muteButton->setCheckable(true); muteButton->setChecked(Settings.playerMuted()); onMuteButtonToggled(Settings.playerMuted()); volumeLayoutH->addWidget(muteButton); connect(muteButton, SIGNAL(toggled(bool)), this, SLOT(onMuteButtonToggled(bool))); // This hack realizes the volume popup geometry for on_actionVolume_triggered(). m_volumePopup->show(); m_volumePopup->hide(); // Add the scrub bar. m_scrubber = new ScrubBar(this); m_scrubber->setFocusPolicy(Qt::NoFocus); m_scrubber->setObjectName("scrubBar"); m_scrubber->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); vlayout->addWidget(m_scrubber); // Add toolbar for transport controls. QToolBar* toolbar = new QToolBar(tr("Transport Controls"), this); int s = style()->pixelMetric(QStyle::PM_SmallIconSize); toolbar->setIconSize(QSize(s, s)); toolbar->setContentsMargins(0, 0, 0, 0); QWidget *spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); m_positionSpinner = new TimeSpinBox(this); m_positionSpinner->setToolTip(tr("Current position")); m_positionSpinner->setEnabled(false); m_positionSpinner->setKeyboardTracking(false); m_durationLabel = new QLabel(this); m_durationLabel->setToolTip(tr("Total Duration")); m_durationLabel->setText(" / 00:00:00:00"); m_durationLabel->setFixedWidth(m_positionSpinner->width()); m_inPointLabel = new QLabel(this); m_inPointLabel->setText("--:--:--:--"); m_inPointLabel->setToolTip(tr("In Point")); m_inPointLabel->setFixedWidth(m_inPointLabel->width()); m_selectedLabel = new QLabel(this); m_selectedLabel->setText("--:--:--:--"); m_selectedLabel->setToolTip(tr("Selected Duration")); m_selectedLabel->setFixedWidth(m_selectedLabel->width()); toolbar->addWidget(m_positionSpinner); toolbar->addWidget(m_durationLabel); toolbar->addWidget(spacer); toolbar->addAction(actionSkipPrevious); toolbar->addAction(actionRewind); toolbar->addAction(actionPlay); toolbar->addAction(actionFastForward); toolbar->addAction(actionSkipNext); // Add zoom button to toolbar. m_zoomButton = new QToolButton; QMenu* zoomMenu = new QMenu(this); m_zoomFitAction = zoomMenu->addAction( QIcon::fromTheme("zoom-fit-best", QIcon(":/icons/oxygen/32x32/actions/zoom-fit-best")), tr("Zoom Fit"), this, SLOT(zoomFit())); m_zoomOriginalAction = zoomMenu->addAction( QIcon::fromTheme("zoom-original", QIcon(":/icons/oxygen/32x32/actions/zoom-original")), tr("Zoom 100%"), this, SLOT(zoomOriginal())); m_zoomOutAction = zoomMenu->addAction( QIcon::fromTheme("zoom-out", QIcon(":/icons/oxygen/32x32/actions/zoom-out")), tr("Zoom 50%"), this, SLOT(zoomOut())); m_zoomInAction = zoomMenu->addAction( QIcon::fromTheme("zoom-in", QIcon(":/icons/oxygen/32x32/actions/zoom-in")), tr("Zoom 200%"), this, SLOT(zoomIn())); connect(m_zoomButton, SIGNAL(toggled(bool)), SLOT(toggleZoom(bool))); m_zoomButton->setMenu(zoomMenu); m_zoomButton->setPopupMode(QToolButton::MenuButtonPopup); m_zoomButton->setCheckable(true); m_zoomButton->setToolTip(tr("Toggle zoom")); toolbar->addWidget(m_zoomButton); toolbar->addAction(actionVolume); m_volumeWidget = toolbar->widgetForAction(actionVolume); // Add in-point and selected duration labels to toolbar. spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); toolbar->addWidget(spacer); toolbar->addWidget(m_inPointLabel); toolbar->addWidget(m_selectedLabel); vlayout->addWidget(toolbar); vlayout->addLayout(tabLayout); connect(MLT.videoWidget(), SIGNAL(frameDisplayed(const SharedFrame&)), this, SLOT(onFrameDisplayed(const SharedFrame&))); connect(actionPlay, SIGNAL(triggered()), this, SLOT(togglePlayPaused())); connect(actionPause, SIGNAL(triggered()), this, SLOT(pause())); connect(actionFastForward, SIGNAL(triggered()), this, SLOT(fastForward())); connect(actionRewind, SIGNAL(triggered()), this, SLOT(rewind())); connect(m_scrubber, SIGNAL(seeked(int)), this, SLOT(seek(int))); connect(m_scrubber, SIGNAL(inChanged(int)), this, SLOT(onInChanged(int))); connect(m_scrubber, SIGNAL(outChanged(int)), this, SLOT(onOutChanged(int))); connect(m_positionSpinner, SIGNAL(valueChanged(int)), this, SLOT(seek(int))); connect(m_positionSpinner, SIGNAL(editingFinished()), this, SLOT(setFocus())); connect(this, SIGNAL(endOfStream()), this, SLOT(pause())); connect(this, SIGNAL(zoomChanged(float)), MLT.videoWidget(), SLOT(setZoom(float))); connect(m_horizontalScroll, SIGNAL(valueChanged(int)), MLT.videoWidget(), SLOT(setOffsetX(int))); connect(m_verticalScroll, SIGNAL(valueChanged(int)), MLT.videoWidget(), SLOT(setOffsetY(int))); setFocusPolicy(Qt::StrongFocus); }
bool ComplementFile::finalizeCalculations() { outPutLastRecordInPrevChrom(); fastForward(""); return true; }
void TranzportClient::readData() { memcpy(previousbuf, currentbuf, 8); ssize_t val; static timeT loop_start_time=0; static timeT loop_end_time=0; while ((val=read(m_descriptor,currentbuf,8)) == 8) { uint32_t new_buttons = current_buttons ^ previous_buttons; if (status == 0x1) { RG_DEBUG << "TranzportClient: device just came online"; while (not commands.empty()) { commands.pop(); } device_online = true; m_rgDocument = m_rgGUIApp->getDocument(); m_composition = &m_rgGUIApp->getDocument()->getComposition(); stateUpdate(); } if (status == 0xff) { RG_DEBUG << "TranzportClient: device just went offline"; device_online = false; return; } if (new_buttons & TrackSolo and current_buttons & TrackSolo) { if (current_buttons & Shift) { bool soloflag = m_composition->isSolo(); emit solo(not soloflag); } } if (new_buttons & Add and current_buttons & Add) { if (current_buttons & Shift) { } else { AddMarkerCommand* cmd = new AddMarkerCommand(m_composition, m_composition->getPosition(), "tranzport", ""); CommandHistory::getInstance()->addCommand(cmd); } } if (new_buttons & Prev and current_buttons & Prev) { RG_DEBUG << "TranzportClient:: received marker previous"; if (current_buttons & Shift) { } else { timeT currentTime = m_composition->getPosition(); Composition::markercontainer& mc = m_composition->getMarkers(); timeT closestPrevious = -1; for (Composition::markerconstiterator it = mc.begin(); it != mc.end(); ++it) { timeT markerTime = (*it)->getTime(); if (markerTime < currentTime and markerTime > closestPrevious) { closestPrevious = markerTime; } } if (closestPrevious >= 0) { RG_DEBUG << "Tranzport:: setting position: " << closestPrevious; emit setPosition(closestPrevious); } } } if (new_buttons & Next and current_buttons & Next) { RG_DEBUG << "TranzportClient:: received marker next"; if (current_buttons & Shift) { } else { timeT currentTime = m_composition->getPosition(); Composition::markercontainer& mc = m_composition->getMarkers(); timeT closestNext = std::numeric_limits<long>::max(); for (Composition::markerconstiterator it = mc.begin(); it != mc.end(); ++it) { timeT markerTime = (*it)->getTime(); if (markerTime > currentTime and markerTime < closestNext) { closestNext = markerTime; } } if (closestNext < std::numeric_limits<long>::max()) { RG_DEBUG << "Tranzport:: setting position: " << closestNext; emit setPosition(closestNext); } } } if (new_buttons & Undo and current_buttons & Undo) { if (current_buttons & Shift) { emit redo(); } else { emit undo(); } } if (new_buttons & Play and current_buttons & Play) { if (current_buttons & Shift) { } else { emit play(); } } if (new_buttons & Stop and current_buttons & Stop) { if (current_buttons & Shift) { } else { emit stop(); } } if (new_buttons & Record and current_buttons & Record) { if (current_buttons & Shift) { } else { emit record(); } } if (new_buttons & Loop and current_buttons & Loop) { if (current_buttons & Shift) { } else { loop_start_time = m_composition->getPosition(); loop_end_time = loop_start_time; } } if (new_buttons & Loop and (not (current_buttons & Loop))) { if (current_buttons & Shift) { } else { if (loop_start_time == loop_end_time) { m_rgDocument->setLoop(0,0); } loop_start_time = 0; loop_end_time = 0; } } if (new_buttons& Rewind and current_buttons & Rewind) { if (current_buttons&Shift) { emit rewindToBeginning(); } else { emit rewind(); } } if (new_buttons & FastForward and current_buttons & FastForward) { if (current_buttons & Shift) { emit fastForwardToEnd(); } else { emit fastForward(); } } if (new_buttons & TrackRec and current_buttons & TrackRec) { if (current_buttons & Shift) { } else { emit trackRecord(); } } if (new_buttons & TrackRight and current_buttons & TrackRight) { if (current_buttons & Shift) { } else { emit trackDown(); } } if (new_buttons & TrackLeft and current_buttons & TrackLeft) { if (current_buttons& Shift) { } else { emit trackUp(); } } if (new_buttons & TrackMute and current_buttons & TrackMute) { if (current_buttons & Shift) { } else { emit trackMute(); } } if (datawheel) { if (datawheel < 0x7F) { if (current_buttons & Loop) { loop_end_time += datawheel * m_composition->getDurationForMusicalTime(loop_end_time, 0,1,0,0); m_rgDocument->setLoop(loop_start_time, loop_end_time); } else if(current_buttons & Shift) { timeT here = m_composition->getPosition(); here += datawheel * m_composition->getDurationForMusicalTime(here,0,0,1,0); if (here <= m_composition->getEndMarker()) { emit setPosition(here); } } else { timeT here = m_composition->getPosition(); here += datawheel * m_composition->getDurationForMusicalTime(here,0,1,0,0); if (here <= m_composition->getEndMarker()) { emit setPosition(here); } } } else { #define DATAWHEEL_VALUE (1 + (0xFF - (datawheel))) if (current_buttons & Loop) { loop_end_time -= (1 + (0xFF - datawheel)) * m_rgGUIApp->getDocument()->getComposition().getDurationForMusicalTime(loop_end_time, 0,1,0,0); m_rgDocument->setLoop(loop_start_time, loop_end_time); } if (current_buttons & Shift) { timeT here = m_composition->getPosition(); here -= DATAWHEEL_VALUE * m_composition->getDurationForMusicalTime(here,0,0,1,0); if (here >= m_composition->getStartMarker()) { emit setPosition(here); } } else { timeT here = m_composition->getPosition(); here -= DATAWHEEL_VALUE * m_composition->getDurationForMusicalTime(here,0,1,0,0); if (here >= m_composition->getStartMarker()) { emit setPosition(here); } } #undef DATAWHEEL_VALUE } } memcpy(previousbuf, currentbuf, 8); } if (val == -1) { if (errno == EAGAIN) { return; } else { RG_DEBUG << "TranzportClient::readData: error " << strerror(errno); } } else { RG_DEBUG << "TranzportClient::readData: partial read of length " << val; RG_DEBUG << "TranzportClient::readData: this should not happen " << val; } }
void ComplementFile::giveFinalReport(RecordOutputMgr *outputMgr) { _outputMgr = outputMgr; outPutLastRecordInPrevChrom(); fastForward(""); }
TranzportClient::TranzportClient(RosegardenMainWindow* rgGUIApp) : QObject(), device_online(true), previous_buttons(*reinterpret_cast<uint32_t*>(previousbuf+2)), current_buttons(*reinterpret_cast<uint32_t*>(currentbuf+2)), datawheel(currentbuf[6]), status(currentbuf[1]), m_rgGUIApp(rgGUIApp), m_rgDocument(rgGUIApp->getDocument()), m_composition(&m_rgDocument->getComposition()) { m_descriptor = open("/dev/tranzport0",O_RDWR); if (m_descriptor < 0) { throw Exception(qstrtostr(QObject::tr("Failed to open tranzport device /dev/tranzport0"))); } bzero(currentbuf,8); bzero(previousbuf,8); fcntl(m_descriptor,F_SETOWN, getpid()); int socketFlags = fcntl(m_descriptor, F_GETFL, 0); if (socketFlags != -1) { fcntl(m_descriptor, F_SETFL, socketFlags | O_NONBLOCK); } m_socketReadNotifier = new QSocketNotifier(m_descriptor, QSocketNotifier::Read, 0); m_socketWriteNotifier = new QSocketNotifier(m_descriptor, QSocketNotifier::Write,0); connect(m_socketReadNotifier, SIGNAL(activated(int)), this, SLOT(readData())); connect(m_socketWriteNotifier, SIGNAL(activated(int)), this, SLOT(writeCommandQueue())); connect(this, SIGNAL(play()), m_rgGUIApp, SLOT(slotPlay()) ); connect(this, SIGNAL(stop()), m_rgGUIApp, SLOT(slotStop()) ); connect(this, SIGNAL(record()), m_rgGUIApp, SLOT(slotRecord()) ); connect(this, SIGNAL(rewind()), m_rgGUIApp, SLOT(slotRewind()) ); connect(this, SIGNAL(rewindToBeginning()), m_rgGUIApp, SLOT(slotRewindToBeginning()) ); connect(this, SIGNAL(fastForward()), m_rgGUIApp, SLOT(slotFastforward()) ); connect(this, SIGNAL(fastForwardToEnd()), m_rgGUIApp, SLOT(slotFastForwardToEnd()) ); connect(this, SIGNAL(toggleRecord()), m_rgGUIApp, SLOT(slotToggleRecord()) ); connect(this, SIGNAL(trackDown()), m_rgGUIApp, SLOT(slotTrackDown()) ); connect(this, SIGNAL(trackUp()), m_rgGUIApp, SLOT(slotTrackUp()) ); connect(this, SIGNAL(trackMute()), m_rgGUIApp, SLOT(slotToggleMute()) ); connect(this, SIGNAL(trackRecord()), m_rgGUIApp, SLOT(slotToggleRecordCurrentTrack()) ); connect(this, SIGNAL(solo(bool)), m_rgGUIApp, SLOT(slotToggleSolo(bool))); connect(m_rgGUIApp, SIGNAL(documentChanged(RosegardenDocument*)), this, SLOT(documentChanged(RosegardenDocument*))); connect(m_rgDocument, SIGNAL(pointerPositionChanged(timeT)), this, SLOT(pointerPositionChanged(timeT))); connect(m_rgDocument, SIGNAL(loopChanged(timeT,timeT)), this, SLOT(loopChanged(timeT,timeT))); connect(this, SIGNAL(undo()), CommandHistory::getInstance(),SLOT(undo())); connect(this, SIGNAL(redo()), CommandHistory::getInstance(), SLOT(redo())); connect(this, SIGNAL(setPosition(timeT)), m_rgDocument, SLOT(slotSetPointerPosition(timeT))); m_composition->addObserver(this); m_socketWriteNotifier->setEnabled(false); stateUpdate(); RG_DEBUG << "TranzportClient::TranzportClient: connected to tranzport device: " << m_descriptor << endl; }
bool update() { sf::Event event; while(window->pollEvent(event)) { switch (event.type) { case sf::Event::Closed: return false; case sf::Event::KeyPressed: switch(event.key.code) { case sf::Keyboard::Up: camera.move(0,-1); break; case sf::Keyboard::Down: camera.move(0,1); std::cout << camera.getCenter().x; break; case sf::Keyboard::Left: camera.move(-1,0); break; case sf::Keyboard::Right: camera.move(1,0); break; case sf::Keyboard::F1: for(int i = 0; i<10; i++) { updateCreatures(); } break; case sf::Keyboard::F2: for(int i = 0; i<100; i++) { updateCreatures(); } break; case sf::Keyboard::F3: fastForward(10); break; case sf::Keyboard::F4: fastForward(50); break; } break; case sf::Event::MouseMoved: if(sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) { camera.move(mousepos-window->mapPixelToCoords(sf::Mouse::getPosition(),camera)); } mousepos = window->mapPixelToCoords(sf::Mouse::getPosition(),camera); break; case sf::Event::MouseWheelMoved: if(event.mouseWheel.delta>0) { camera.zoom(1.15); } else if(event.mouseWheel.delta<0) { camera.zoom(0.85); } break; case sf::Event::MouseButtonPressed: if(mouseclock.getElapsedTime().asMilliseconds()<333) { auto center = window->mapPixelToCoords(sf::Vector2i(event.mouseButton.x,event.mouseButton.y),camera); camera.setCenter(center); camera.setSize(sf::Vector2f(SCREEN_W,SCREEN_H)); } prev_click = mouseclock.restart(); break; } } double ftest = 0; avg = 0; for(auto& creature: creatures) { creature->foodPool(food); creature->update(); for(auto fd = food.begin(); fd<food.end(); fd++) { if(distance(creature->getPos(),*fd)<15) { fd = food.erase(fd); creature->increaseFitness(1.f); } } avg += creature->getFitness(); if(creature->getFitness()>ftest) { ftest = creature->getFitness(); } } pavg = avg; avg = avg/creatures.size(); if(avg>bestavg) { best_so_far = vpop->getPopulationRef(); } else if(avg < bestavg*0.85) { vpop->revertPopulation(best_so_far); } while(food.size()<FOOD_CAP) { food.push_back(sf::Vector2f(20 + rand() % (AREA_W-40), 10 + rand() % (AREA_H-20))); } if(counter>1) { counter--; } else { updateCreatures(); counter = 60*evolution_rate; std::cout << "Generation: " << gen++; std::cout << " fittest: " << ftest; std::cout << " average: " << avg << std::endl; } return true; }
int sidplay2::fastForward (uint percent) { return sidplayer.fastForward (percent); }
void LircCommander::slotExecute(const char *command) { struct command tmp, *res; RG_DEBUG << "LircCommander::slotExecute: invoking command: " << command; // find the function for the name tmp.name = command; res = (struct command *)bsearch(&tmp, commands, sizeof(commands) / sizeof(struct command), sizeof(struct command), compareCommandName); if (res != NULL) { switch (res->code) { case cmd_play: emit play(); break; case cmd_stop: emit stop(); break; case cmd_record: emit record(); break; case cmd_rewind: emit rewind(); break; case cmd_rewindToBeginning: emit rewindToBeginning(); break; case cmd_fastForward: emit fastForward(); break; case cmd_fastForwardToEnd: emit fastForwardToEnd(); break; case cmd_toggleRecord: emit toggleRecord(); break; case cmd_trackDown: emit trackDown(); break; case cmd_trackUp: emit trackUp(); break; case cmd_trackMute: emit trackMute(); break; case cmd_trackRecord: emit trackRecord(); break; case cmd_undo: emit undo(); break; case cmd_redo: emit redo(); break; case cmd_aboutrg: emit aboutrg(); break; case cmd_editInEventList: emit editInEventList(); break; case cmd_editInMatrix: emit editInMatrix(); break; case cmd_editInPercussionMatrix: emit editInPercussionMatrix(); break; case cmd_editAsNotation: emit editAsNotation(); break; case cmd_quit: emit quit(); break; case cmd_closeTransport: emit closeTransport(); break; case cmd_toggleTransportVisibility: emit toggleTransportVisibility(); break; default: RG_DEBUG << "LircCommander::slotExecute: unhandled command " << command; return; } RG_DEBUG << "LircCommander::slotExecute: handled command: " << command; } else { RG_DEBUG << "LircCommander::slotExecute: invoking command: " << command << " failed (command not defined in LircCommander::commands[])" << endl; }; }