Skip to content
Closed
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: 1 addition & 0 deletions include/FadeButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class FadeButton : public QAbstractButton
public slots:
void activate();
void noteEnd();
void notPlaying();


protected:
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 wasPlaying()
{
return m_wasPlaying;
}

void setWasPlaying(bool wasPlaying)
{
m_wasPlaying = wasPlaying;
}

signals:
void playing();
void notPlaying();

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_wasPlaying;



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

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


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 @@ -737,12 +738,17 @@ public slots:

Actions m_action;

virtual FadeButton * getActivityIndicator()
{
return NULL;
}

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 @@ -2715,6 +2715,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 @@ -3047,3 +3050,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));
}
}
}
10 changes: 10 additions & 0 deletions src/gui/widgets/FadeButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ void FadeButton::noteEnd()



void FadeButton::notPlaying()
{
activeNotes = 0;
m_releaseTimer.restart();
signalUpdate();
}




void FadeButton::customEvent(QEvent *)
{
update();
Expand Down
17 changes: 0 additions & 17 deletions src/tracks/InstrumentTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,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 @@ -1223,22 +1222,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
56 changes: 55 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_wasPlaying(false)
{
setName( tr( "Sample track" ) );
m_panningModel.setCenterValue( DefaultPanning );
Expand All @@ -617,11 +618,17 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
{
m_audioPort.effects()->startRunning();
bool played_a_note = false; // will be return variable
bool is_playing = false;

tcoVector tcos;
::BBTrack * bb_track = NULL;
if( _tco_num >= 0 )
{
if (m_wasPlaying && _start > getTCO(_tco_num)->length())
{
m_wasPlaying = false;
emit notPlaying();
}
if( _start != 0 )
{
return false;
Expand All @@ -630,6 +637,8 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
if (trackContainer() == (TrackContainer*)Engine::getBBTrackContainer())
{
bb_track = BBTrack::findBBTrack( _tco_num );
m_wasPlaying = true;
emit playing();
}
}
else
Expand All @@ -641,6 +650,10 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,

if( _start >= sTco->startPosition() && _start < sTco->endPosition() )
{
if (sTco->isPlaying())
{
is_playing = true;
}
if( sTco->isPlaying() == false && _start > sTco->startPosition() + sTco->startTimeOffset() )
{
auto bufferFramesPerTick = Engine::framesPerTick (sTco->sampleBuffer ()->sampleRate ());
Expand All @@ -657,6 +670,7 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
sTco->setSamplePlayLength( samplePlayLength );
tcos.push_back( sTco );
sTco->setIsPlaying( true );
is_playing = true;
}
}
}
Expand All @@ -665,6 +679,18 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
sTco->setIsPlaying( false );
}
}

if (is_playing && !m_wasPlaying)
{
m_wasPlaying = true;
emit playing();
}
else if (!is_playing && m_wasPlaying)
{
m_wasPlaying = false;
emit notPlaying();
}

}

for( tcoVector::Iterator it = tcos.begin(); it != tcos.end(); ++it )
Expand Down Expand Up @@ -826,6 +852,22 @@ 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(playing()),
m_activityIndicator, SLOT(activate()));
connect(_t, SIGNAL(notPlaying()),
m_activityIndicator, SLOT(notPlaying()));
connect(Engine::getSong(), SIGNAL(stopped()),
this, SLOT(stopPlaying()));

setModel( _t );

m_window = new SampleTrackWindow(this);
Expand Down Expand Up @@ -940,6 +982,18 @@ void SampleTrackView::dropEvent(QDropEvent *de)



void SampleTrackView::stopPlaying()
{
SampleTrack * smpltrck = dynamic_cast<SampleTrack*>(getTrack());
if (smpltrck->wasPlaying())
{
m_activityIndicator->notPlaying();
smpltrck->setWasPlaying(false);
}
}




SampleTrackWindow::SampleTrackWindow(SampleTrackView * tv) :
QWidget(),
Expand Down