void SampleTrack::setPlayingTcos( bool isPlaying ) { for( int i = 0; i < numOfTCOs(); ++i ) { TrackContentObject * tco = getTCO( i ); SampleTCO * sTco = dynamic_cast<SampleTCO*>( tco ); sTco->setIsPlaying( isPlaying ); } }
void SampleTrack::updateTcos() { for( int i = 0; i < numOfTCOs(); ++i ) { TrackContentObject * tco = getTCO( i ); SampleTCO * sTco = dynamic_cast<SampleTCO*>( tco ); sTco->playbackPositionChanged(); } }
bool sampleTrack::play( const midiTime & _start, const fpp_t _frames, const f_cnt_t _offset, Sint16 /*_tco_num*/ ) { m_audioPort.effects()->startRunning(); bool played_a_note = false; // will be return variable for( int i = 0; i < numOfTCOs(); ++i ) { trackContentObject * tco = getTCO( i ); if( tco->startPosition() != _start ) { continue; } sampleTCO * st = dynamic_cast<sampleTCO *>( tco ); if( !st->isMuted() ) { playHandle * handle; if( st->isRecord() ) { if( !engine::getSong()->isRecording() ) { return played_a_note; } sampleRecordHandle * smpHandle = new sampleRecordHandle( st ); handle = smpHandle; } else { samplePlayHandle * smpHandle = new samplePlayHandle( st ); smpHandle->setVolumeModel( &m_volumeModel ); handle = smpHandle; } //TODO: check whether this works // handle->setBBTrack( _tco_num ); handle->setOffset( _offset ); // send it to the mixer engine::getMixer()->addPlayHandle( handle ); played_a_note = true; } } return played_a_note; }
void InstrumentTrack::setName( const QString & _new_name ) { // when changing name of track, also change name of those patterns, // which have the same name as the instrument-track for( int i = 0; i < numOfTCOs(); ++i ) { pattern * p = dynamic_cast<pattern *>( getTCO( i ) ); if( ( p != NULL && p->name() == name() ) || p->name() == "" ) { p->setName( _new_name ); } } track::setName( _new_name ); m_midiPort.setName( name() ); m_audioPort.setName( name() ); emit nameChanged(); }
bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames, const f_cnt_t _offset, int _tco_num ) { m_audioPort.effects()->startRunning(); bool played_a_note = false; // will be return variable tcoVector tcos; ::BBTrack * bb_track = NULL; if( _tco_num >= 0 ) { if( _start != 0 ) { return false; } tcos.push_back( getTCO( _tco_num ) ); if (trackContainer() == (TrackContainer*)Engine::getBBTrackContainer()) { bb_track = BBTrack::findBBTrack( _tco_num ); } } else { for( int i = 0; i < numOfTCOs(); ++i ) { TrackContentObject * tco = getTCO( i ); SampleTCO * sTco = dynamic_cast<SampleTCO*>( tco ); float framesPerTick = Engine::framesPerTick(); if( _start >= sTco->startPosition() && _start < sTco->endPosition() ) { if( sTco->isPlaying() == false && _start > sTco->startPosition() + sTco->startTimeOffset() ) { f_cnt_t sampleStart = framesPerTick * ( _start - sTco->startPosition() - sTco->startTimeOffset() ); f_cnt_t tcoFrameLength = framesPerTick * ( sTco->endPosition() - sTco->startPosition() - sTco->startTimeOffset() ); f_cnt_t sampleBufferLength = sTco->sampleBuffer()->frames(); //if the Tco smaller than the sample length we play only until Tco end //else we play the sample to the end but nothing more f_cnt_t samplePlayLength = tcoFrameLength > sampleBufferLength ? sampleBufferLength : tcoFrameLength; //we only play within the sampleBuffer limits if( sampleStart < sampleBufferLength ) { sTco->setSampleStartFrame( sampleStart ); sTco->setSamplePlayLength( samplePlayLength ); tcos.push_back( sTco ); sTco->setIsPlaying( true ); } } } else { sTco->setIsPlaying( false ); } } } for( tcoVector::Iterator it = tcos.begin(); it != tcos.end(); ++it ) { SampleTCO * st = dynamic_cast<SampleTCO *>( *it ); if( !st->isMuted() ) { PlayHandle* handle; if( st->isRecord() ) { if( !Engine::getSong()->isRecording() ) { return played_a_note; } SampleRecordHandle* smpHandle = new SampleRecordHandle( st ); handle = smpHandle; } else { SamplePlayHandle* smpHandle = new SamplePlayHandle( st ); smpHandle->setVolumeModel( &m_volumeModel ); smpHandle->setBBTrack( bb_track ); handle = smpHandle; } handle->setOffset( _offset ); // send it to the mixer Engine::mixer()->addPlayHandle( handle ); played_a_note = true; } } return played_a_note; }