Sampletrack activity indicator

This commit is contained in:
Andres
2019-11-05 08:17:25 -03:00
parent 8a52ddb642
commit 4d9e5e36a6
4 changed files with 61 additions and 1 deletions

View File

@@ -47,6 +47,7 @@ public:
public slots:
void activate();
void noteEnd();
void notPlaying();
protected:

View File

@@ -29,6 +29,7 @@
#include <QLayout>
#include "AudioPort.h"
#include "FadeButton.h"
#include "FxMixer.h"
#include "FxLineLcdSpinBox.h"
#include "Track.h"
@@ -161,6 +162,10 @@ public:
return "sampletrack";
}
signals:
void playing();
void notPlaying();
public slots:
void updateTcos();
void setPlayingTcos( bool isPlaying );
@@ -171,6 +176,7 @@ private:
FloatModel m_panningModel;
IntModel m_effectChannelModel;
AudioPort m_audioPort;
bool m_wasPlaying;
@@ -230,6 +236,7 @@ private:
SampleTrackWindow * m_window;
Knob * m_volumeKnob;
Knob * m_panningKnob;
FadeButton * m_activityIndicator;
TrackLabelButton * m_tlb;

View File

@@ -100,6 +100,16 @@ void FadeButton::noteEnd()
void FadeButton::notPlaying()
{
activeNotes = 0;
m_releaseTimer.restart();
signalUpdate();
}
void FadeButton::customEvent(QEvent *)
{
update();

View File

@@ -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 );
@@ -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;
@@ -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
@@ -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 ());
@@ -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;
}
}
}
@@ -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 )
@@ -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()),
m_activityIndicator, SLOT(notPlaying()));
setModel( _t );
m_window = new SampleTrackWindow(this);