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 view in BB editor #3002

Merged
merged 1 commit into from
Sep 4, 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
1 change: 0 additions & 1 deletion include/AutomationPatternView.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class AutomationPatternView : public TrackContentObjectView
public slots:
/// Opens this view's pattern in the global automation editor
void openInAutomationEditor();
virtual void update();


protected slots:
Expand Down
1 change: 1 addition & 0 deletions include/BBEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public slots:
void addSteps();
void cloneSteps();
void removeSteps();
void addSampleTrack();
void addAutomationTrack();

protected slots:
Expand Down
4 changes: 4 additions & 0 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ TrackContentObjectView::~TrackContentObjectView()
*/
void TrackContentObjectView::update()
{
if( fixedTCOs() )
{
updateLength();
}
m_needsUpdate = true;
selectableObject::update();
}
Expand Down
13 changes: 0 additions & 13 deletions src/gui/AutomationPatternView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,6 @@ void AutomationPatternView::openInAutomationEditor()




void AutomationPatternView::update()
{
if( fixedTCOs() )
{
m_pat->changeLength( m_pat->length() );
}
TrackContentObjectView::update();
}




void AutomationPatternView::resetName()
{
m_pat->setName( QString::null );
Expand Down
12 changes: 12 additions & 0 deletions src/gui/editors/BBEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ BBEditor::BBEditor( BBTrackContainer* tc ) :

trackAndStepActionsToolBar->addAction(embed::getIconPixmap("add_bb_track"), tr("Add beat/bassline"),
Engine::getSong(), SLOT(addBBTrack()));
trackAndStepActionsToolBar->addAction(
embed::getIconPixmap("add_sample_track"),
tr("Add sample-track"), m_trackContainerView,
SLOT(addSampleTrack()));
trackAndStepActionsToolBar->addAction(embed::getIconPixmap("add_automation"), tr("Add automation-track"),
m_trackContainerView, SLOT(addAutomationTrack()));

Expand Down Expand Up @@ -210,6 +214,14 @@ void BBTrackContainerView::removeSteps()



void BBTrackContainerView::addSampleTrack()
{
(void) Track::create( Track::SampleTrack, model() );
}




void BBTrackContainerView::addAutomationTrack()
{
(void) Track::create( Track::AutomationTrack, model() );
Expand Down
2 changes: 0 additions & 2 deletions src/tracks/Pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,6 @@ PatternView::~PatternView()

void PatternView::update()
{
m_pat->changeLength( m_pat->length() );

if ( m_pat->m_patternType == Pattern::BeatPattern )
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit problematic. If you create a BBTrack with a pattern that goes beyond step 16 ( see #1105/#2964) and you enter this in a song and extend it to cover more than one bar it will fill with one bar sequences. On saving/reloading the project this will now be a sequence of two bar BBTracks, every second bar being empty.

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not know the relation to this line of code. Anyway, I cannot reproduce this one bar sequence that reloads as two bars. Is there a sample project that shows the sequence?

Copy link
Member

Choose a reason for hiding this comment

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

funkyEnding.mmp.zip

funkyending

funkyendingreloaded

Method to reproduce.

  1. In a new project make a beat with a note at step 16 and hit play.
  2. Right click and open sequence in the Piano Roll. Shift the note one 32nd step to the right.
    It now still plays back as a one bar beat if you play from the BBEditor but if you now stop and play from the Piano Roll it will play back two bars, the second silent.
  3. In the Song Editor, enter a BB track and drag it out. In my case this will make a stretch of one bar BB Tracks.
  4. Save and reload. Now the BB tracks in the Song Editor are two bars.

Copy link
Member Author

Choose a reason for hiding this comment

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

It now still plays back as a one bar beat if you play from the BBEditor

It plays back two bars from the BB editor; it is the error described in #1105. Should I apply #2964?

Copy link
Member

Choose a reason for hiding this comment

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

It plays back two bars from the BB editor; it is the error described in #1105.

Yes, that's the old bug. The new one is that now you don't see it in the BBTrack until you reload the project unless you play it from the Song Editor.

Should I apply #2964?

Not ready yet. But I can poke this one a bit and fix it in 2964? I need to rebase that one and try it with Sample Tracks any way.

Copy link
Member Author

Choose a reason for hiding this comment

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

About the new bug, the pattern length is not being updated. Nevertheless, this m_pat->changeLength( m_pat->length() ); line is not suitable, since it would be a model update from a view update. The fix should update the model from related model changes.

Copy link
Member

Choose a reason for hiding this comment

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

Right. I've poked this a bit and I don't think there is anything I can do to help fixing this particular issue.

{
ToolTip::add( this,
Expand Down
30 changes: 17 additions & 13 deletions src/tracks/SampleTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,14 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )
QLinearGradient lingrad( 0, 0, 0, height() );
QColor c;
bool muted = m_tco->getTrack()->isMuted() || m_tco->isMuted();

// state: selected, muted, normal
c = isSelected() ? selectedColor() : ( muted ? mutedBackgroundColor()
: painter.background().color() );

lingrad.setColorAt( 1, c.darker( 300 ) );
lingrad.setColorAt( 0, c );

if( gradient() )
{
p.fillRect( rect(), lingrad );
Expand All @@ -386,13 +386,17 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )
}

p.setPen( !muted ? painter.pen().brush().color() : mutedColor() );

const int spacing = TCO_BORDER_WIDTH + 1;

const float ppt = fixedTCOs() ?
( parentWidget()->width() - 2 * TCO_BORDER_WIDTH )
/ (float) m_tco->length().getTact() :
pixelsPerTact();

QRect r = QRect( TCO_BORDER_WIDTH, spacing,
qMax( static_cast<int>( m_tco->sampleLength() *
pixelsPerTact() / DefaultTicksPerTact ), 1 ),
rect().bottom() - 2 * spacing );
qMax( static_cast<int>( m_tco->sampleLength() * ppt
/ DefaultTicksPerTact ), 1 ),
rect().bottom() - 2 * spacing );
m_tco->m_sampleBuffer->visualize( p, r, pe->rect() );

// disable antialiasing for borders, since its not needed
Expand All @@ -408,11 +412,11 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )
p.setPen( c.lighter( 160 ) );
p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH,
rect().bottom() - TCO_BORDER_WIDTH );

// outer border
p.setPen( c.darker( 300 ) );
p.drawRect( 0, 0, rect().right(), rect().bottom() );

// draw the 'muted' pixmap only if the pattern was manualy muted
if( m_tco->isMuted() )
{
Expand All @@ -421,9 +425,9 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )
p.drawPixmap( spacing, height() - ( size + spacing ),
embed::getIconPixmap( "muted", size, size ) );
}

// recording sample tracks is not possible at the moment

/* if( m_tco->isRecord() )
{
p.setFont( pointSize<7>( p.font() ) );
Expand All @@ -436,9 +440,9 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )
p.setBrush( QBrush( textColor() ) );
p.drawEllipse( 4, 5, 4, 4 );
}*/

p.end();

painter.drawPixmap( 0, 0, m_paintPixmap );
}

Expand Down