Skip to content
Prev Previous commit
Next Next commit
save/load project with left resized sampletrack works
  • Loading branch information
BaraMGB committed Apr 7, 2017
commit 9eb7b7294cc5b5d76c2d540b27b97949cb08db80
4 changes: 2 additions & 2 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#include "SongEditor.h"
#include "StringPairDrag.h"
#include "TextFloat.h"
#include <QDebug>


/*! The width of the resize grip in pixels
*/
Expand Down Expand Up @@ -1029,7 +1029,7 @@ void TrackContentObjectView::mouseReleaseEvent( QMouseEvent * me )
setSelected( !isSelected() );
}

if( m_action == Move || m_action == Resize )
if( m_action == Move || m_action == Resize || m_action == ResizeLeft )
{
m_tco->setJournalling( true );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add this?

// TODO: Fix m_tco->setJournalling() consistency

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
Expand Down
9 changes: 5 additions & 4 deletions src/tracks/SampleTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#include "Mixer.h"
#include "EffectRackView.h"
#include "TrackLabelButton.h"
#include <QDebug>

SampleTCO::SampleTCO( Track * _track ) :
TrackContentObject( _track ),
m_sampleBuffer( new SampleBuffer ),
Expand Down Expand Up @@ -148,6 +148,7 @@ void SampleTCO::setSampleBuffer( SampleBuffer* sb )
void SampleTCO::setSampleFile( const QString & _sf )
{
m_sampleBuffer->setAudioFile( _sf );
setStartTimeOffset( 0 );
updateLength();

emit sampleChanged();
Expand Down Expand Up @@ -253,6 +254,7 @@ void SampleTCO::saveSettings( QDomDocument & _doc, QDomElement & _this )
_this.setAttribute( "len", length() );
_this.setAttribute( "muted", isMuted() );
_this.setAttribute( "src", sampleFile() );
_this.setAttribute( "off", startTimeOffset() );
if( sampleFile() == "" )
{
QString s;
Expand All @@ -277,6 +279,7 @@ void SampleTCO::loadSettings( const QDomElement & _this )
}
changeLength( _this.attribute( "len" ).toInt() );
setMuted( _this.attribute( "muted" ).toInt() );
setStartTimeOffset( _this.attribute( "off" ).toInt() );
}


Expand Down Expand Up @@ -325,7 +328,6 @@ SampleTCOView::~SampleTCOView()

void SampleTCOView::updateSample()
{
m_tco->setStartTimeOffset( 0 );
update();
// set tooltip to filename so that user can see what sample this
// sample-tco contains
Expand Down Expand Up @@ -625,12 +627,11 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
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() )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should refactor the offset information because playing is more important than GUI events.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain, what is in your mind? @jasp00

{
f_cnt_t sampleStart = framesPerTick * ( (_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
Expand Down