-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Sampletrack - resize from left #3487
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b9c8f20
resize sampletrack from start (gui)
BaraMGB 92099b2
resize sampletrack from start (sample)
BaraMGB f8ae969
code clean up
BaraMGB 9eb7b72
save/load project with left resized sampletrack works
BaraMGB 25fb7b2
code improvements Part I
BaraMGB d6701d1
fixes <change tempo bug> / some spaces
BaraMGB b8e9248
improve resizing
BaraMGB 0849eec
refactor startTimeOffset(positive values)/change offset on tempochange
BaraMGB 246797a
improve rounding in sampletrack visualizing
BaraMGB 1c30827
change approach again
BaraMGB 2b27365
cleanup the code/consolidate if blocks
BaraMGB 6b8353b
merge master
BaraMGB a6ec9e6
rebase to master
BaraMGB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,7 @@ void SampleTCO::setSampleBuffer( SampleBuffer* sb ) | |
void SampleTCO::setSampleFile( const QString & _sf ) | ||
{ | ||
m_sampleBuffer->setAudioFile( _sf ); | ||
setStartTimeOffset( 0 ); | ||
changeLength( (int) ( m_sampleBuffer->frames() / Engine::framesPerTick() ) ); | ||
|
||
emit sampleChanged(); | ||
|
@@ -183,11 +184,17 @@ void SampleTCO::updateTrackTcos() | |
} | ||
} | ||
|
||
|
||
|
||
|
||
bool SampleTCO::isPlaying() const | ||
{ | ||
return m_isPlaying; | ||
} | ||
|
||
|
||
|
||
|
||
void SampleTCO::setIsPlaying(bool isPlaying) | ||
{ | ||
m_isPlaying = isPlaying; | ||
|
@@ -241,6 +248,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; | ||
|
@@ -265,6 +273,7 @@ void SampleTCO::loadSettings( const QDomElement & _this ) | |
} | ||
changeLength( _this.attribute( "len" ).toInt() ); | ||
setMuted( _this.attribute( "muted" ).toInt() ); | ||
setStartTimeOffset( _this.attribute( "off" ).toInt() ); | ||
} | ||
|
||
|
||
|
@@ -369,6 +378,8 @@ void SampleTCOView::dragEnterEvent( QDragEnterEvent * _dee ) | |
|
||
|
||
|
||
|
||
|
||
void SampleTCOView::dropEvent( QDropEvent * _de ) | ||
{ | ||
if( StringPairDrag::decodeKey( _de ) == "samplefile" ) | ||
|
@@ -501,8 +512,9 @@ void SampleTCOView::paintEvent( QPaintEvent * pe ) | |
float nom = Engine::getSong()->getTimeSigModel().getNumerator(); | ||
float den = Engine::getSong()->getTimeSigModel().getDenominator(); | ||
float ticksPerTact = DefaultTicksPerTact * nom / den; | ||
|
||
QRect r = QRect( TCO_BORDER_WIDTH, spacing, | ||
|
||
float offset = m_tco->startTimeOffset() / ticksPerTact * pixelsPerTact(); | ||
QRect r = QRect( TCO_BORDER_WIDTH + offset, spacing, | ||
qMax( static_cast<int>( m_tco->sampleLength() * ppt / ticksPerTact ), 1 ), rect().bottom() - 2 * spacing ); | ||
m_tco->m_sampleBuffer->visualize( p, r, pe->rect() ); | ||
|
||
|
@@ -605,10 +617,10 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames, | |
float framesPerTick = Engine::framesPerTick(); | ||
if( _start >= sTco->startPosition() && _start < sTco->endPosition() ) | ||
{ | ||
if( sTco->isPlaying() == false ) | ||
if( sTco->isPlaying() == false && _start > sTco->startPosition() + sTco->startTimeOffset() ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() ); | ||
f_cnt_t tcoFrameLength = framesPerTick * ( sTco->endPosition() - sTco->startPosition() ); | ||
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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BaraMGB I guess something went wrong when you sync with
master
branch.See https://github.com/LMMS/lmms/pull/3649/files#diff-cb2a453c979a4777b9330e2b96644f0eR701.