Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sample track playback in BB tracks #3023

Merged
merged 1 commit into from
Sep 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/tracks/BBTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,9 @@ BBTrack::BBTrack( TrackContainer* tc ) :
BBTrack::~BBTrack()
{
Engine::mixer()->removePlayHandlesOfTypes( this,
PlayHandle::TypeNotePlayHandle
| PlayHandle::TypeInstrumentPlayHandle );
PlayHandle::TypeNotePlayHandle
| PlayHandle::TypeInstrumentPlayHandle
| PlayHandle::TypeSamplePlayHandle );

const int bb = s_infoMap[this];
Engine::getBBTrackContainer()->removeBB( bb );
Expand Down
34 changes: 26 additions & 8 deletions src/tracks/SampleTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "Engine.h"
#include "ToolTip.h"
#include "AudioPort.h"
#include "BBTrack.h"
#include "SamplePlayHandle.h"
#include "SampleRecordHandle.h"
#include "StringPairDrag.h"
Expand Down Expand Up @@ -475,19 +476,37 @@ SampleTrack::~SampleTrack()


bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
const f_cnt_t _offset, int /*_tco_num*/ )
const f_cnt_t _offset, int _tco_num )
{
m_audioPort.effects()->startRunning();
bool played_a_note = false; // will be return variable

for( int i = 0; i < numOfTCOs(); ++i )
tcoVector tcos;
::BBTrack * bb_track = NULL;
if( _tco_num >= 0 )
{
TrackContentObject * tco = getTCO( i );
if( tco->startPosition() != _start )
if( _start != 0 )
{
continue;
return false;
}
SampleTCO * st = dynamic_cast<SampleTCO *>( tco );
tcos.push_back( getTCO( _tco_num ) );
bb_track = BBTrack::findBBTrack( _tco_num );
}
else
{
for( int i = 0; i < numOfTCOs(); ++i )
{
TrackContentObject * tco = getTCO( i );
if( tco->startPosition() == _start )
{
tcos.push_back( tco );
}
}
}

for( tcoVector::Iterator it = tcos.begin(); it != tcos.end(); ++it )
{
SampleTCO * st = dynamic_cast<SampleTCO *>( *it );
if( !st->isMuted() )
{
PlayHandle* handle;
Expand All @@ -504,10 +523,9 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
{
SamplePlayHandle* smpHandle = new SamplePlayHandle( st );
smpHandle->setVolumeModel( &m_volumeModel );
smpHandle->setBBTrack( bb_track );
handle = smpHandle;
}
//TODO: check whether this works
// handle->setBBTrack( _tco_num );
handle->setOffset( _offset );
// send it to the mixer
Engine::mixer()->addPlayHandle( handle );
Expand Down