Skip to content

Commit

Permalink
attempt to fix #1512
Browse files Browse the repository at this point in the history
grejppi committed Dec 27, 2014

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 1cd8c0e commit bbbe515
Showing 5 changed files with 46 additions and 39 deletions.
11 changes: 7 additions & 4 deletions include/AudioPort.h
Original file line number Diff line number Diff line change
@@ -35,13 +35,15 @@

class EffectChain;
class FloatModel;
class BoolModel;

class AudioPort : public ThreadableJob
{
MM_OPERATORS
public:
AudioPort( const QString & _name, bool _has_effect_chain = true,
FloatModel * volumeModel = NULL, FloatModel * panningModel = NULL );
AudioPort( const QString & _name, bool _has_effect_chain = true,
FloatModel * volumeModel = NULL, FloatModel * panningModel = NULL,
BoolModel * mutedModel = NULL );
virtual ~AudioPort();

inline sampleFrame * buffer()
@@ -117,14 +119,15 @@ class AudioPort : public ThreadableJob
fx_ch_t m_nextFxChannel;

QString m_name;

EffectChain * m_effects;

PlayHandleList m_playHandles;
QMutex m_playHandleLock;

FloatModel * m_volumeModel;
FloatModel * m_panningModel;
BoolModel * m_mutedModel;

friend class Mixer;
friend class MixerWorkerThread;
4 changes: 3 additions & 1 deletion include/Track.h
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ class TrackContentObject : public Model, public JournallingObject
{
return m_length;
}

virtual void movePosition( const MidiTime & _pos );
virtual void changeLength( const MidiTime & _length );

@@ -539,7 +539,9 @@ public slots:
QString m_name;
int m_height;

protected:
BoolModel m_mutedModel;
private:
BoolModel m_soloModel;
bool m_mutedBeforeSolo;

33 changes: 20 additions & 13 deletions src/core/audio/AudioPort.cpp
Original file line number Diff line number Diff line change
@@ -33,16 +33,18 @@
#include "panning.h"


AudioPort::AudioPort( const QString & _name, bool _has_effect_chain,
FloatModel * volumeModel, FloatModel * panningModel ) :
AudioPort::AudioPort( const QString & _name, bool _has_effect_chain,
FloatModel * volumeModel, FloatModel * panningModel,
BoolModel * mutedModel ) :
m_bufferUsage( false ),
m_portBuffer( NULL ),
m_extOutputEnabled( false ),
m_nextFxChannel( 0 ),
m_name( "unnamed port" ),
m_effects( _has_effect_chain ? new EffectChain( NULL ) : NULL ),
m_volumeModel( volumeModel ),
m_panningModel( panningModel )
m_panningModel( panningModel ),
m_mutedModel( mutedModel )
{
Engine::mixer()->addAudioPort( this );
setExtOutputEnabled( true );
@@ -102,6 +104,11 @@ bool AudioPort::processEffects()

void AudioPort::doProcessing()
{
if( m_mutedModel && m_mutedModel->value() )
{
return;
}

const fpp_t fpp = Engine::mixer()->framesPerPeriod();

m_portBuffer = BufferManager::acquire(); // get buffer for processing
@@ -118,11 +125,11 @@ void AudioPort::doProcessing()
m_bufferUsage = true;
MixHelpers::add( m_portBuffer, ph->buffer(), fpp );
}
ph->releaseBuffer(); // gets rid of playhandle's buffer and sets
ph->releaseBuffer(); // gets rid of playhandle's buffer and sets
// pointer to null, so if it doesn't get re-acquired we know to skip it next time
}
}

if( m_bufferUsage )
{
// handle volume and panning
@@ -131,7 +138,7 @@ void AudioPort::doProcessing()
{
ValueBuffer * volBuf = m_volumeModel->valueBuffer();
ValueBuffer * panBuf = m_panningModel->valueBuffer();

// both vol and pan have s.ex.data:
if( volBuf && panBuf )
{
@@ -143,7 +150,7 @@ void AudioPort::doProcessing()
m_portBuffer[f][1] *= ( p >= 0 ? 1.0f : 1.0f + p ) * v;
}
}

// only vol has s.ex.data:
else if( volBuf )
{
@@ -157,7 +164,7 @@ void AudioPort::doProcessing()
m_portBuffer[f][1] *= v * r;
}
}

// only pan has s.ex.data:
else if( panBuf )
{
@@ -169,7 +176,7 @@ void AudioPort::doProcessing()
m_portBuffer[f][1] *= ( p >= 0 ? 1.0f : 1.0f + p ) * v;
}
}

// neither has s.ex.data:
else
{
@@ -182,12 +189,12 @@ void AudioPort::doProcessing()
}
}
}

// has vol model only
else if( m_volumeModel )
{
ValueBuffer * volBuf = m_volumeModel->valueBuffer();

if( volBuf )
{
for( f_cnt_t f = 0; f < fpp; ++f )
@@ -210,7 +217,7 @@ void AudioPort::doProcessing()
}
// as of now there's no situation where we only have panning model but no volume model
// if we have neither, we don't have to do anything here - just pass the audio as is

// handle effects
const bool me = processEffects();
if( me || m_bufferUsage )
@@ -219,7 +226,7 @@ void AudioPort::doProcessing()
// TODO: improve the flow here - convert to pull model
m_bufferUsage = false;
}

BufferManager::release( m_portBuffer ); // release buffer, we don't need it anymore
}

24 changes: 12 additions & 12 deletions src/tracks/InstrumentTrack.cpp
Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@ InstrumentTrack::InstrumentTrack( TrackContainer* tc ) :
tr( "Base note" ) ),
m_volumeModel( DefaultVolume, MinVolume, MaxVolume, 0.1f, this, tr( "Volume" ) ),
m_panningModel( DefaultPanning, PanningLeft, PanningRight, 0.1f, this, tr( "Panning" ) ),
m_audioPort( tr( "unnamed_track" ), true, &m_volumeModel, &m_panningModel ),
m_audioPort( tr( "unnamed_track" ), true, &m_volumeModel, &m_panningModel, &m_mutedModel ),
m_pitchModel( 0, MinPitchDefault, MaxPitchDefault, 1, this, tr( "Pitch" ) ),
m_pitchRangeModel( 1, 1, 24, this, tr( "Pitch range" ) ),
m_effectChannelModel( 0, 0, 0, this, tr( "FX channel" ) ),
@@ -338,7 +338,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti
break;
}
break;

default:
break;
}
@@ -840,7 +840,7 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV
{
widgetWidth = DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT;
}
else
else
{
widgetWidth = DEFAULT_SETTINGS_WIDGET_WIDTH;
}
@@ -949,8 +949,8 @@ InstrumentTrackWindow * InstrumentTrackView::topLevelInstrumentTrackWindow()



// TODO: Add windows to free list on freeInstrumentTrackWindow.
// But, don't NULL m_window or disconnect signals. This will allow windows
// TODO: Add windows to free list on freeInstrumentTrackWindow.
// But, don't NULL m_window or disconnect signals. This will allow windows
// that are being show/hidden frequently to stay connected.
void InstrumentTrackView::freeInstrumentTrackWindow()
{
@@ -975,7 +975,7 @@ void InstrumentTrackView::freeInstrumentTrackWindow()
{
delete m_window;
}

m_window = NULL;
}
}
@@ -1002,7 +1002,7 @@ InstrumentTrackWindow * InstrumentTrackView::getInstrumentTrackWindow()
else if( !s_windowCache.isEmpty() )
{
m_window = s_windowCache.dequeue();

m_window->setInstrumentTrackView( this );
m_window->setModel( model() );
m_window->updateInstrumentView();
@@ -1028,7 +1028,7 @@ InstrumentTrackWindow * InstrumentTrackView::getInstrumentTrackWindow()
s_windowCache << m_window;
}
}

return m_window;
}

@@ -1059,7 +1059,7 @@ void InstrumentTrackView::dropEvent( QDropEvent * _de )
void InstrumentTrackView::toggleInstrumentWindow( bool _on )
{
getInstrumentTrackWindow()->toggleVisibility( _on );

if( !_on )
{
freeInstrumentTrackWindow();
@@ -1119,10 +1119,10 @@ void InstrumentTrackView::midiConfigChanged()



class fxLineLcdSpinBox : public LcdSpinBox
class fxLineLcdSpinBox : public LcdSpinBox
{
public:
fxLineLcdSpinBox( int _num_digits, QWidget * _parent,
fxLineLcdSpinBox( int _num_digits, QWidget * _parent,
const QString & _name ) :
LcdSpinBox( _num_digits, _parent, _name ) {}

@@ -1336,7 +1336,7 @@ void InstrumentTrackWindow::modelChanged()
this, SLOT( updateName() ) );
connect( m_track, SIGNAL( instrumentChanged() ),
this, SLOT( updateInstrumentView() ) );

m_volumeKnob->setModel( &m_track->m_volumeModel );
m_panningKnob->setModel( &m_track->m_panningModel );
m_effectChannelNumber->setModel( &m_track->m_effectChannelModel );
13 changes: 4 additions & 9 deletions src/tracks/SampleTrack.cpp
Original file line number Diff line number Diff line change
@@ -387,11 +387,11 @@ void SampleTCOView::paintEvent( QPaintEvent * _pe )
{
p.setFont( pointSize<7>( p.font() ) );

p.setPen( QColor( 0, 0, 0 ) );
p.setPen( QColor( 0, 0, 0 ) );
p.drawText( 10, p.fontMetrics().height()+1, "Rec" );
p.setPen( textColor() );
p.setPen( textColor() );
p.drawText( 9, p.fontMetrics().height(), "Rec" );

p.setBrush( QBrush( textColor() ) );
p.drawEllipse( 4, 5, 4, 4 );
}
@@ -408,7 +408,7 @@ SampleTrack::SampleTrack( TrackContainer* tc ) :
tr( "Volume" ) ),
m_panningModel( DefaultPanning, PanningLeft, PanningRight, 0.1f,
this, tr( "Panning" ) ),
m_audioPort( tr( "Sample track" ), true, &m_volumeModel, &m_panningModel )
m_audioPort( tr( "Sample track" ), true, &m_volumeModel, &m_panningModel, &m_mutedModel )
{
setName( tr( "Sample track" ) );
m_panningModel.setCenterValue( DefaultPanning );
@@ -610,8 +610,3 @@ void SampleTrackView::modelChanged()

TrackView::modelChanged();
}





0 comments on commit bbbe515

Please sign in to comment.