本文整理汇总了C++中Hydrogen::setTimelineBpm方法的典型用法代码示例。如果您正苦于以下问题:C++ Hydrogen::setTimelineBpm方法的具体用法?C++ Hydrogen::setTimelineBpm怎么用?C++ Hydrogen::setTimelineBpm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hydrogen
的用法示例。
在下文中一共展示了Hydrogen::setTimelineBpm方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateTransportInfo
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();
//.........这里部分代码省略.........
示例2: handleAction
/**
* 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;
}
//.........这里部分代码省略.........
示例3: updateTransportInfo
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
//.........这里部分代码省略.........