Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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: 1 addition & 0 deletions include/FadeButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class FadeButton : public QAbstractButton

public slots:
void activate();
void activateOnce();
void noteEnd();


Expand Down
5 changes: 4 additions & 1 deletion include/InstrumentTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ private slots:
void midiInSelected();
void midiOutSelected();
void midiConfigChanged();
void muteChanged();

void assignFxLine( int channelIndex );
void createFxLine();
Expand All @@ -357,6 +356,10 @@ private slots:

QPoint m_lastPos;

FadeButton * getActivityIndicator()
{
return m_activityIndicator;
}

friend class InstrumentTrackWindow;

Expand Down
22 changes: 22 additions & 0 deletions include/SampleTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <QLayout>

#include "AudioPort.h"
#include "FadeButton.h"
#include "FxMixer.h"
#include "FxLineLcdSpinBox.h"
#include "Track.h"
Expand Down Expand Up @@ -161,6 +162,20 @@ class SampleTrack : public Track
return "sampletrack";
}

bool isPlaying()
{
return m_isPlaying;
}

void setPlaying(bool playing)
{
if (m_isPlaying != playing) { emit playingChanged(); }
m_isPlaying = playing;
}

signals:
void playingChanged();

public slots:
void updateTcos();
void setPlayingTcos( bool isPlaying );
Expand All @@ -171,6 +186,7 @@ public slots:
FloatModel m_panningModel;
IntModel m_effectChannelModel;
AudioPort m_audioPort;
bool m_isPlaying;



Expand Down Expand Up @@ -209,6 +225,7 @@ class SampleTrackView : public TrackView

public slots:
void showEffects();
void updateIndicator();


protected:
Expand All @@ -230,9 +247,14 @@ private slots:
SampleTrackWindow * m_window;
Knob * m_volumeKnob;
Knob * m_panningKnob;
FadeButton * m_activityIndicator;

TrackLabelButton * m_tlb;

FadeButton * getActivityIndicator()
{
return m_activityIndicator;
}

friend class SampleTrackWindow;

Expand Down
6 changes: 6 additions & 0 deletions include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "AutomatableModel.h"
#include "ModelView.h"
#include "DataFile.h"
#include "FadeButton.h"


class QMenu;
Expand Down Expand Up @@ -739,12 +740,17 @@ public slots:

Actions m_action;

virtual FadeButton * getActivityIndicator()
{
return nullptr;
}

friend class TrackLabelButton;


private slots:
void createTCOView( TrackContentObject * tco );
void muteChanged ();

} ;

Expand Down
25 changes: 25 additions & 0 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2719,6 +2719,9 @@ TrackView::TrackView( Track * track, TrackContainerView * tcv ) :
connect( &m_track->m_mutedModel, SIGNAL( dataChanged() ),
&m_trackContentWidget, SLOT( update() ) );

connect(&m_track->m_mutedModel, SIGNAL(dataChanged()),
this, SLOT(muteChanged()));

connect( &m_track->m_soloModel, SIGNAL( dataChanged() ),
m_track, SLOT( toggleSolo() ), Qt::DirectConnection );
// create views for already existing TCOs
Expand Down Expand Up @@ -3051,3 +3054,25 @@ void TrackView::createTCOView( TrackContentObject * tco )
}
tco->selectViewOnCreate( false );
}




void TrackView::muteChanged()
{
FadeButton * actind = getActivityIndicator();
if (actind)
{
if (m_track->m_mutedModel.value())
{
actind->setActiveColor(QApplication::palette().color(
QPalette::Active,
QPalette::Highlight));
} else
{
actind->setActiveColor(QApplication::palette().color(
QPalette::Active,
QPalette::BrightText));
}
}
}
15 changes: 12 additions & 3 deletions src/gui/widgets/FadeButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* FadeButton.cpp - implementation of fade-button
*
* Copyright (c) 2005-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
Expand All @@ -21,7 +21,7 @@
* Boston, MA 02110-1301 USA.
*
*/


#include <QTimer>
#include <QPainter>
Expand Down Expand Up @@ -75,6 +75,14 @@ void FadeButton::activate()



void FadeButton::activateOnce()
{
if (activeNotes == 0) { activate(); }
}




void FadeButton::noteEnd()
{
if (activeNotes <= 0)
Expand All @@ -97,6 +105,7 @@ void FadeButton::noteEnd()




void FadeButton::paintEvent(QPaintEvent * _pe)
{
QColor col = m_normalColor;
Expand Down Expand Up @@ -145,7 +154,7 @@ QColor FadeButton::fadeToColor(QColor startCol, QColor endCol, QTime timer, floa
QColor col;

const float state = 1 - timer.elapsed() / duration;
const int r = (int)(endCol.red() * (1.0f - state)
const int r = (int)(endCol.red() * (1.0f - state)
+ startCol.red() * state);
const int g = (int)(endCol.green() * (1.0f - state)
+ startCol.green() * state);
Expand Down
17 changes: 0 additions & 17 deletions src/tracks/InstrumentTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,6 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV
m_activityIndicator, SLOT( activate() ) );
connect( _it, SIGNAL( endNote() ),
m_activityIndicator, SLOT( noteEnd() ) );
connect( &_it->m_mutedModel, SIGNAL( dataChanged() ), this, SLOT( muteChanged() ) );

setModel( _it );
}
Expand Down Expand Up @@ -1225,22 +1224,6 @@ void InstrumentTrackView::midiConfigChanged()



void InstrumentTrackView::muteChanged()
{
if(model()->m_mutedModel.value() )
{
m_activityIndicator->setActiveColor( QApplication::palette().color( QPalette::Active,
QPalette::Highlight ) );
} else
{
m_activityIndicator->setActiveColor( QApplication::palette().color( QPalette::Active,
QPalette::BrightText ) );
}
}




//FIXME: This is identical to SampleTrackView::createFxMenu
QMenu * InstrumentTrackView::createFxMenu(QString title, QString newFxLabel)
{
Expand Down
34 changes: 33 additions & 1 deletion src/tracks/SampleTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@ SampleTrack::SampleTrack( TrackContainer* tc ) :
m_panningModel( DefaultPanning, PanningLeft, PanningRight, 0.1f,
this, tr( "Panning" ) ),
m_effectChannelModel( 0, 0, 0, this, tr( "FX channel" ) ),
m_audioPort( tr( "Sample track" ), true, &m_volumeModel, &m_panningModel, &m_mutedModel )
m_audioPort( tr( "Sample track" ), true, &m_volumeModel, &m_panningModel, &m_mutedModel ),
m_isPlaying(false)
{
setName( tr( "Sample track" ) );
m_panningModel.setCenterValue( DefaultPanning );
Expand Down Expand Up @@ -622,6 +623,10 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
::BBTrack * bb_track = NULL;
if( _tco_num >= 0 )
{
if (_start > getTCO(_tco_num)->length())
{
setPlaying(false);
}
if( _start != 0 )
{
return false;
Expand All @@ -630,10 +635,12 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
if (trackContainer() == (TrackContainer*)Engine::getBBTrackContainer())
{
bb_track = BBTrack::findBBTrack( _tco_num );
setPlaying(true);
}
}
else
{
bool nowPlaying = false;
for( int i = 0; i < numOfTCOs(); ++i )
{
TrackContentObject * tco = getTCO( i );
Expand All @@ -657,14 +664,17 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
sTco->setSamplePlayLength( samplePlayLength );
tcos.push_back( sTco );
sTco->setIsPlaying( true );
nowPlaying = true;
}
}
}
else
{
sTco->setIsPlaying( false );
}
nowPlaying = nowPlaying || sTco->isPlaying();
}
setPlaying(nowPlaying);
}

for( tcoVector::Iterator it = tcos.begin(); it != tcos.end(); ++it )
Expand Down Expand Up @@ -826,6 +836,19 @@ SampleTrackView::SampleTrackView( SampleTrack * _t, TrackContainerView* tcv ) :
m_panningKnob->setLabel( tr( "PAN" ) );
m_panningKnob->show();

m_activityIndicator = new FadeButton(QApplication::palette().color(QPalette::Active,
QPalette::Background),
QApplication::palette().color(QPalette::Active,
QPalette::BrightText),
QApplication::palette().color(QPalette::Active,
QPalette::BrightText).darker(),
getTrackSettingsWidget());
m_activityIndicator->setGeometry(settingsWidgetWidth-2*24-11, 2, 8, 28);
m_activityIndicator->show();
connect(_t, SIGNAL(playingChanged()), this, SLOT(updateIndicator()));
connect(Engine::getSong(), SIGNAL(stopped()),
this, SLOT(stopPlaying()));

setModel( _t );

m_window = new SampleTrackWindow(this);
Expand All @@ -835,6 +858,15 @@ SampleTrackView::SampleTrackView( SampleTrack * _t, TrackContainerView* tcv ) :



void SampleTrackView::updateIndicator()
{
if (model()->isPlaying()) m_activityIndicator->activateOnce();
else { m_activityIndicator->noteEnd(); }
}




SampleTrackView::~SampleTrackView()
{
if(m_window != NULL)
Expand Down