inline TTErr TTSvf::calculatePeak(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel) { tick(x, channel); y = 0.5 * (mLowpass_output[channel] - mHighpass_output[channel]); return kTTErrNone; }
qreal TimeSig::mag() const { return staff() ? staff()->mag(tick()) : 1.0; }
static int midimain(const void * filename) { int a, notes_used, vol; bool is_playing = true; /* false = paused */ midi_debug("Loading file"); mf = loadFile(filename); if (mf == NULL) { midi_debug("Error loading file."); return -1; } if (initSynth(mf, ROCKBOX_DIR "/patchset/patchset.cfg", ROCKBOX_DIR "/patchset/drums.cfg") == -1) return -1; rb->pcm_play_stop(); #if INPUT_SRC_CAPS != 0 /* Select playback */ rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); rb->audio_set_output_source(AUDIO_SRC_PLAYBACK); #endif rb->pcm_set_frequency(SAMPLE_RATE); /* 44100 22050 11025 */ /* * tick() will do one MIDI clock tick. Then, there's a loop here that * will generate the right number of samples per MIDI tick. The whole * MIDI playback is timed in terms of this value.. there are no forced * delays or anything. It just produces enough samples for each tick, and * the playback of these samples is what makes the timings right. * * This seems to work quite well. On a laptop, anyway. */ midi_debug("Okay, starting sequencing"); bpm = mf->div*1000000/tempo; number_of_samples = SAMPLE_RATE/bpm; /* Skip over any junk in the beginning of the file, so start playing */ /* after the first note event */ do { notes_used = 0; for (a = 0; a < MAX_VOICES; a++) if (voices[a].isUsed) notes_used++; tick(); } while (notes_used == 0); playing_time = 0; samples_this_second = 0; synthbuf(); rb->pcm_play_data(&get_more, NULL, 0); while (!quit) { #ifndef SYNC synthbuf(); #endif rb->yield(); /* Prevent idle poweroff */ rb->reset_poweroff_timer(); /* Code taken from Oscilloscope plugin */ switch (rb->button_get(false)) { case BTN_UP: case BTN_UP | BUTTON_REPEAT: { vol = rb->global_settings->volume; if (vol < rb->sound_max(SOUND_VOLUME)) { vol++; rb->sound_set(SOUND_VOLUME, vol); rb->global_settings->volume = vol; } break; } case BTN_DOWN: case BTN_DOWN | BUTTON_REPEAT: { vol = rb->global_settings->volume; if (vol > rb->sound_min(SOUND_VOLUME)) { vol--; rb->sound_set(SOUND_VOLUME, vol); rb->global_settings->volume = vol; } break; } case BTN_LEFT: { /* Rewinding is tricky. Basically start the file over */ /* but run through the tracks without the synth running */ rb->pcm_play_stop(); seekBackward(5); midi_debug("Rewind to %d:%02d\n", playing_time/60, playing_time%60); if (is_playing) rb->pcm_play_data(&get_more, NULL, 0); break; } case BTN_RIGHT: { rb->pcm_play_stop(); seekForward(5); midi_debug("Skip to %d:%02d\n", playing_time/60, playing_time%60); if (is_playing) rb->pcm_play_data(&get_more, NULL, 0); break; } case BTN_PLAY: { if (is_playing) { midi_debug("Paused at %d:%02d\n", playing_time/60, playing_time%60); is_playing = false; rb->pcm_play_stop(); } else { midi_debug("Playing from %d:%02d\n", playing_time/60, playing_time%60); is_playing = true; rb->pcm_play_data(&get_more, NULL, 0); } break; } #ifdef BTN_RC_QUIT case BTN_RC_QUIT: #endif case BTN_QUIT: quit = true; } } return 0; }
void DSP::enter() { while(true) { switch(state.sample_stage) { case 0: voice_5(voice[0]); voice_2(voice[1]); if(!tick()) break; case 1: voice_6(voice[0]); voice_3(voice[1]); if (!tick()) break; case 2: voice_7(voice[0]); voice_4(voice[1]); voice_1(voice[3]); if (!tick()) break; case 3: voice_8(voice[0]); voice_5(voice[1]); voice_2(voice[2]); if (!tick()) break; case 4: voice_9(voice[0]); voice_6(voice[1]); voice_3(voice[2]); if (!tick()) break; case 5: voice_7(voice[1]); voice_4(voice[2]); voice_1(voice[4]); if (!tick()) break; case 6: voice_8(voice[1]); voice_5(voice[2]); voice_2(voice[3]); if (!tick()) break; case 7: voice_9(voice[1]); voice_6(voice[2]); voice_3(voice[3]); if (!tick()) break; case 8: voice_7(voice[2]); voice_4(voice[3]); voice_1(voice[5]); if (!tick()) break; case 9: voice_8(voice[2]); voice_5(voice[3]); voice_2(voice[4]); if (!tick()) break; case 10: voice_9(voice[2]); voice_6(voice[3]); voice_3(voice[4]); if (!tick()) break; case 11: voice_7(voice[3]); voice_4(voice[4]); voice_1(voice[6]); if (!tick()) break; case 12: voice_8(voice[3]); voice_5(voice[4]); voice_2(voice[5]); if (!tick()) break; case 13: voice_9(voice[3]); voice_6(voice[4]); voice_3(voice[5]); if (!tick()) break; case 14: voice_7(voice[4]); voice_4(voice[5]); voice_1(voice[7]); if (!tick()) break; case 15: voice_8(voice[4]); voice_5(voice[5]); voice_2(voice[6]); if (!tick()) break; case 16: voice_9(voice[4]); voice_6(voice[5]); voice_3(voice[6]); if (!tick()) break; case 17: voice_1(voice[0]); voice_7(voice[5]); voice_4(voice[6]); if (!tick()) break; case 18: voice_8(voice[5]); voice_5(voice[6]); voice_2(voice[7]); if (!tick()) break; case 19: voice_9(voice[5]); voice_6(voice[6]); voice_3(voice[7]); if (!tick()) break; case 20: voice_1(voice[1]); voice_7(voice[6]); voice_4(voice[7]); if (!tick()) break; case 21: voice_8(voice[6]); voice_5(voice[7]); voice_2(voice[0]); if (!tick()) break; case 22: voice_3a(voice[0]); voice_9(voice[6]); voice_6(voice[7]); echo_22(); if (!tick()) break; case 23: voice_7(voice[7]); echo_23(); if (!tick()) break; case 24: voice_8(voice[7]); echo_24(); if (!tick()) break; case 25: voice_3b(voice[0]); voice_9(voice[7]); echo_25(); if (!tick()) break; case 26: echo_26(); if (!tick()) break; case 27: misc_27(); echo_27(); if (!tick()) break; case 28: misc_28(); echo_28(); if (!tick()) break; case 29: misc_29(); echo_29(); if (!tick()) break; case 30: misc_30(); voice_3c(voice[0]); echo_30(); if (!tick()) break; case 31: voice_4(voice[0]); voice_1(voice[2]); tick(); } } }
void game_loop(int * input_key){ //init game data init_game(); //control data struct timeval *begin, *end, *tmp; unsigned long diff;//in us int key = 0; //for temporary storage of input_key, b/c of race conditions int reached_bottom = 0; begin=malloc(sizeof(struct timeval)); end=malloc(sizeof(struct timeval)); gettimeofday(begin, NULL); diff = 0; draw(); while(1){ //input key=*input_key; if(key != -1){ *input_key = -1;//input read->reset switch(key){//TODO move block case KEY_DOWN: reached_bottom = go_down(¤t_tetromino, &world); break; case KEY_LEFT: if(!reached_bottom){ go_left(¤t_tetromino, &world); } break; case KEY_RIGHT: if(!reached_bottom){ go_right(¤t_tetromino, &world); } break; case 'x': if(!reached_bottom){ rotate(¤t_tetromino, &world, 1); } break; case 'c': if(!reached_bottom){ rotate(¤t_tetromino, &world, 0); } break; case 27: /*ESC*/ switch(menu(input_key)){ case 0:break;//continue game case 1:init_game();break;//new game case -1://quit free(begin); free(end); return; default:break; } gettimeofday(begin, NULL); break; case 32: /*Space*/ while(!go_down(¤t_tetromino, &world)); reached_bottom=1; diff=tick_time; break; case -2: free(begin); free(end); return; default: break; } } //game tick & time gettimeofday(end, NULL); diff+=(end->tv_sec-begin->tv_sec)*1000000 + end->tv_usec-begin->tv_usec; tmp=begin; begin=end; end=tmp; if(diff >= tick_time){ diff -= tick_time; tick(&reached_bottom); } //gui update draw(); //sleep usleep(50*1000); } }
/** Animate and perform the fight routine */ static void _fight(NinjaState *state, NinjaPacket *packet) { uint8_t result = results[state->p1Move][state->p2Move]; bool up = true; char username[USERNAME_MAX_LENGTH]; ANXGetUsername(username); //Animate the players getting ready to fight for (uint8_t i = 0; i < 6; i++) { display.clearDisplay(); display.setCursor(0, 0); display.print(state->p1Score); display.setCursor(120, 0); display.print(state->p2Score); display.setCursor(40, 28); display.print("Round "); display.print(state->round); display.drawFastHLine(0, display.height() - 10, display.width(), WHITE); //Draw the usernames display.setCursor(0, 56); display.print(username); printAlignRight(state->p2Name, 56); //Animate the players idling if (up) { drawBitmapFlash(state->p1Idle1, PLAYER_1_X, PLAYER_1_Y); drawBitmapFlash(state->p2Idle1, PLAYER_2_X, PLAYER_2_Y); } else { drawBitmapFlash(state->p1Idle2, PLAYER_1_X, PLAYER_1_Y); drawBitmapFlash(state->p2Idle2, PLAYER_2_X, PLAYER_2_Y); } up = !up; safeDisplay(); for (uint8_t i = 0; i < 15; i++) { deepSleep(25); tick(); _handlePackets(state, packet); } } for (uint8_t i = 0; i < 6; i++) { display.clearDisplay(); display.setCursor(0, 0); display.print(state->p1Score); display.setCursor(120, 0); display.print(state->p2Score); display.drawFastHLine(0, display.height() - 10, display.width(), WHITE); //Draw the names display.setCursor(0, 56); display.print(username); printAlignRight(state->p2Name, 56); //Setup the animation graphics if (up) { if (state->p1Move == MOVE_PUNCH) drawBitmapFlash(state->p1Punch1, 37, PLAYER_1_Y); if (state->p1Move == MOVE_KICK) drawBitmapFlash(state->p1Kick1, 37, PLAYER_1_Y); if (state->p1Move == MOVE_NONE) drawBitmapFlash(state->p1Idle1, 37, PLAYER_1_Y); if (state->p1Move == MOVE_SHIELD) drawBitmapFlash(state->p1Shield1, 37, PLAYER_1_Y); if (state->p2Move == MOVE_PUNCH) drawBitmapFlash(state->p2Punch2, 64, PLAYER_2_Y); if (state->p2Move == MOVE_KICK) drawBitmapFlash(state->p2Kick2, 64, PLAYER_2_Y); if (state->p2Move == MOVE_NONE) drawBitmapFlash(state->p2Idle2, 64, PLAYER_2_Y); if (state->p2Move == MOVE_SHIELD) drawBitmapFlash(state->p2Shield2, 64, PLAYER_2_Y); } else { if (state->p1Move == MOVE_PUNCH) drawBitmapFlash(state->p1Punch2, 37, PLAYER_1_Y); if (state->p1Move == MOVE_KICK) drawBitmapFlash(state->p1Kick2, 37, PLAYER_1_Y); if (state->p1Move == MOVE_NONE) drawBitmapFlash(state->p1Idle2, 37, PLAYER_1_Y); if (state->p1Move == MOVE_SHIELD) drawBitmapFlash(state->p1Shield2, 37, PLAYER_2_Y); if (state->p2Move == MOVE_PUNCH) drawBitmapFlash(state->p2Punch1, 64, PLAYER_2_Y); if (state->p2Move == MOVE_KICK) drawBitmapFlash(state->p2Kick1, 64, PLAYER_2_Y); if (state->p2Move == MOVE_NONE) drawBitmapFlash(state->p2Idle1, 64, PLAYER_2_Y); if (state->p2Move == MOVE_SHIELD) drawBitmapFlash(state->p2Shield1, 64, PLAYER_2_Y); } if (state->p1Move == MOVE_TROLL) drawBitmapFlash(state->troll, 23, PLAYER_1_Y); if (state->p2Move == MOVE_TROLL) drawBitmapFlash(state->troll, 64, PLAYER_2_Y); up = !up; safeDisplay(); for (uint8_t i = 0; i < 5; i++) { deepSleep(100); tick(); } } display.clearDisplay(); display.drawFastHLine(0, display.height() - 10, display.width(), WHITE); //Draw the names display.setCursor(0, 56); display.print(username); printAlignRight(state->p2Name, 56); //Check the tiebreaker if (result == RESULT_TIE) { if (state->tiebreaker[state->round - 1]) { result = RESULT_WIN; } else { result = RESULT_LOSE; } } switch (result) { case RESULT_WIN: display.setCursor(67, 28); display.print("You Win!"); state->p1Score++; drawBitmapFlash(state->p1Idle1, 37, PLAYER_1_Y); drawBitmapFlash(state->p2Dead, 64, PLAYER_2_Y); break; case RESULT_LOSE: display.setCursor(4, 28); display.print("You Lose :("); state->p2Score++; drawBitmapFlash(state->p1Dead, 37, PLAYER_1_Y); drawBitmapFlash(state->p2Idle1, 64, PLAYER_2_Y); break; } display.setCursor(0, 0); display.print(state->p1Score); display.setCursor(120, 0); display.print(state->p2Score); safeDisplay(); //3 second delay for (uint8_t i = 0; i < 15; i++) { deepSleep(200); tick(); } }
JNIEXPORT void JNICALL Java_br_odb_nehe_lesson07_GL2JNILib_tick(JNIEnv *env, jobject obj) { tick(); }
void Alias::process() { for (int i = 0; i < buffer_size_; ++i) tick(i); }
bool NounShip::canCollide() const { if ( tick() < m_nIgnoreCollisionTick ) return false; return true; }
SDRdaemonGui::SDRdaemonGui(DeviceSourceAPI *deviceAPI, QWidget* parent) : QWidget(parent), ui(new Ui::SDRdaemonGui), m_deviceAPI(deviceAPI), m_sampleSource(NULL), m_acquisition(false), m_lastEngineState((DSPDeviceSourceEngine::State)-1), m_sampleRate(0), m_sampleRateStream(0), m_centerFrequency(0), m_syncLocked(false), m_frameSize(0), m_lz4(false), m_compressionRatio(1.0), m_nbLz4DataCRCOK(0), m_nbLz4SuccessfulDecodes(0), m_bufferLengthInSecs(0.0), m_bufferGauge(-50), m_samplesCount(0), m_tickCount(0), m_address("127.0.0.1"), m_dataPort(9090), m_controlPort(9091), m_addressEdited(false), m_dataPortEdited(false), m_initSendConfiguration(false), m_dcBlock(false), m_iqCorrection(false), m_autoFollowRate(false) { m_sender = nn_socket(AF_SP, NN_PAIR); assert(m_sender != -1); int millis = 500; int rc = nn_setsockopt (m_sender, NN_SOL_SOCKET, NN_SNDTIMEO, &millis, sizeof (millis)); assert (rc == 0); m_startingTimeStamp.tv_sec = 0; m_startingTimeStamp.tv_usec = 0; ui->setupUi(this); ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold)); ui->centerFrequency->setValueRange(7, 0, pow(10,7)); connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware())); connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); m_statusTimer.start(500); connect(&(deviceAPI->getMainWindow()->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick())); m_sampleSource = new SDRdaemonInput(deviceAPI->getMainWindow()->getMasterTimer(), m_deviceAPI); connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages())); m_deviceAPI->setSource(m_sampleSource); displaySettings(); ui->applyButton->setEnabled(false); ui->sendButton->setEnabled(false); char recFileNameCStr[30]; sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID()); m_fileSink = new FileRecord(std::string(recFileNameCStr)); m_deviceAPI->addSink(m_fileSink); connect(m_deviceAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection); }
// observe the raw infomation, but just like human ut will use some method to filter the noice // this is just for one robot void RobotTracker::observe(VisionRawInfo obs, double timestamp) { //如果有1秒没有来更新信号,自动复位,防止繁殖的程序内存不够 if(timestamp-time>0.5) { printf("Robot obvserve reset\r\n"); reset_on_observation = true; } // if there is no renew signal // if the observation has been reset if (reset_on_observation) { if (obs.conf <= 0.0) { return; } static Matrix observe_matrix(7,1), P(7); observe_matrix.e(0,0) = obs.pos.x; observe_matrix.e(1,0) = obs.pos.y; observe_matrix.e(2,0) = obs.angle; observe_matrix.e(3,0) = 0.0; observe_matrix.e(4,0) = 0.0; observe_matrix.e(5,0) = 0.0; observe_matrix.e(6,0) = 0.0; P.e(0,0) = DVAR(ROBOT_POSITION_VARIANCE); P.e(1,1) = DVAR(ROBOT_POSITION_VARIANCE); P.e(2,2) = DVAR(ROBOT_THETA_VARIANCE); P.e(3,3) = 0.0; // 0m/s if (type == ROBOT_TYPE_DIFF) { P.e(4,4) = 0.0; } else { P.e(4,4) = 0.0; // 0m/s } P.e(5,5) = 0.0; P.e(6,6) = 0.0; initial(obs.timestamp, observe_matrix, P); reset_on_observation = false; } else { // If this is a new observation. if (timestamp > time) { // Tick to current time. tick(timestamp - time); // Make observation if (obs.timestamp == timestamp) { double xtheta = xs[0].e(2,0); Matrix o(3,1); o.e(0,0) = obs.pos.x; o.e(1,0) = obs.pos.y; o.e(2,0) = anglemod(obs.angle - xtheta) + xtheta; update(o); } if (error_time_elapsed() > 10.0) { fprintf(stderr, "Kalman Error (pos, theta, vpos, vtheta): "); fprintf(stderr, "%f ", hypot(error_mean().e(0, 0), error_mean().e(1, 0))); fprintf(stderr, "%f ", error_mean().e(2, 0)); fprintf(stderr, "%f ", hypot(error_mean().e(3, 0), error_mean().e(4, 0))); fprintf(stderr, "%f\n", error_mean().e(5, 0)); error_reset(); } } } }
void MpvAudioOutput::event_loop() { while (true) { auto event = mpv_wait_event(handle_, -1); // qDebug() << "mpv event " << mpv_event_name(event->event_id); switch (event->event_id) { case MPV_EVENT_SHUTDOWN: return; case MPV_EVENT_QUEUE_OVERFLOW: qWarning() << "mpv queue overflow"; break; case MPV_EVENT_START_FILE: setState(AudioState::Buffering); break; case MPV_EVENT_FILE_LOADED: setState(AudioState::Playing); emit currentSourceChanged(); setVolume(); if (seek_offset_ != -1) { seek(seek_offset_); seek_offset_ = -1; } break; case MPV_EVENT_END_FILE: { auto end_ev = reinterpret_cast<mpv_event_end_file *>(event->data); if (end_ev->reason == MPV_END_FILE_REASON_ERROR) qWarning() << "Ended file: " << mpv_error_string(end_ev->error); break; } case MPV_EVENT_LOG_MESSAGE: { auto log = reinterpret_cast<mpv_event_log_message *>(event->data); qDebug() << "mpv [" << log->prefix << "] " << log->text; break; } case MPV_EVENT_PROPERTY_CHANGE: { auto prop = reinterpret_cast<mpv_event_property *>(event->data); if (prop->format != MPV_FORMAT_NONE && prop->data) { if (std::string(prop->name) == "playback-time") { std::string pos(*(reinterpret_cast<char **>(prop->data))); emit tick(pos_to_qint64(pos)); if (volumeNeverSet_) setVolume(); } else if (std::string(prop->name) == "idle") { int idle = *reinterpret_cast<int *>(prop->data); if (idle) { setState(AudioState::Stopped); emit finished(); } else setState(AudioState::Playing); } else if (std::string(prop->name) == "pause") { int pause = *reinterpret_cast<int *>(prop->data); if (pause) setState(AudioState::Paused); else if (state_ == AudioState::Paused) setState(AudioState::Playing); } else if (std::string(prop->name) == "duration") { double v = *reinterpret_cast<double *>(prop->data); emit durationChanged(v); } else if (std::string(prop->name) == "metadata") { emit metadataChanged(get_property("media-title").toString(), get_property("audio-format").toString(), get_property("audio-params/samplerate").toInt()); } } break; } default: break; } } }
void NPlayer::connectSignals() { connect(m_playbackEngine, SIGNAL(mediaChanged(const QString &)), this, SLOT(on_playbackEngine_mediaChanged(const QString &))); connect(m_playbackEngine, SIGNAL(mediaChanged(const QString &)), m_waveformSlider, SLOT(setMedia(const QString &))); connect(m_playbackEngine, SIGNAL(stateChanged(N::PlaybackState)), this, SLOT(on_playbackEngine_stateChanged(N::PlaybackState))); connect(m_playbackEngine, SIGNAL(aboutToFinish()), m_playlistWidget, SLOT(currentFinished()), Qt::BlockingQueuedConnection); connect(m_playbackEngine, SIGNAL(positionChanged(qreal)), m_waveformSlider, SLOT(setValue(qreal))); connect(m_playbackEngine, SIGNAL(tick(qint64)), m_trackInfoWidget, SLOT(tick(qint64))); connect(m_playbackEngine, SIGNAL(finished()), m_playlistWidget, SLOT(currentFinished())); connect(m_playbackEngine, SIGNAL(failed()), this, SLOT(on_playbackEngine_failed())); connect(m_playbackEngine, SIGNAL(message(QMessageBox::Icon, const QString &, const QString &)), m_logDialog, SLOT(showMessage(QMessageBox::Icon, const QString &, const QString &))); connect(m_mainWindow, SIGNAL(closed()), this, SLOT(on_mainWindow_closed())); connect(m_preferencesDialog, SIGNAL(settingsChanged()), this, SLOT(on_preferencesDialog_settingsChanged())); if (m_coverWidget) connect(m_playbackEngine, SIGNAL(mediaChanged(const QString &)), m_coverWidget, SLOT(setSource(const QString &))); if (QAbstractButton *playButton = qFindChild<QAbstractButton *>(m_mainWindow, "playButton")) connect(playButton, SIGNAL(clicked()), this, SLOT(on_playButton_clicked())); if (QAbstractButton *stopButton = qFindChild<QAbstractButton *>(m_mainWindow, "stopButton")) connect(stopButton, SIGNAL(clicked()), m_playbackEngine, SLOT(stop())); if (QAbstractButton *prevButton = qFindChild<QAbstractButton *>(m_mainWindow, "prevButton")) connect(prevButton, SIGNAL(clicked()), m_playlistWidget, SLOT(playPrevItem())); if (QAbstractButton *nextButton = qFindChild<QAbstractButton *>(m_mainWindow, "nextButton")) connect(nextButton, SIGNAL(clicked()), m_playlistWidget, SLOT(playNextItem())); if (QAbstractButton *closeButton = qFindChild<QAbstractButton *>(m_mainWindow, "closeButton")) connect(closeButton, SIGNAL(clicked()), m_mainWindow, SLOT(close())); if (QAbstractButton *minimizeButton = qFindChild<QAbstractButton *>(m_mainWindow, "minimizeButton")) connect(minimizeButton, SIGNAL(clicked()), m_mainWindow, SLOT(showMinimized())); if (m_volumeSlider) { connect(m_volumeSlider, SIGNAL(sliderMoved(qreal)), m_playbackEngine, SLOT(setVolume(qreal))); connect(m_playbackEngine, SIGNAL(volumeChanged(qreal)), m_volumeSlider, SLOT(setValue(qreal))); connect(m_mainWindow, SIGNAL(scrolled(int)), this, SLOT(on_mainWindow_scrolled(int))); } if (QAbstractButton *repeatButton = qFindChild<QAbstractButton *>(m_mainWindow, "repeatButton")) { connect(repeatButton, SIGNAL(clicked(bool)), m_playlistWidget, SLOT(setRepeatMode(bool))); connect(m_playlistWidget, SIGNAL(repeatModeChanged(bool)), repeatButton, SLOT(setChecked(bool))); } if (QAbstractButton *shuffleButton = qFindChild<QAbstractButton *>(m_mainWindow, "shuffleButton")) { connect(shuffleButton, SIGNAL(clicked(bool)), m_playlistWidget, SLOT(setShuffleMode(bool))); connect(m_playlistWidget, SIGNAL(shuffleModeChanged(bool)), shuffleButton, SLOT(setChecked(bool))); } connect(m_playlistWidget, SIGNAL(setMedia(const QString &)), m_playbackEngine, SLOT(setMedia(const QString &))); connect(m_playlistWidget, SIGNAL(currentActivated()), m_playbackEngine, SLOT(play())); connect(m_playlistWidget, SIGNAL(shuffleModeChanged(bool)), m_shufflePlaylistAction, SLOT(setChecked(bool))); connect(m_playlistWidget, SIGNAL(repeatModeChanged(bool)), m_repeatPlaylistAction, SLOT(setChecked(bool))); connect(m_waveformSlider, SIGNAL(filesDropped(const QStringList &)), m_playlistWidget, SLOT(playFiles(const QStringList &))); connect(m_waveformSlider, SIGNAL(sliderMoved(qreal)), m_playbackEngine, SLOT(setPosition(qreal))); connect(m_showHideAction, SIGNAL(triggered()), this, SLOT(toggleWindowVisibility())); connect(m_playAction, SIGNAL(triggered()), m_playbackEngine, SLOT(play())); connect(m_stopAction, SIGNAL(triggered()), m_playbackEngine, SLOT(stop())); connect(m_prevAction, SIGNAL(triggered()), m_playlistWidget, SLOT(playPrevItem())); connect(m_nextAction, SIGNAL(triggered()), m_playlistWidget, SLOT(playNextItem())); connect(m_preferencesAction, SIGNAL(triggered()), m_preferencesDialog, SLOT(exec())); connect(m_exitAction, SIGNAL(triggered()), this, SLOT(quit())); connect(m_addFilesAction, SIGNAL(triggered()), this, SLOT(showOpenFileDialog())); connect(m_playlistWidget, SIGNAL(activateEmptyFail()), m_addFilesAction, SLOT(trigger())); connect(m_addDirAction, SIGNAL(triggered()), this, SLOT(showOpenDirDialog())); connect(m_savePlaylistAction, SIGNAL(triggered()), this, SLOT(showSavePlaylistDialog())); connect(m_showCoverAction, SIGNAL(toggled(bool)), this, SLOT(on_showCoverAction_toggled(bool))); connect(m_aboutAction, SIGNAL(triggered()), this, SLOT(showAboutMessageBox())); connect(m_playingOnTopAction, SIGNAL(toggled(bool)), this, SLOT(on_whilePlayingOnTopAction_toggled(bool))); connect(m_alwaysOnTopAction, SIGNAL(toggled(bool)), this, SLOT(on_alwaysOnTopAction_toggled(bool))); connect(m_fullScreenAction, SIGNAL(triggered()), m_mainWindow, SLOT(toggleFullScreen())); connect(m_shufflePlaylistAction, SIGNAL(triggered(bool)), m_playlistWidget, SLOT(setShuffleMode(bool))); connect(m_repeatPlaylistAction, SIGNAL(triggered(bool)), m_playlistWidget, SLOT(setRepeatMode(bool))); connect(m_loopPlaylistAction, SIGNAL(triggered()), this, SLOT(on_playlistAction_triggered())); connect(m_nextFileEnableAction, SIGNAL(triggered()), this, SLOT(on_playlistAction_triggered())); connect(m_nextFileByNameAscdAction, SIGNAL(triggered()), this, SLOT(on_playlistAction_triggered())); connect(m_nextFileByNameDescAction, SIGNAL(triggered()), this, SLOT(on_playlistAction_triggered())); connect(m_nextFileByDateAscd, SIGNAL(triggered()), this, SLOT(on_playlistAction_triggered())); connect(m_nextFileByDateDesc, SIGNAL(triggered()), this, SLOT(on_playlistAction_triggered())); foreach (NAction *action, findChildren<NAction *>()) { if (action->objectName().startsWith("Jump")) connect(action, SIGNAL(triggered()), this, SLOT(on_jumpAction_triggered())); } connect(m_mainWindow, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(m_systemTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_trayIcon_activated(QSystemTrayIcon::ActivationReason))); connect(m_trayClickTimer, SIGNAL(timeout()), this, SLOT(on_trayClickTimer_timeout())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setWindowTitle("MD VideoConference " MDVC_VERSION); posted = true; ws = new QWorkspace(this); ws->setScrollBarsEnabled(TRUE); setCentralWidget(ws); if (! prefs->bNoReceive) { dice=new DiceWindow(ws); ws->addWindow(dice); dice->show(); dice->parentWidget()->installEventFilter(this); } else { dice = NULL; } timer=new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(tick())); timer->start(60000); readyWin = NULL; QActionGroup *ag; QAction *a; QMenu *submenu; int i; videoSizeMenu = new QMenu( "&Video", this ); ag=new QActionGroup(this); submenu=new QMenu("&Bitrate", videoSizeMenu); i = 0; while(bitrates[i] != -1) { QString bitrate=QString::number(bitrates[i] / 1000) + " kbit"; a = new QAction(bitrate, this); a->setCheckable(TRUE); a->setData(bitrates[i]); ag->addAction(a); submenu->addAction(a); if (bitrates[i] == prefs->iVideoBitrate) a->setChecked(TRUE); i++; } connect(ag, SIGNAL(triggered(QAction *)), this, SLOT(videoBitrate(QAction *))); videoSizeMenu->addMenu(submenu); videoSizeMenu->addAction("Settings", this, SLOT(videoDialog())); videoSizeMenu->addAction("Stream", this, SLOT(videoStreamDialog())); videoSizeMenu->addAction("&Denoise", this, SLOT(videoDenoise())); videoSizeMenu->addAction("Statistics", this, SLOT(videoStats())); if (! prefs->bNoSendAudio) { audioMenu = new QMenu( "&Audio", this ); ag=new QActionGroup(this); submenu=new QMenu("&Decodelag", audioMenu); for(i=1;i<=7;i++) { a = new QAction(QString::number((i-1)*10) + "ms", this); a->setCheckable(TRUE); a->setData(i); ag->addAction(a); submenu->addAction(a); if (prefs->iAudioDecodeLag == i) a->setChecked(TRUE); } connect(ag, SIGNAL(triggered(QAction *)), this, SLOT(audioDecodeLag(QAction *))); audioMenu->addMenu(submenu); audioMenu->addAction("&Statistics", this, SLOT(audioStats())); audioMenu->addAction("Max &Gain", this, SLOT(audioGain())); audioMenu->addAction("&Reset PP", this, SLOT(audioResetPP())); aAudioInput = audioMenu->addAction("&InputMonitor", this, SLOT(audioInputMonitor())); aAudioInput->setCheckable(TRUE); aAudioInput->setChecked(prefs->bAudioInput); } else {
/** Primary state machine for ninja fight game handles exchange of packets and setting up game between the two players */ static void _doNinja(NinjaState *state, NinjaPacket *packet) { uint32_t endTime = 0; //Init the game state state->p1Idle1 = getBitmapMetadata(NINJA_P1_IDLE1_address); state->p2Idle1 = getBitmapMetadata(NINJA_P2_IDLE1_address); state->p1Idle2 = getBitmapMetadata(NINJA_P1_IDLE2_address); state->p2Idle2 = getBitmapMetadata(NINJA_P2_IDLE2_address); state->p1Punch1 = getBitmapMetadata(NINJA_P1_PUNCH1_address); state->p2Punch1 = getBitmapMetadata(NINJA_P2_PUNCH1_address); state->p1Punch2 = getBitmapMetadata(NINJA_P1_PUNCH2_address); state->p2Punch2 = getBitmapMetadata(NINJA_P2_PUNCH2_address); state->p1Kick1 = getBitmapMetadata(NINJA_P1_KICK1_address); state->p2Kick1 = getBitmapMetadata(NINJA_P2_KICK1_address); state->p1Kick2 = getBitmapMetadata(NINJA_P1_KICK2_address); state->p2Kick2 = getBitmapMetadata(NINJA_P2_KICK2_address); state->p1Shield1 = getBitmapMetadata(NINJA_P1_SHIELD1_address); state->p2Shield1 = getBitmapMetadata(NINJA_P2_SHIELD1_address); state->p1Shield2 = getBitmapMetadata(NINJA_P1_SHIELD2_address); state->p2Shield2 = getBitmapMetadata(NINJA_P2_SHIELD2_address); state->p1Dead = getBitmapMetadata(NINJA_P1_DEAD_address); state->p2Dead = getBitmapMetadata(NINJA_P2_DEAD_address); state->troll = getBitmapMetadata(NINJA_DT_address); state->punch = getBitmapMetadata(NINJA_PUNCH_address); state->kick = getBitmapMetadata(NINJA_KICK_address); state->shield = getBitmapMetadata(NINJA_SHIELD_address); state->up = getBitmapMetadata(NINJA_UP_address); state->down = getBitmapMetadata(NINJA_DOWN_address); state->right = getBitmapMetadata(NINJA_RIGHT_address); state->state = STATE_SELECT_MOVE; state->round = 1; state->p1Score = 0; state->p2Score = 0; while (state->p1Score < 2 && state->p2Score < 2) { if (state->state == STATE_SELECT_MOVE) { state->lastACK = -1; //Set p2Move to -1 *before* _getPlayerMove (which could change it!) state->p2Move = -1; //other player move state->p1Move = _getPlayerMove(state, packet); endTime = rtMillis() + 20000; bool ackRecv = false; bool moveRecv = false; //Wait for a bit sending and receiving until we're synced with other player while (state->lastACK != TYPE_MOVE || state->p2Move < 0) { //Show a dialog to the player char wait[32]; sprintf(wait, "Waiting for\nplayer %d", (endTime - rtMillis()) / 1000); statusDialog(wait); safeDisplay(); //Keep sending until an ACK is received if (state->lastACK != TYPE_MOVE) { //Fill out the rest of the packet packet->type = TYPE_MOVE; packet->data = state->p1Move; packet->round = state->round; ANXRFSend(packet, NINJA_PACKET_SIZE); } //Delay and do some ticking (400ms) for (uint8_t i = 0; i < 16; i++) { deepSleep(25); tick(); //Process any data that comes in _handlePackets(state, packet); } //give up on other player if (rtMillis() > endTime) { state->state = STATE_ABORT; break; } } //Bump them over to fight if (state->state != STATE_ABORT) state->state = STATE_FIGHT; } else if (state->state == STATE_FIGHT) { _fight(state, packet); state->state = STATE_SELECT_MOVE; state->round++; } else if (state->state == STATE_ABORT) { break; } deepSleep(200); tick(); } _gameOver(state); enablePopups(); }
void NounShip::destroyShip( Noun * pKiller, bool bZeroVelocity ) { // make sure the damage is enough m_Damage = maxDamage(); // clear the current order & command, so if they respawn the ship doesn't try to keep doing it's last command setCommand( NOCOMMAND, NULL ); setOrder( NOORDER, NULL, NULL ); // inform the context user first if ( pKiller != this ) { gameContext()->gameUser()->onDestroyed( this, pKiller ); if ( pKiller != NULL ) gameContext()->gameUser()->onKill( pKiller, this ); } else gameContext()->gameUser()->onSelfDestruct( this ); if ( WidgetCast<NounPlanet>( pKiller ) ) gameContext()->gameUser()->onCollidePlanet( this ); // create the primary explosion if ( context()->isClient() ) { Scene * pScene = destroyEffect(); if ( pScene != NULL ) { // TODO: no need to add this explosion of this player is nowhere near the explosion // ship destroyed, create the explosion effect SceneryDebris * pEffect = new SceneryDebris; pEffect->setNounContext( new NounContext( pScene ) ); pEffect->setContext( context() ); pEffect->setPosition( worldPosition() ); pEffect->setDelay( 0.0f ); pEffect->setFrame( frame() ); if (! bZeroVelocity ) pEffect->setVelocity( Vector3( sin( m_fHeading ) * m_fVelocity, 0.0f, cos( m_fHeading) * m_fVelocity ) ); if (! pEffect->setSegment( "Effect" ) ) pEffect->setLife( 15.0f ); context()->attachNoun( pEffect ); } NounTrail::CopyTrailsIntoZone( this ); } // list of destroyed items to remove from ship.. std::list< Noun * > destroyed; // damage enhancements, once they reach their maxDamage() they are destroyed.. for(int i=0;i<childCount();++i) { NounEnhancement * pEnh = WidgetCast<NounEnhancement>( child(i) ); if ( pEnh != NULL ) { if ( pEnh->incrementDamage() ) { LOG_STATUS( "NounShip", "[ENHANCEMENT]:Destroyed:%s:%s:%u", pEnh->getName(), name(), userId() ); message( CharString().format( "<color;ffffff>Comms: Enhancement '%s' destroyed!", pEnh->getName() ) ); destroyed.push_back( pEnh ); } continue; } // remove any beacons on death.. NounBeacon * pBeacon = WidgetCast<NounBeacon>( child(i) ); if ( pBeacon != NULL ) { destroyed.push_back( pBeacon ); continue; } } // server-side only logic if ( isServer() ) { // check for area damage Array< GameContext::NounCollision > collide; if ( context()->proximityCheck( worldPosition(), explodeArea(), collide ) ) { for(int i=0;i<collide.size();i++) { NounGame * pCollide = WidgetCast<NounGame>( collide[i].pNoun ); if ( !pCollide || pCollide == this ) continue; if ( pCollide->canDamage( DAMAGE_ENERGY | DAMAGE_KINETIC ) && collide[i].fDistance < explodeArea() ) { float damageRatio = 1.0f - (collide[i].fDistance / explodeArea()); int damage = damageRatio * explodeDamage(); if ( damage > 0 ) { pCollide->inflictDamage( tick(), this, damage, DAMAGE_ENERGY | DAMAGE_KINETIC, pCollide->worldFrame() * (worldPosition() - pCollide->worldPosition()) ); } } } } // drop enhancements after we do area damage, otherwise we'll destroy the dropped loot.. dropLoot(); // space-monsters do not leave behind devices if ( ! isMonster() ) { // eject some of the resources used to build the ship into space int nAmount = DESTROYED_SHIP_RESOURCE * buildCost( this ); while( nAmount > 0 ) { CargoResource::Ref pCargo = new CargoResource( nAmount ); nAmount -= pCargo->quantity(); Vector3 vPosition( worldPosition() + RandomVector( -radius(), radius() ) ); vPosition.y = 0.0f; pCargo->setPosition( vPosition ); context()->attachNoun( pCargo ); } //// check for any cargo items... if found put them into space //for(int i=0;i<childCount();i++) //{ // BaseNode * pChild = child(i); // NounCargo::Ref pCargo; // if ( WidgetCast<NounCargo>( pChild ) ) // { // int roll = rand() % 100; // if ( roll < ((NounCargo *)pChild)->durability() ) // pCargo = (NounCargo *)pChild->copy(); // } // if ( pCargo.valid() ) // { // Vector3 vPosition( worldPosition() + RandomVector( -5.0f, 5.0f ) ); // vPosition.y = 0.0f; // pCargo->setPosition( vPosition ); // context()->attachNoun( pCargo ); // } //} } // last before detach so that players dont dupe thier enhancements // that were dropped // save off storage with this "active" ship if(userId() != 0) context()->user()->saveStorage(this); } // remove desrtroyed items from ship.. while( destroyed.size() > 0 ) { Noun * pDestroyed = destroyed.front(); destroyed.pop_front(); if ( pDestroyed ) pDestroyed->detachSelf(); } // lastly, detach the ship from the universe setDetach(); }
/** Challenge another player at ninja */ void ninja() { //Used to store game state NinjaState state; state.lastACK = -1; state.lastNACK = -1; //Used as a timer to timeout of things uint32_t endTime; //Reset game packet state ninjaPacketAvailable = false; //Select a peer int16_t nodeid = getPeerFromUser(); if (nodeid == -1) { return; } //Up until this point we can interrupt the user disablePopups(); //Establish game state PeerNode peer = peers[nodeid]; state.p2nodeid = peer.nodeid; state.p2Level = peer.level; state.p2Name = peer.name; //Pre-determine tiebreakers by round based on selected player int16_t wthreshold = (100 * (ANXGetLevel() - state.p2Level + 3)) / 6; for (uint8_t i = 0; i < 3; i++) { state.tiebreaker[i] = random(100) <= wthreshold; } //Construct most of the packet now, we'll re-use it later NinjaPacket packet; packet.port = PORT_NINJA; packet.src = getNodeID(); packet.dest = peer.nodeid; packet.gameid = random(256); //Setup game with another player packet.type = TYPE_INIT; packet.data = state.tiebreaker[0] << 2 | state.tiebreaker[1] << 1 | state.tiebreaker[2]; //Wait for the other player to accept endTime = rtMillis() + 20000; char challenge[40]; memset(challenge, '\0', 40); sprintf(challenge, "Challenging\n%s\nLevel %d...", peer.name, peer.level); statusDialog(challenge); safeDisplay(); //Wait for ack while (state.lastACK != TYPE_INIT) { ANXRFSend(&packet, NINJA_PACKET_SIZE); //Roughly wait 200ms until next send for (uint8_t i = 0; i < 8; i++) { tick(); _handlePackets(&state, &packet); deepSleep(random(80)); } //Quit if time expires if (rtMillis() > endTime) { statusDialog("Challenge\nTimed out."); safeWaitForButton(); enablePopups(); return; } //Quit if NACKed by other user if ( state.lastNACK == TYPE_INIT) { statusDialog("Challenge\nRejected :("); safeWaitForButton(); enablePopups(); return; } } //Play the game _doNinja(&state, &packet); }
System::System(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { _funDel = kHeroFun0; setPal(); tick(); }
int main(int argc, char **argv) { int N; int nThreads; int nColumns; int i,j,k; double *A,*Bi,*C,*Ci; int BiRows, BiColumns; CompressedMatrix *cBi; CompressedMatrix *cCi; double elapsed; char printDebug; //************ Check Input **************/ if(argc < 3){ printf("Usage: %s MaxtrixSize NumberOfThreads\n" , argv[0] ); exit(EXIT_FAILURE); } N = atoi(argv[1]); if( N <= 1){ printf("MatrixSize must be bigger than 1!"); exit(EXIT_FAILURE); } nThreads = atoi(argv[2]); if( nThreads <= 1){ printf("NumberOfThreads must be bigger than 1!"); exit(EXIT_FAILURE); } omp_set_num_threads(nThreads); omp_set_schedule(omp_sched_dynamic, N/10); MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &mpi_id); MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); nColumns = N / mpi_size; //For the moment depend on N being a multiple the number of MPI nodes //************ Prepare Matrix **************/ A = (double *) malloc( N*N * sizeof(double) ); if((A == NULL) ){ printf("Running out of memory!\n"); exit(EXIT_FAILURE); } // if(mpi_id != 0){ // MPI_Finalize(); // exit(0); // } if(mpi_id == 0) { printDebug = 0; if(printDebug) printf("[%d] Generating A ...",mpi_id); //Fill matrixes. Generate Identity like matrix for A and B , So C should result in an matrix with a single major diagonal for(i=0; i < N; i++ ){ for(j=0; j < N; j++){ A[i+N*j] = (i==j)?i:0.0; // //Sparse Matrix with 10% population // A[i+N*j] = rand()%10; // if(A[i+N*j] == 0) // A[i+N*j] = rand()%10; // else // A[i+N*j] = 0; } } // printMatrix(A, N, nColumns); // cA = compressMatrix(A, N, nColumns); // printCompressedMatrix(cA); // uncompressMatrix(cA, &Bi, &i, &j); // printMatrix(Bi, i, j); // // MPI_Finalize(); // exit(0); tick(); if(printDebug) printf("[%d] Broadcasting A ...",mpi_id); MPI_Bcast( A, N*N, MPI_DOUBLE, 0, MPI_COMM_WORLD); if(printDebug) printf("[%d] Generating B ...",mpi_id); double* B; CompressedMatrix* cB; B = (double *) malloc( N*N * sizeof(double) ); for(i=0; i < N; i++ ){ for(j=0; j < N; j++){ B[j+N*i] = (i==j)?1.0:0.0; } } if(printDebug) printf("[%d] Compressing and distributing Bi ...",mpi_id); cB = compressMatrix(B, N, N); for(i=1; i < mpi_size; i++){ mpiSendCompressedMatrix(cB, i*nColumns, (i+1)*nColumns, i); } //Fake shorten cB free(B); cB->columns = nColumns; uncompressMatrix(cB, &Bi, &BiRows, &BiColumns); Ci = MatrixMultiply(A, N, N, Bi, nColumns); if(printDebug) printf("[%d] Ci = A x Bi ...", mpi_id); if(printDebug) printMatrix(Ci, N, nColumns); cCi = compressMatrix(Ci, N, nColumns); if(printDebug) printf("cCi ...\n"); if(printDebug) printCompressedMatrix(cCi); MPI_Barrier(MPI_COMM_WORLD); if(printDebug) printf("[%d] Receiving Ci fragments ...\n", mpi_id); CompressedMatrix** Cii; Cii = (CompressedMatrix**) malloc(sizeof(CompressedMatrix*) * mpi_size); if(Cii == NULL){ perror("malloc"); exit(EXIT_FAILURE); } Cii[0] = cCi; for(i=1; i < mpi_size; i++){ Cii[i] = mpiRecvCompressedMatrix(N,nColumns, i); } if(printDebug) printf("[%d] Joining Cii ...\n", mpi_id); CompressedMatrix *cC; cC = joinCompressedMatrices(Cii, mpi_size); if(printDebug) printCompressedMatrix(cC); elapsed = tack(); printf("[%d] C ...\n", mpi_id); uncompressMatrix(cC, &C, &i,&j); if(i <= 20){ printMatrix(C, i,j); } else { if(i < 1000){ printf("C is too big, only printing first diagonal %d.\n[",j); for(k=0; (k < i) && (k < j); k++){ printf("%3.2f ",C[k + k*j]); } printf("]\n"); } else { printf("C is just too big!"); } } printf("Took [%f] seconds!\n",elapsed); } else { printDebug = 0; if(printDebug) printf("[%d] Waiting for A ...",mpi_id); MPI_Bcast( A, N*N, MPI_DOUBLE, 0, MPI_COMM_WORLD); if(printDebug) printf("[%d] Received A ...\n", mpi_id); if(printDebug) printMatrix(A, N, N); if(printDebug) printf("[%d] Waiting for Bi ...",mpi_id); cBi = mpiRecvCompressedMatrix(N, nColumns, 0); uncompressMatrix(cBi, &Bi, &BiRows, &BiColumns); if(printDebug) printf("[%d] Received Bi ...",mpi_id); if(printDebug) printMatrix(Bi,BiRows, BiColumns); assert( (BiRows == N) && "Number or Rows in Bi is not right!"); assert( (BiColumns == nColumns) && "Number or Columns in Bi is not right!"); Ci = MatrixMultiply(A, N, N, Bi, BiColumns); if(printDebug) printf("[%d] Ci = A x Bi ...", mpi_id); if(printDebug) printMatrix(Ci, N, nColumns); cCi = compressMatrix(Ci, N, nColumns); if(printDebug) printCompressedMatrix(cCi); MPI_Barrier(MPI_COMM_WORLD); if(printDebug) printf("[%d] Returning Ci ...\n", mpi_id); mpiSendCompressedMatrix(cCi, 0, nColumns, 0); } MPI_Finalize(); // NxM = NxN * NxM exit(EXIT_SUCCESS); }
void TempoText::updateRelative() { qreal tempoBefore = score()->tempo(tick() - 1); setTempo(tempoBefore * _relative); }
Player::Player(QWidget *parent) : KXmlGuiWindow(parent) { //SETUP DATABASE QDir(KGlobal::dirs()->saveLocation("data")).mkdir("projekt7"); //NOTE: creates the projekt7 directory if it doesn't already exist QString db_path = KGlobal::dirs()->saveLocation("data") + "projekt7/tracks_db"; int return_code = sqlite3_open(qtos(db_path), &tracks_db); if (return_code) { showError("Failed to open the Projekt7 Track Database: ", sqlite3_errmsg(tracks_db)); exit(return_code); } const char *create_table = "CREATE TABLE IF NOT EXISTS `tracks` (`tid` INTEGER PRIMARY KEY, `artist` VARCHAR KEY ASC, `year` INT KEY ASC, `album` VARCHAR, `track_number` INT KEY ASC, `title` VARCHAR, `path` VARCHAR, `length` INT, `playcount` INT)"; //TODO make use of the `length` and `playcount` columns char *errmsg; return_code = sqlite3_exec(tracks_db, create_table, 0, 0, &errmsg); if (return_code) { showError("Failed to create `tracks` table: ", errmsg); sqlite3_free(errmsg); exit(return_code); } updateNumTracks(); //SETUP PHONON now_playing = new Phonon::MediaObject(this); Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); createPath(now_playing, audioOutput); now_playing->setTickInterval(1000); //SETUP WIDGETS QWidget *central_widget = new QWidget(this); KToolBar *toolbar_widget = new KToolBar(i18n("Main Toolbar"), central_widget); toolbar_widget->setIconDimensions(32); playlist_widget = new QWidget(central_widget); artist_list = new KListWidget(playlist_widget); artist_list->addItem(ALL); album_list = new KListWidget(playlist_widget); titles_list = new KListWidget(playlist_widget); QAction* tb_previousAction = toolbar_widget->addAction(KIcon("media-skip-backward"), ""); QString previousHelpText = i18n("Play the previous track"); tb_previousAction->setToolTip(previousHelpText); QAction* tb_pauseAction = toolbar_widget->addAction(KIcon("media-playback-pause"), ""); QString plauseHelpText = i18n("Plause playback"); tb_pauseAction->setToolTip(plauseHelpText); QAction* tb_playAction = toolbar_widget->addAction(KIcon("media-playback-start"), ""); QString playHelpText = i18n("Play the track"); tb_playAction->setToolTip(playHelpText); QAction* tb_nextAction = toolbar_widget->addAction(KIcon("media-skip-forward"), ""); QString nextHelpText = i18n("Play the next track"); tb_nextAction->setToolTip(nextHelpText); toolbar_widget->addSeparator(); Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider; volumeSlider->setAudioOutput(audioOutput); volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); toolbar_widget->addWidget(volumeSlider); toolbar_widget->addSeparator(); Phonon::SeekSlider *seekSlider = new Phonon::SeekSlider(now_playing); volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); toolbar_widget->addWidget(seekSlider); toolbar_widget->addSeparator(); cur_time = new QLabel(" 0:00", toolbar_widget); cur_time->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); toolbar_widget->addWidget(cur_time); toolbar_widget->addWidget(new QLabel(" / ", toolbar_widget)); track_duration = new QLabel("0:00", toolbar_widget); track_duration->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); toolbar_widget->addWidget(track_duration); queued = new KIcon("go-next-view"); QHBoxLayout *listLayout = new QHBoxLayout; listLayout->addWidget(artist_list); listLayout->addWidget(album_list); listLayout->addWidget(titles_list); playlist_widget->setLayout(listLayout); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(toolbar_widget); mainLayout->addWidget(playlist_widget); central_widget->setLayout(mainLayout); setCentralWidget(central_widget); //SETUP STATUS BAR KStatusBar* bar = statusBar(); bar->insertPermanentItem("", SONG_NAME, true); bar->setItemAlignment(SONG_NAME, Qt::AlignLeft | Qt::AlignVCenter); //SETUP SYSTEM TRAY ICON tray_icon = new KSystemTrayIcon("projekt7", this); tray_icon->show(); //SETUP METADATA WINDOW metadata_window = new QWidget(this, Qt::Dialog); metadata_window->setWindowModality(Qt::WindowModal); metadata_window->setWindowTitle("Track Details | Projekt 7"); mw_ok_button = new KPushButton(KIcon("dialog-ok-apply"), "OK", metadata_window); mw_ok_button->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); QGridLayout *mwLayout = new QGridLayout; mwLayout->addWidget(new QLabel("Artist:", metadata_window), 0, 0); mwLayout->addWidget(new QLabel("Year:", metadata_window), 1, 0); mwLayout->addWidget(new QLabel("Album:", metadata_window), 2, 0); mwLayout->addWidget(new QLabel("Track Number:", metadata_window), 3, 0); mwLayout->addWidget(new QLabel("Title:", metadata_window), 4, 0); mwLayout->addWidget(new QLabel("File Path:", metadata_window), 5, 0); mwLayout->addWidget(mw_artist = new QLabel(metadata_window), 0, 1); mwLayout->addWidget(mw_year = new QLabel(metadata_window), 1, 1); mwLayout->addWidget(mw_album = new QLabel(metadata_window), 2, 1); mwLayout->addWidget(mw_track_number = new QLabel(metadata_window), 3, 1); mwLayout->addWidget(mw_title = new QLabel(metadata_window), 4, 1); mwLayout->addWidget(mw_path = new QLabel(metadata_window), 5, 1); mwLayout->addWidget(mw_ok_button, 6, 0, 1, 2, Qt::AlignCenter); metadata_window->setLayout(mwLayout); //SETUP QUEUE EDITOR WINDOW queue_window = new QWidget(this, Qt::Dialog); queue_window->setWindowModality(Qt::WindowModal); queue_window->setWindowTitle("Track Queue Editor | Projekt 7"); qw_ok_button = new KPushButton(KIcon("dialog-ok-apply"), "OK", queue_window); qw_ok_button->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); QVBoxLayout *qw_buttons_layout = new QVBoxLayout; KPushButton *qw_top_button = new KPushButton(KIcon("go-top"), "", queue_window); KPushButton *qw_up_button = new KPushButton(KIcon("go-up"), "", queue_window); KPushButton *qw_down_button = new KPushButton(KIcon("go-down"), "", queue_window); KPushButton *qw_bottom_button = new KPushButton(KIcon("go-bottom"), "", queue_window); KPushButton *qw_remove_button = new KPushButton(KIcon("edit-delete"), "", queue_window); qw_buttons_layout->addWidget(qw_top_button); qw_buttons_layout->addWidget(qw_up_button); qw_buttons_layout->addWidget(qw_down_button); qw_buttons_layout->addWidget(qw_bottom_button); qw_buttons_layout->addWidget(qw_remove_button); QHBoxLayout *qw_list_buttons_layout = new QHBoxLayout; qw_queue_list = new KListWidget(queue_window); QWidget *qw_button_holder = new QWidget(queue_window); qw_button_holder->setLayout(qw_buttons_layout); qw_list_buttons_layout->addWidget(qw_queue_list); qw_list_buttons_layout->addWidget(qw_button_holder); QVBoxLayout *qwLayout = new QVBoxLayout; QWidget *qw_list_buttons = new QWidget(queue_window); qw_list_buttons->setLayout(qw_list_buttons_layout); qwLayout->addWidget(qw_list_buttons); qwLayout->addWidget(qw_ok_button, 0, Qt::AlignCenter); queue_window->setLayout(qwLayout); //SETUP ACTIONS KStandardAction::quit(kapp, SLOT(quit()), actionCollection()); connect(kapp, SIGNAL(aboutToQuit()), this, SLOT(quit())); connect(now_playing, SIGNAL(aboutToFinish()), this, SLOT(enqueueNext())); connect(now_playing, SIGNAL(totalTimeChanged(qint64)), this, SLOT(updateDuration(qint64))); connect(now_playing, SIGNAL(tick(qint64)), this, SLOT(tick(qint64))); KAction *openFilesAction = setupKAction("document-open", i18n("Open"), i18n("Load the selected files"), "files"); openFilesAction->setShortcut(QKeySequence::Open); connect(openFilesAction, SIGNAL(triggered(bool)), this, SLOT(loadFiles())); KAction *openDirectoryAction = setupKAction("document-open-folder", i18n("Open Directory..."), i18n("Load all files in the selected directory and its subdirectories"), "directory"); openDirectoryAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); connect(openDirectoryAction, SIGNAL(triggered(bool)), this, SLOT(loadDirectory())); KAction *previousAction = setupKAction("media-skip-backward", i18n("Previous"), previousHelpText, "previous"); previousAction->setShortcut(QKeySequence(Qt::Key_Z)); connect(previousAction, SIGNAL(triggered(bool)), this, SLOT(previous())); connect(tb_previousAction, SIGNAL(triggered(bool)), this, SLOT(previous())); KAction *pauseAction = setupKAction("media-playback-pause", i18n("Pause"), plauseHelpText, "pause"); pauseAction->setShortcut(QKeySequence(Qt::Key_C)); connect(pauseAction, SIGNAL(triggered(bool)), this, SLOT(pause())); connect(tb_pauseAction, SIGNAL(triggered(bool)), this, SLOT(pause())); KAction *playAction = setupKAction("media-playback-start", i18n("Play"), playHelpText, "play"); playAction->setShortcut(QKeySequence(Qt::Key_X)); connect(playAction, SIGNAL(triggered(bool)), this, SLOT(play())); connect(tb_playAction, SIGNAL(triggered(bool)), this, SLOT(play())); KAction *nextAction = setupKAction("media-skip-forward", i18n("Next"), nextHelpText, "next"); nextAction->setShortcut(QKeySequence(Qt::Key_V)); connect(nextAction, SIGNAL(triggered(bool)), this, SLOT(next())); connect(tb_nextAction, SIGNAL(triggered(bool)), this, SLOT(next())); KAction *queueAction = setupKAction("go-next-view", i18n("Queue Track"), "Enqueue the current track", "queue"); queueAction->setShortcut(QKeySequence(Qt::Key_Q)); connect(queueAction, SIGNAL(triggered(bool)), this, SLOT(queue())); shuffleAction = setupKAction("media-playlist-shuffle", i18n("Suffle"), "The next track will be random when checked", "shuffle"); shuffleAction->setCheckable(true); connect(shuffleAction, SIGNAL(triggered(bool)), this, SLOT(shuffle(bool))); KAction *viewCurrentTrackAction = setupKAction("go-last", i18n("Current Track"), i18n("Show the Current Track in the Playlist"), "current_track"); connect(viewCurrentTrackAction, SIGNAL(triggered(bool)), this, SLOT(viewCurrentTrack())); KAction *viewTrackDetailsAction = setupKAction("view-media-lyrics", i18n("Track Details"), i18n("View the playing track's metadata"), "track_details"); connect(viewTrackDetailsAction, SIGNAL(triggered(bool)), this, SLOT(viewTrackDetails())); KAction *viewTrackQueueAction = setupKAction("view-time-schedule-edit", i18n("Track Queue"), i18n("Edit the track queue"), "track_queue"); connect(viewTrackQueueAction, SIGNAL(triggered(bool)), this, SLOT(viewTrackQueue())); viewPlaylistAction = setupKAction("view-file-columns", i18n("Playlist"), i18n("Show/Hide the playlist"), "playlist"); viewPlaylistAction->setCheckable(true); connect(viewPlaylistAction, SIGNAL(triggered(bool)), this, SLOT(viewPlaylist(bool))); connect(artist_list, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(updateAlbumList(QListWidgetItem *, QListWidgetItem *))); connect(album_list, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(updateTitlesList(QListWidgetItem *, QListWidgetItem *))); connect(titles_list, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(showTrackInfo(QListWidgetItem *, QListWidgetItem *))); connect(titles_list, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(play(QListWidgetItem *))); connect(mw_ok_button, SIGNAL(clicked()), this, SLOT(hideTrackDetails())); connect(qw_top_button, SIGNAL(clicked()), this, SLOT(moveQueuedTrackToTop())); connect(qw_up_button, SIGNAL(clicked()), this, SLOT(moveQueuedTrackUp())); connect(qw_down_button, SIGNAL(clicked()), this, SLOT(moveQueuedTrackDown())); connect(qw_bottom_button, SIGNAL(clicked()), this, SLOT(moveQueuedTrackToBottom())); connect(qw_remove_button, SIGNAL(clicked()), this, SLOT(dequeueTrack())); connect(qw_ok_button, SIGNAL(clicked()), this, SLOT(hideTrackQueue())); //SETUP GUI qsrand(QDateTime::currentDateTime().toTime_t()); setupGUI(Default, "projekt7ui.rc"); updateArtistList(0); //READ CONFIG config = KGlobal::config(); KConfigGroup curTrackDetails(config, "curTrackDetails"); cur_artist = artist_list->item(curTrackDetails.readEntry("artist", QString()).toInt()); cur_album = curTrackDetails.readEntry("album", QString()).toInt(); cur_title = curTrackDetails.readEntry("title", QString()).toInt(); KConfigGroup applicationSettings(config, "applicationSettings"); viewPlaylistAction->setChecked(applicationSettings.readEntry("playlistVisible", QString()).toInt()); shuffle_tracks = applicationSettings.readEntry("shuffleTracks", QString()).toInt(); shuffleAction->setChecked(shuffle_tracks); viewCurrentTrack(); if (titles_list->count() > 0) { if (titles_list->currentRow() == -1) titles_list->setCurrentRow(0); play(titles_list->currentItem()->data(Qt::UserRole).toInt(), false, false); pause(); quint64 song_position = curTrackDetails.readEntry("tick", QString()).toLongLong(); now_playing->seek(song_position); tick(song_position); //TODO update the seekSlider's position to match the "tick" location of the song } }
void DSP::enter() { while(true) { if(scheduler.sync.i == Scheduler::SynchronizeMode::All) { scheduler.exit(Scheduler::ExitReason::SynchronizeEvent); } voice_5(voice[0]); voice_2(voice[1]); tick(); voice_6(voice[0]); voice_3(voice[1]); tick(); voice_7(voice[0]); voice_4(voice[1]); voice_1(voice[3]); tick(); voice_8(voice[0]); voice_5(voice[1]); voice_2(voice[2]); tick(); voice_9(voice[0]); voice_6(voice[1]); voice_3(voice[2]); tick(); voice_7(voice[1]); voice_4(voice[2]); voice_1(voice[4]); tick(); voice_8(voice[1]); voice_5(voice[2]); voice_2(voice[3]); tick(); voice_9(voice[1]); voice_6(voice[2]); voice_3(voice[3]); tick(); voice_7(voice[2]); voice_4(voice[3]); voice_1(voice[5]); tick(); voice_8(voice[2]); voice_5(voice[3]); voice_2(voice[4]); tick(); voice_9(voice[2]); voice_6(voice[3]); voice_3(voice[4]); tick(); voice_7(voice[3]); voice_4(voice[4]); voice_1(voice[6]); tick(); voice_8(voice[3]); voice_5(voice[4]); voice_2(voice[5]); tick(); voice_9(voice[3]); voice_6(voice[4]); voice_3(voice[5]); tick(); voice_7(voice[4]); voice_4(voice[5]); voice_1(voice[7]); tick(); voice_8(voice[4]); voice_5(voice[5]); voice_2(voice[6]); tick(); voice_9(voice[4]); voice_6(voice[5]); voice_3(voice[6]); tick(); voice_1(voice[0]); voice_7(voice[5]); voice_4(voice[6]); tick(); voice_8(voice[5]); voice_5(voice[6]); voice_2(voice[7]); tick(); voice_9(voice[5]); voice_6(voice[6]); voice_3(voice[7]); tick(); voice_1(voice[1]); voice_7(voice[6]); voice_4(voice[7]); tick(); voice_8(voice[6]); voice_5(voice[7]); voice_2(voice[0]); tick(); voice_3a(voice[0]); voice_9(voice[6]); voice_6(voice[7]); echo_22(); tick(); voice_7(voice[7]); echo_23(); tick(); voice_8(voice[7]); echo_24(); tick(); voice_3b(voice[0]); voice_9(voice[7]); echo_25(); tick(); echo_26(); tick(); misc_27(); echo_27(); tick(); misc_28(); echo_28(); tick(); misc_29(); echo_29(); tick(); misc_30(); voice_3c(voice[0]); echo_30(); tick(); voice_4(voice[0]); voice_1(voice[2]); tick(); } }
AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget* parent) : RollupWidget(parent), ui(new Ui::AMDemodGUI), m_pluginAPI(pluginAPI), m_deviceAPI(deviceAPI), m_channelMarker(this), m_basicSettingsShown(false), m_doApplySettings(true), m_squelchOpen(false) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked())); m_amDemod = new AMDemod(); m_channelizer = new DownChannelizer(m_amDemod); m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this); //m_pluginAPI->addThreadedSink(m_threadedChannelizer); m_deviceAPI->addThreadedSink(m_threadedChannelizer); connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold)); ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue); //m_channelMarker = new ChannelMarker(this); m_channelMarker.setColor(Qt::yellow); m_channelMarker.setBandwidth(5000); m_channelMarker.setCenterFrequency(0); m_channelMarker.setVisible(true); connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged())); m_deviceAPI->registerChannelInstance(m_channelID, this); m_deviceAPI->addChannelMarker(&m_channelMarker); m_deviceAPI->addRollupWidget(this); applySettings(); }
void SmoothValue::process() { for (int i = 0; i < buffer_size_; ++i) outputs_[0]->buffer[i] = tick(); }
void TimeSig::layout() { setPos(0.0, 0.0); qreal _spatium = spatium(); setbbox(QRectF()); // prepare for an empty time signature pointLargeLeftParen = QPointF(); pz = QPointF(); pn = QPointF(); pointLargeRightParen = QPointF(); qreal lineDist; int numOfLines; TimeSigType sigType = timeSigType(); Staff* _staff = staff(); if (_staff) { // if staff is without time sig, format as if no text at all if (!_staff->staffType(tick())->genTimesig() ) { // reset position and box sizes to 0 // qDebug("staff: no time sig"); pointLargeLeftParen.rx() = 0.0; pn.rx() = 0.0; pz.rx() = 0.0; pointLargeRightParen.rx() = 0.0; setbbox(QRectF()); // leave everything else as it is: // draw() will anyway skip any drawing if staff type has no time sigs return; } numOfLines = _staff->lines(tick()); lineDist = _staff->lineDistance(tick()); } else { // assume dimensions of a standard staff lineDist = 1.0; numOfLines = 5; } // if some symbol // compute vert. displacement to center in the staff height // determine middle staff position: qreal yoff = _spatium * (numOfLines-1) *.5 * lineDist; // C and Ccut are placed at the middle of the staff: use yoff directly if (sigType == TimeSigType::FOUR_FOUR) { pz = QPointF(0.0, yoff); setbbox(symBbox(SymId::timeSigCommon).translated(pz)); ns.clear(); ns.push_back(SymId::timeSigCommon); ds.clear(); } else if (sigType == TimeSigType::ALLA_BREVE) { pz = QPointF(0.0, yoff); setbbox(symBbox(SymId::timeSigCutCommon).translated(pz)); ns.clear(); ns.push_back(SymId::timeSigCutCommon); ds.clear(); } else { ns = toTimeSigString(_numeratorString.isEmpty() ? QString::number(_sig.numerator()) : _numeratorString); ds = toTimeSigString(_denominatorString.isEmpty() ? QString::number(_sig.denominator()) : _denominatorString); ScoreFont* font = score()->scoreFont(); QSizeF mag(magS() * _scale); QRectF numRect = font->bbox(ns, mag); QRectF denRect = font->bbox(ds, mag); // position numerator and denominator; vertical displacement: // number of lines is odd: 0.0 (strings are directly above and below the middle line) // number of lines even: 0.05 (strings are moved up/down to leave 1/10sp between them) qreal displ = (numOfLines & 1) ? 0.0 : (0.05 * _spatium); //align on the wider qreal pzY = yoff - (denRect.width() < 0.01 ? 0.0 : (displ + numRect.height() * .5)); qreal pnY = yoff + displ + denRect.height() * .5; if (numRect.width() >= denRect.width()) { // numerator: one space above centre line, unless denomin. is empty (if so, directly centre in the middle) pz = QPointF(0.0, pzY); // denominator: horiz: centred around centre of numerator | vert: one space below centre line pn = QPointF((numRect.width() - denRect.width())*.5, pnY); } else { // numerator: one space above centre line, unless denomin. is empty (if so, directly centre in the middle) pz = QPointF((denRect.width() - numRect.width())*.5, pzY); // denominator: horiz: centred around centre of numerator | vert: one space below centre line pn = QPointF(0.0, pnY); } // centering of parenthesis so the middle of the parenthesis is at the divisor marking level int centerY = yoff/2 + _spatium; int widestPortion = numRect.width() > denRect.width() ? numRect.width() : denRect.width(); pointLargeLeftParen = QPointF(-_spatium, centerY); pointLargeRightParen = QPointF(widestPortion + _spatium, centerY); setbbox(numRect.translated(pz)); // translate bounding boxes to actual string positions addbbox(denRect.translated(pn)); if (_largeParentheses) { addbbox(QRect(pointLargeLeftParen.x(), pointLargeLeftParen.y() - denRect.height(), _spatium / 2, numRect.height() + denRect.height())); addbbox(QRect(pointLargeRightParen.x(), pointLargeRightParen.y() - denRect.height(), _spatium / 2, numRect.height() + denRect.height())); } } }
void ToyMetroWidget::onTick(int pos) { emit tick(this, pos); }
void NPlaybackEngineGStreamer::checkStatus() { GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(m_playbin)); GstMessage *msg; while ((msg = gst_bus_pop_filtered(bus, GstMessageType(GST_MESSAGE_EOS | GST_MESSAGE_ERROR))) != NULL) { switch (GST_MESSAGE_TYPE(msg)) { case GST_MESSAGE_EOS: { stop(); emit finished(); emit stateChanged(m_oldState = N::PlaybackStopped); break; } case GST_MESSAGE_ERROR: { gchar *debug; GError *err = NULL; gst_message_parse_error(msg, &err, &debug); g_free(debug); emit message(QMessageBox::Critical, QFileInfo(m_currentMedia).absoluteFilePath(), err ? QString::fromUtf8(err->message) : "unknown error"); fail(); if (err) g_error_free(err); break; } default: break; } gst_message_unref(msg); } gst_object_unref(bus); GstState gstState; if (gst_element_get_state(m_playbin, &gstState, NULL, 0) != GST_STATE_CHANGE_SUCCESS) return; N::PlaybackState state = fromGstState(gstState); if (m_oldState != state) emit stateChanged(m_oldState = state); if (state == N::PlaybackPlaying || state == N::PlaybackPaused) { // duration may change for some reason // TODO use DURATION_CHANGED in gstreamer1.0 gboolean res = gst_element_query_duration(m_playbin, GST_FORMAT_TIME, &m_durationNsec); if (!res) m_durationNsec = 0; } if (m_posponedPosition >= 0 && m_durationNsec > 0) { setPosition(m_posponedPosition); m_posponedPosition = -1; emit positionChanged(m_posponedPosition); } else { qreal pos; gint64 gstPos = 0; if (!hasMedia() || m_durationNsec <= 0) { pos = -1; } else { gboolean res = gst_element_query_position(m_playbin, GST_FORMAT_TIME, &gstPos); if (!res) gstPos = 0; pos = (qreal)gstPos / m_durationNsec; } if (m_oldPosition != pos) { if (m_oldPosition > pos) m_crossfading = false; m_oldPosition = pos; emit positionChanged(m_crossfading ? 0 : m_oldPosition); } emit tick(m_crossfading ? 0 : gstPos / NSEC_IN_MSEC); } qreal vol = volume(); if (qAbs(m_oldVolume - vol) > 0.0001) { m_oldVolume = vol; emit volumeChanged(vol); } if (state == N::PlaybackStopped) m_timer->stop(); }
void Stopwatch::computeOverhead() { cycleOverhead = 0; tick(); tock(); cycleOverhead = elapsedCycles(); }
void reset() { deltaStart_ = start_ = tick(); }
inline TTErr TTSvf::calculateNotch(const TTFloat64& x, TTFloat64& y, TTPtrSizedInt channel) { tick(x, channel); y = 0.5 * mNotch_output[channel]; return kTTErrNone; }