void JackOutput::updateTransportInfo() { if ( locate_countdown == 1 ) locate( locate_frame ); if ( locate_countdown > 0 ) locate_countdown--; if ( Preferences::get_instance()->m_bJackTransportMode != Preferences::USE_JACK_TRANSPORT ) return; m_JackTransportState = jack_transport_query( client, &m_JackTransportPos ); // update m_transport with jack-transport data switch ( m_JackTransportState ) { case JackTransportStopped: m_transport.m_status = TransportInfo::STOPPED; //infoLog( "[updateTransportInfo] STOPPED - frames: " + to_string(m_transportPos.frame) ); break; case JackTransportRolling: if ( m_transport.m_status != TransportInfo::ROLLING && ( m_JackTransportPos.valid & JackPositionBBT ) ) { must_relocate = 2; //WARNINGLOG( "Jack transport starting: Resyncing in 2 x Buffersize!!" ); } m_transport.m_status = TransportInfo::ROLLING; //infoLog( "[updateTransportInfo] ROLLING - frames: " + to_string(m_transportPos.frame) ); break; case JackTransportStarting: m_transport.m_status = TransportInfo::STOPPED; //infoLog( "[updateTransportInfo] STARTING (stopped) - frames: " + to_string(m_transportPos.frame) ); break; default: ERRORLOG( "Unknown jack transport state" ); } // FIXME // TickSize and BPM Hydrogen * H = Hydrogen::get_instance(); H->setTimelineBpm(); // dlr: fix #168, jack may have re-located us anywhere, check for bpm change every cycle if ( m_JackTransportPos.valid & JackPositionBBT ) { float bpm = ( float )m_JackTransportPos.beats_per_minute; if ( m_transport.m_nBPM != bpm ) { if ( Preferences::get_instance()->m_bJackMasterMode == Preferences::NO_JACK_TIME_MASTER ){ // WARNINGLOG( QString( "Tempo change from jack-transport: %1" ).arg( bpm ) ); m_transport.m_nBPM = bpm; must_relocate = 1; // The tempo change has happened somewhere during the previous cycle; relocate right away. // This commenting out is rude perhaps, but I cant't figure out what this bit is doing. // In any case, setting must_relocate = 1 here causes too many relocates. Jakob Lund /* } else { if ( m_transport.m_status == TransportInfo::STOPPED ) { oldpo = H->getPatternPos(); must_relocate = 1; //changer =1; }*/ } // Hydrogen::get_instance()->setBPM( m_JackTransportPos.beats_per_minute ); // unnecessary, as Song->m_BPM gets updated in audioEngine_process_transport (after calling this function) } } if ( m_transport.m_nFrames + bbt_frame_offset != m_JackTransportPos.frame ) { if ( ( m_JackTransportPos.valid & JackPositionBBT ) && must_relocate == 0 ) { WARNINGLOG( "Frame offset mismatch; triggering resync in 2 cycles" ); must_relocate = 2; } else { if ( Preferences::get_instance()->m_bJackMasterMode == Preferences::NO_JACK_TIME_MASTER ) { // If There's no timebase_master, and audioEngine_process_checkBPMChanged handled a tempo change during last cycle, the offset doesn't match, but hopefully it was calculated correctly: //this perform Jakobs mod in pattern mode, but both m_transport.m_nFrames works with the same result in pattern Mode // in songmode the first case dont work. //so we can remove this "if query" and only use this old mod: m_transport.m_nFrames = H->getHumantimeFrames(); //because to get the songmode we have to add this "H2Core::Hydrogen *m_pEngine" to the header file //if we remove this we also can remove *m_pEngine from header #if 0 // dlr: fix #169, why do we have a different behaviour for SONG_MODE? if ( m_pEngine->getSong()->get_mode() == Song::PATTERN_MODE ){ m_transport.m_nFrames = m_JackTransportPos.frame/* - bbt_frame_offset*/; ///see comment in svn changeset 753 } else { m_transport.m_nFrames = H->getHumantimeFrames(); } #else m_transport.m_nFrames = m_JackTransportPos.frame; bbt_frame_offset = 0; // dlr: stop re-syncing in every cycle when STOPPED #endif // In jack 'slave' mode, if there's no master, the following line is needed to be able to relocate by clicking the song ruler (wierd corner case, but still...) if ( m_transport.m_status == TransportInfo::ROLLING ) H->triggerRelocateDuringPlay(); } else { ///this is experimantal... but it works for the moment... fix me fix :-) wolke // ... will this actually happen? keeping it for now ( jakob lund ) m_transport.m_nFrames = H->getHumantimeFrames(); } } } // humantime fix if ( H->getHumantimeFrames() != m_JackTransportPos.frame ) { H->setHumantimeFrames(m_JackTransportPos.frame); //WARNINGLOG("fix Humantime " + to_string (m_JackTransportPos.frame)); } if ( must_relocate == 1 ) { //WARNINGLOG( "Resyncing!" ); relocateBBT(); if ( m_transport.m_status == TransportInfo::ROLLING ) { H->triggerRelocateDuringPlay(); } } if ( must_relocate > 0 ) must_relocate--; }
/** * The handleAction method is the heard of the MidiActionManager class. * It executes the operations that are needed to carry the desired action. */ bool MidiActionManager::handleAction( MidiAction * pAction ){ Hydrogen *pEngine = Hydrogen::get_instance(); /* return false if action is null (for example if no Action exists for an event) */ if( pAction == NULL ) return false; QString sActionString = pAction->getType(); if( sActionString == "PLAY" ) { int nState = pEngine->getState(); if ( nState == STATE_READY ){ pEngine->sequencer_play(); } return true; } if( sActionString == "PLAY/STOP_TOGGLE" || sActionString == "PLAY/PAUSE_TOGGLE" ) { int nState = pEngine->getState(); switch ( nState ) { case STATE_READY: pEngine->sequencer_play(); break; case STATE_PLAYING: if( sActionString == "PLAY/STOP_TOGGLE" ) pEngine->setPatternPos( 0 ); pEngine->sequencer_stop(); pEngine->setTimelineBpm(); break; default: ERRORLOG( "[Hydrogen::ActionManager(PLAY): Unhandled case" ); } return true; } if( sActionString == "PAUSE" ) { pEngine->sequencer_stop(); return true; } if( sActionString == "STOP" ) { pEngine->sequencer_stop(); pEngine->setPatternPos( 0 ); pEngine->setTimelineBpm(); return true; } if( sActionString == "MUTE" ){ //mutes the master, not a single strip pEngine->getSong()->__is_muted = true; return true; } if( sActionString == "UNMUTE" ){ pEngine->getSong()->__is_muted = false; return true; } if( sActionString == "MUTE_TOGGLE" ){ pEngine->getSong()->__is_muted = !Hydrogen::get_instance()->getSong()->__is_muted; return true; } if( sActionString == "BEATCOUNTER" ){ pEngine->handleBeatCounter(); return true; } if( sActionString == "TAP_TEMPO" ){ pEngine->onTapTempoAccelEvent(); return true; } if( sActionString == "SELECT_NEXT_PATTERN" ){ bool ok; int row = pAction->getParameter1().toInt(&ok,10); if( row> pEngine->getSong()->get_pattern_list()->size() -1 ) return false; if(Preferences::get_instance()->patternModePlaysSelected()) pEngine->setSelectedPatternNumber( row ); else pEngine->sequencer_setNextPattern( row, false, true ); return true; } if( sActionString == "SELECT_NEXT_PATTERN_RELATIVE" ){ bool ok; if(!Preferences::get_instance()->patternModePlaysSelected()) { return true; } int row = pEngine->getSelectedPatternNumber() + pAction->getParameter1().toInt(&ok,10); if( row> pEngine->getSong()->get_pattern_list()->size() -1 ) { return false; } pEngine->setSelectedPatternNumber( row ); return true; } if( sActionString == "SELECT_PREV_PATTERN_RELATIVE" ){ bool ok; if(!Preferences::get_instance()->patternModePlaysSelected()) return true; int row = pEngine->getSelectedPatternNumber() - pAction->getParameter1().toInt(&ok,10); if( row < 0 ) return false; pEngine->setSelectedPatternNumber( row ); return true; } if( sActionString == "SELECT_NEXT_PATTERN_CC_ABSOLUT" ){ bool ok; int row = pAction->getParameter2().toInt(&ok,10); if( row> pEngine->getSong()->get_pattern_list()->size() -1 ) return false; if(Preferences::get_instance()->patternModePlaysSelected()) pEngine->setSelectedPatternNumber( row ); else return true;// only usefully in normal pattern mode return true; } if( sActionString == "SELECT_NEXT_PATTERN_PROMPTLY" ){// obsolete, use SELECT_NEXT_PATTERN_CC_ABSOLUT instead bool ok; int row = pAction->getParameter2().toInt(&ok,10); pEngine->setSelectedPatternNumberWithoutGuiEvent( row ); return true; } if( sActionString == "SELECT_AND_PLAY_PATTERN"){ bool ok; int row = pAction->getParameter1().toInt(&ok,10); pEngine->setSelectedPatternNumber( row ); pEngine->sequencer_setNextPattern( row, false, true ); int nState = pEngine->getState(); if ( nState == STATE_READY ){ pEngine->sequencer_play(); } return true; } if( sActionString == "SELECT_INSTRUMENT" ){ bool ok; int instrument_number = pAction->getParameter2().toInt(&ok,10) ; if ( pEngine->getSong()->get_instrument_list()->size() < instrument_number ) instrument_number = pEngine->getSong()->get_instrument_list()->size() -1; pEngine->setSelectedInstrumentNumber( instrument_number ); return true; } if( sActionString == "EFFECT1_LEVEL_ABSOLUTE" ){ bool ok; int nLine = pAction->getParameter1().toInt(&ok,10); int fx_param = pAction->getParameter2().toInt(&ok,10); setAbsoluteFXLevel( nLine, 0 , fx_param ); } if( sActionString == "EFFECT2_LEVEL_ABSOLUTE" ){ bool ok; int nLine = pAction->getParameter1().toInt(&ok,10); int fx_param = pAction->getParameter2().toInt(&ok,10); setAbsoluteFXLevel( nLine, 1 , fx_param ); } if( sActionString == "EFFECT3_LEVEL_ABSOLUTE" ){ bool ok; int nLine = pAction->getParameter1().toInt(&ok,10); int fx_param = pAction->getParameter2().toInt(&ok,10); setAbsoluteFXLevel( nLine, 2 , fx_param ); } if( sActionString == "EFFECT4_LEVEL_ABSOLUTE" ){ bool ok; int nLine = pAction->getParameter1().toInt(&ok,10); int fx_param = pAction->getParameter2().toInt(&ok,10); setAbsoluteFXLevel( nLine, 3 , fx_param ); } if( sActionString == "MASTER_VOLUME_RELATIVE" ){ //increments/decrements the volume of the whole song bool ok; int vol_param = pAction->getParameter2().toInt(&ok,10); Hydrogen *engine = Hydrogen::get_instance(); Song *song = engine->getSong(); if( vol_param != 0 ){ if ( vol_param == 1 && song->get_volume() < 1.5 ){ song->set_volume( song->get_volume() + 0.05 ); } else { if( song->get_volume() >= 0.0 ){ song->set_volume( song->get_volume() - 0.05 ); } } } else { song->set_volume( 0 ); } } if( sActionString == "MASTER_VOLUME_ABSOLUTE" ){ //sets the volume of a master output to a given level (percentage) bool ok; int vol_param = pAction->getParameter2().toInt(&ok,10); Hydrogen *engine = Hydrogen::get_instance(); Song *song = engine->getSong(); if( vol_param != 0 ){ song->set_volume( 1.5* ( (float) (vol_param / 127.0 ) )); } else { song->set_volume( 0 ); } } if( sActionString == "STRIP_VOLUME_RELATIVE" ){ //increments/decrements the volume of one mixer strip bool ok; int nLine = pAction->getParameter1().toInt(&ok,10); int vol_param = pAction->getParameter2().toInt(&ok,10); Hydrogen::get_instance()->setSelectedInstrumentNumber( nLine ); Hydrogen *engine = Hydrogen::get_instance(); Song *song = engine->getSong(); InstrumentList *instrList = song->get_instrument_list(); Instrument *instr = instrList->get( nLine ); if ( instr == NULL) return 0; if( vol_param != 0 ){ if ( vol_param == 1 && instr->get_volume() < 1.5 ){ instr->set_volume( instr->get_volume() + 0.1 ); } else { if( instr->get_volume() >= 0.0 ){ instr->set_volume( instr->get_volume() - 0.1 ); } } } else { instr->set_volume( 0 ); } Hydrogen::get_instance()->setSelectedInstrumentNumber(nLine); } if( sActionString == "STRIP_VOLUME_ABSOLUTE" ){ //sets the volume of a mixer strip to a given level (percentage) bool ok; int nLine = pAction->getParameter1().toInt(&ok,10); int vol_param = pAction->getParameter2().toInt(&ok,10); Hydrogen::get_instance()->setSelectedInstrumentNumber( nLine ); Hydrogen *engine = Hydrogen::get_instance(); Song *song = engine->getSong(); InstrumentList *instrList = song->get_instrument_list(); Instrument *instr = instrList->get( nLine ); if ( instr == NULL) return 0; if( vol_param != 0 ){ instr->set_volume( 1.5* ( (float) (vol_param / 127.0 ) )); } else { instr->set_volume( 0 ); } Hydrogen::get_instance()->setSelectedInstrumentNumber(nLine); } if( sActionString == "PAN_ABSOLUTE" ){ // sets the absolute panning of a given mixer channel bool ok; int nLine = pAction->getParameter1().toInt(&ok,10); int pan_param = pAction->getParameter2().toInt(&ok,10); float pan_L; float pan_R; Hydrogen *engine = Hydrogen::get_instance(); engine->setSelectedInstrumentNumber( nLine ); Song *song = engine->getSong(); InstrumentList *instrList = song->get_instrument_list(); Instrument *instr = instrList->get( nLine ); if( instr == NULL ) return false; pan_L = instr->get_pan_l(); pan_R = instr->get_pan_r(); // pan float fPanValue = 0.0; if (pan_R == 1.0) { fPanValue = 1.0 - (pan_L / 2.0); } else { fPanValue = pan_R / 2.0; } fPanValue = 1 * ( ((float) pan_param) / 127.0 ); if (fPanValue >= 0.5) { pan_L = (1.0 - fPanValue) * 2; pan_R = 1.0; } else { pan_L = 1.0; pan_R = fPanValue * 2; } instr->set_pan_l( pan_L ); instr->set_pan_r( pan_R ); Hydrogen::get_instance()->setSelectedInstrumentNumber(nLine); return true; } if( sActionString == "PAN_RELATIVE" ){ // changes the panning of a given mixer channel // this is useful if the panning is set by a rotary control knob bool ok; int nLine = pAction->getParameter1().toInt(&ok,10); int pan_param = pAction->getParameter2().toInt(&ok,10); float pan_L; float pan_R; Hydrogen *engine = Hydrogen::get_instance(); engine->setSelectedInstrumentNumber( nLine ); Song *song = engine->getSong(); InstrumentList *instrList = song->get_instrument_list(); Instrument *instr = instrList->get( nLine ); if( instr == NULL ) return false; pan_L = instr->get_pan_l(); pan_R = instr->get_pan_r(); // pan float fPanValue = 0.0; if (pan_R == 1.0) { fPanValue = 1.0 - (pan_L / 2.0); } else { fPanValue = pan_R / 2.0; } if( pan_param == 1 && fPanValue < 1 ){ fPanValue += 0.05; } if( pan_param != 1 && fPanValue > 0 ){ fPanValue -= 0.05; } if (fPanValue >= 0.5) { pan_L = (1.0 - fPanValue) * 2; pan_R = 1.0; } else { pan_L = 1.0; pan_R = fPanValue * 2; } instr->set_pan_l( pan_L ); instr->set_pan_r( pan_R ); Hydrogen::get_instance()->setSelectedInstrumentNumber(nLine); return true; } if( sActionString == "BPM_CC_RELATIVE" ){ /* * increments/decrements the BPM * this is useful if the bpm is set by a rotary control knob */ AudioEngine::get_instance()->lock( RIGHT_HERE ); int mult = 1; //second parameter of cc command //this value should be 1 to decrement and something other then 1 to increment the bpm int cc_param = 1; //this Action should be triggered only by CC commands bool ok; mult = pAction->getParameter1().toInt(&ok,10); cc_param = pAction->getParameter2().toInt(&ok,10); if( lastBpmChangeCCParameter == -1) { lastBpmChangeCCParameter = cc_param; } Song* pSong = pEngine->getSong(); if ( lastBpmChangeCCParameter >= cc_param && pSong->__bpm < 300) { pEngine->setBPM( pSong->__bpm - 1*mult ); } if ( lastBpmChangeCCParameter < cc_param && pSong->__bpm > 40 ) { pEngine->setBPM( pSong->__bpm + 1*mult ); } lastBpmChangeCCParameter = cc_param; AudioEngine::get_instance()->unlock(); return true; } if( sActionString == "BPM_FINE_CC_RELATIVE" ){ /* * increments/decrements the BPM * this is useful if the bpm is set by a rotary control knob */ AudioEngine::get_instance()->lock( RIGHT_HERE ); int mult = 1; //second parameter of cc command //this value should be 1 to decrement and something other then 1 to increment the bpm int cc_param = 1; //this Action should be triggered only by CC commands bool ok; mult = pAction->getParameter1().toInt(&ok,10); cc_param = pAction->getParameter2().toInt(&ok,10); if( lastBpmChangeCCParameter == -1) { lastBpmChangeCCParameter = cc_param; } Song* pSong = pEngine->getSong(); if ( lastBpmChangeCCParameter >= cc_param && pSong->__bpm < 300) { pEngine->setBPM( pSong->__bpm - 0.01*mult ); } if ( lastBpmChangeCCParameter < cc_param && pSong->__bpm > 40 ) { pEngine->setBPM( pSong->__bpm + 0.01*mult ); } lastBpmChangeCCParameter = cc_param; AudioEngine::get_instance()->unlock(); return true; } if( sActionString == "BPM_INCR" ){ AudioEngine::get_instance()->lock( RIGHT_HERE ); int mult = 1; bool ok; mult = pAction->getParameter1().toInt(&ok,10); Song* pSong = pEngine->getSong(); if (pSong->__bpm < 300) { pEngine->setBPM( pSong->__bpm + 1*mult ); } AudioEngine::get_instance()->unlock(); return true; } if( sActionString == "BPM_DECR" ){ AudioEngine::get_instance()->lock( RIGHT_HERE ); int mult = 1; bool ok; mult = pAction->getParameter1().toInt(&ok,10); Song* pSong = pEngine->getSong(); if (pSong->__bpm > 40 ) { pEngine->setBPM( pSong->__bpm - 1*mult ); } AudioEngine::get_instance()->unlock(); return true; } if( sActionString == ">>_NEXT_BAR"){ pEngine->setPatternPos(pEngine->getPatternPos() +1 ); pEngine->setTimelineBpm(); return true; } if( sActionString == "<<_PREVIOUS_BAR"){ pEngine->setPatternPos(pEngine->getPatternPos() -1 ); pEngine->setTimelineBpm(); return true; } if( sActionString == "PLAYLIST_SONG"){ bool ok; int songnumber = pAction->getParameter2().toInt(&ok,10); return setSong( songnumber ); } if( sActionString == "PLAYLIST_NEXT_SONG"){ int songnumber = Playlist::get_instance()->getActiveSongNumber(); return setSong( ++songnumber ); } if( sActionString == "PLAYLIST_PREV_SONG"){ int songnumber = Playlist::get_instance()->getActiveSongNumber(); return setSong( --songnumber ); } if( sActionString == "RECORD_READY"){ if ( pEngine->getState() != STATE_PLAYING ) { if (!Preferences::get_instance()->getRecordEvents()) { Preferences::get_instance()->setRecordEvents(true); } else { Preferences::get_instance()->setRecordEvents(false); } } return true; } if( sActionString == "RECORD/STROBE_TOGGLE"){ if (!Preferences::get_instance()->getRecordEvents()) { Preferences::get_instance()->setRecordEvents(true); } else { Preferences::get_instance()->setRecordEvents(false); } return true; } if( sActionString == "RECORD_STROBE"){ if (!Preferences::get_instance()->getRecordEvents()) { Preferences::get_instance()->setRecordEvents(true); } return true; } if( sActionString == "RECORD_EXIT"){ if (Preferences::get_instance()->getRecordEvents()) { Preferences::get_instance()->setRecordEvents(false); } return true; } if( sActionString == "TOGGLE_METRONOME"){ Preferences::get_instance()->m_bUseMetronome = !Preferences::get_instance()->m_bUseMetronome; return true; } if( sActionString == "UNDO_ACTION"){ EventQueue::get_instance()->push_event( EVENT_UNDO_REDO, 0);// 0 = undo return true; } if( sActionString == "REDO_ACTION"){ EventQueue::get_instance()->push_event( EVENT_UNDO_REDO, 1);// 1 = redo return true; } return false; }
void JackAudioDriver::updateTransportInfo() { // The following four lines do only cover the special case of // audioEngine_updateNoteQueue() returning -1 in // audioEngine_process() and triggering an addition relocation // of the transport position to the beginning of the song // using locateInNCycles() to possibly keep synchronization // with Ardour. if ( locate_countdown == 1 ) locate( locate_frame ); if ( locate_countdown > 0 ) locate_countdown--; if ( Preferences::get_instance()->m_bJackTransportMode != Preferences::USE_JACK_TRANSPORT ){ return; } // jack_transport_query() (jack/transport.h) queries the // current transport state and position. If called from the // process thread, the second argument, which is a pointer to // a structure for returning current transport, corresponds to // the first frame of the current cycle and the state returned // is valid for the entire cycle. #m_JackTransportPos->valid // will show which fields contain valid data. If // #m_JackTransportPos is NULL, do not return position // information. m_JackTransportState = jack_transport_query( m_pClient, &m_JackTransportPos ); // WARNINGLOG( QString( "[Jack-Query] state: %1, frame: %2, position bit: %3, bpm: %4" ) // .arg( m_JackTransportState ) // .arg( m_JackTransportPos.frame ) // .arg( m_JackTransportPos.valid ) // .arg( m_JackTransportPos.beats_per_minute ) ); // Update the TransportInfo in m_transport based on the state // returned by jack_transport_query. switch ( m_JackTransportState ) { case JackTransportStopped: // Transport is halted m_transport.m_status = TransportInfo::STOPPED; //INFOLOG( "[updateTransportInfo] STOPPED - frames: " + to_string(m_transportPos.frame) ); break; case JackTransportRolling: // Transport is playing // If the valid member matches the JackPositionBBT // bits, there is a JACK timebase master present // supplying bar, beat, and tick information along // with the plain transport position in frames. We // will use it for re-positioning. But only at the end // of the next cycle, because this timebase master has // to properly initialize its state during this cycle // too. if ( m_transport.m_status != TransportInfo::ROLLING && ( m_JackTransportPos.valid & JackPositionBBT ) ) { must_relocate = 2; //WARNINGLOG( "Jack transport starting: Resyncing in 2 x Buffersize!!" ); } m_transport.m_status = TransportInfo::ROLLING; //INFOLOG( "[updateTransportInfo] ROLLING - frames: " + to_string(m_transportPos.frame) ); break; case JackTransportStarting: // Waiting for sync ready. If // there are slow-sync clients, // this can take more than one // cycle. m_transport.m_status = TransportInfo::STOPPED; //INFOLOG( "[updateTransportInfo] STARTING (stopped) - frames: " + to_string(m_transportPos.frame) ); break; default: ERRORLOG( "Unknown jack transport state" ); } // Updating TickSize and BPM Hydrogen * H = Hydrogen::get_instance(); // JACK may have re-located us anywhere. Therefore, we have to // check for a bpm change every cycle. We will do so by // updating both the global speed of the song, as well as the // fallback speed (H->getNewBpmJTM) with the local tempo at // the current position on the timeline. H->setTimelineBpm(); // Check whether another JACK master is present (the second if // clause won't evaluate to true if Hydrogen itself is the // timebase master) and whether it changed the transport // state. Note that only the JACK timebase master and not // arbitrary clients can do this. If so, the speed is updated // an a relocation according to the bar, beat, and tick // information will be triggered right away. if ( m_JackTransportPos.valid & JackPositionBBT ) { float bpm = ( float )m_JackTransportPos.beats_per_minute; if ( m_transport.m_nBPM != bpm ) { if ( Preferences::get_instance()->m_bJackMasterMode == Preferences::NO_JACK_TIME_MASTER ){ // WARNINGLOG( QString( "Tempo change from jack-transport: %1" ).arg( bpm ) ); m_transport.m_nBPM = bpm; must_relocate = 1; } } } // This clause detects a re-location, which was either // triggered by an user-interaction (e.g. clicking the forward // button or clicking somewhere on the timeline) or by a // different JACK client. if ( m_transport.m_nFrames + bbt_frame_offset != m_JackTransportPos.frame ) { // Whether there is a JACK timebase master registered // but the audio engine was neither (re)started nor a // change in the speed was found beforehand. if ( ( m_JackTransportPos.valid & JackPositionBBT ) && must_relocate == 0 ) { // WARNINGLOG( "Frame offset mismatch; triggering resync in 2 cycles" ); must_relocate = 2; // re-locate at the end of // the next cycle. } else { if ( Preferences::get_instance()->m_bJackMasterMode == Preferences::NO_JACK_TIME_MASTER ) { // Just consider the transport // position as dirty, reassign the // one obtained in the query, and // reset the offset. m_transport.m_nFrames = m_JackTransportPos.frame; bbt_frame_offset = 0; // If not registered as JACK time // master, the following line is // needed to be able to relocate by // clicking the song ruler (wired // corner case, but still...) if ( m_transport.m_status == TransportInfo::ROLLING ) // Setting // H->m_nPatternStartTick = -1 // if in pattern mode. H->triggerRelocateDuringPlay(); } else { // Fallback to the transport position // of the last cycle. m_transport.m_nFrames = H->getHumantimeFrames(); } } } // Only used if Hydrogen is in JACK timebase master // mode. Updated every cycle. if ( H->getHumantimeFrames() != m_JackTransportPos.frame ) { H->setHumantimeFrames(m_JackTransportPos.frame); // WARNINGLOG( QString( "fix Humantime: %1" ).arg( m_JackTransportPos.frame ) ); } // Trigger the re-location based on the information provided // by another JACK timebase master. if ( must_relocate == 1 ) { WARNINGLOG( QString( "Resyncing! bbt_frame_offset: %1" ).arg( bbt_frame_offset ) ); relocateBBT(); if ( m_transport.m_status == TransportInfo::ROLLING ) { // Setting H->m_nPatternStartTick = -1 if in // pattern mode H->triggerRelocateDuringPlay(); } } if ( must_relocate > 0 ) must_relocate--; }