MCPcopy Create free account
hub / github.com/LMMS/lmms / play

Method play

src/tracks/SampleTrack.cpp:603–690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601
602
603bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
604 const f_cnt_t _offset, int _tco_num )
605{
606 m_audioPort.effects()->startRunning();
607 bool played_a_note = false; // will be return variable
608
609 tcoVector tcos;
610 ::BBTrack * bb_track = NULL;
611 if( _tco_num >= 0 )
612 {
613 if( _start != 0 )
614 {
615 return false;
616 }
617 tcos.push_back( getTCO( _tco_num ) );
618 if (trackContainer() == (TrackContainer*)Engine::getBBTrackContainer())
619 {
620 bb_track = BBTrack::findBBTrack( _tco_num );
621 }
622 }
623 else
624 {
625 for( int i = 0; i < numOfTCOs(); ++i )
626 {
627 TrackContentObject * tco = getTCO( i );
628 SampleTCO * sTco = dynamic_cast<SampleTCO*>( tco );
629
630 if( _start >= sTco->startPosition() && _start < sTco->endPosition() )
631 {
632 if( sTco->isPlaying() == false )
633 {
634 auto bufferFramesPerTick = Engine::framesPerTick (sTco->sampleBuffer ()->sampleRate ());
635 f_cnt_t sampleStart = bufferFramesPerTick * ( _start - sTco->startPosition() );
636
637 f_cnt_t tcoFrameLength = bufferFramesPerTick * ( sTco->endPosition() - sTco->startPosition() );
638
639 f_cnt_t sampleBufferLength = sTco->sampleBuffer()->frames();
640 //if the Tco smaller than the sample length we play only until Tco end
641 //else we play the sample to the end but nothing more
642 f_cnt_t samplePlayLength = tcoFrameLength > sampleBufferLength ? sampleBufferLength : tcoFrameLength;
643 //we only play within the sampleBuffer limits
644 if( sampleStart < sampleBufferLength )
645 {
646 sTco->setSampleStartFrame( sampleStart );
647 sTco->setSamplePlayLength( samplePlayLength );
648 tcos.push_back( sTco );
649 sTco->setIsPlaying( true );
650 }
651 }
652 }
653 else
654 {
655 sTco->setIsPlaying( false );
656 }
657 }
658 }
659
660 for( tcoVector::Iterator it = tcos.begin(); it != tcos.end(); ++it )

Callers

nothing calls this directly

Calls 15

trackContainerFunction · 0.85
getBBTrackContainerFunction · 0.85
framesPerTickFunction · 0.85
getSongFunction · 0.85
mixerFunction · 0.85
startRunningMethod · 0.80
effectsMethod · 0.80
sampleBufferMethod · 0.80
framesMethod · 0.80
setSampleStartFrameMethod · 0.80
setSamplePlayLengthMethod · 0.80
setIsPlayingMethod · 0.80

Tested by

no test coverage detected