Merge commit 'b5538c7da818cbcdde5ff1c885ce4eee5b626f3b' into ed_refac

Conflicts:
	plugins/audio_file_processor/audio_file_processor.cpp
	plugins/delay/delaycontrols.cpp
	plugins/delay/delaycontrolsdialog.cpp
	plugins/delay/delayeffect.cpp
	src/gui/MainWindow.cpp
This commit is contained in:
Lukas W
2015-01-06 16:33:41 +01:00
13 changed files with 256 additions and 225 deletions

View File

@@ -577,13 +577,8 @@ AudioFileProcessorView::AudioFileProcessorView( Instrument * _instrument,
m_interpBox->setFont( pointSize<8>( m_interpBox->font() ) );
// wavegraph
m_waveView = new AudioFileProcessorWaveView( this, 245, 75, castModel<audioFileProcessor>()->m_sampleBuffer );
m_waveView->move( 2, 172 );
m_waveView->setKnobs(
dynamic_cast<AudioFileProcessorWaveView::knob *>( m_startKnob ),
dynamic_cast<AudioFileProcessorWaveView::knob *>( m_endKnob ),
dynamic_cast<AudioFileProcessorWaveView::knob *>( m_loopKnob )
);
m_waveView = 0;
newWaveView();
connect( castModel<audioFileProcessor>(), SIGNAL( isPlaying( f_cnt_t ) ),
m_waveView, SLOT( isPlaying( f_cnt_t ) ) );
@@ -632,6 +627,25 @@ void AudioFileProcessorView::dragEnterEvent( QDragEnterEvent * _dee )
void AudioFileProcessorView::newWaveView()
{
if ( m_waveView )
{
delete m_waveView;
m_waveView = 0;
}
m_waveView = new AudioFileProcessorWaveView( this, 245, 75, castModel<audioFileProcessor>()->m_sampleBuffer );
m_waveView->move( 2, 172 );
m_waveView->setKnobs(
dynamic_cast<AudioFileProcessorWaveView::knob *>( m_startKnob ),
dynamic_cast<AudioFileProcessorWaveView::knob *>( m_endKnob ),
dynamic_cast<AudioFileProcessorWaveView::knob *>( m_loopKnob ) );
m_waveView->show();
}
void AudioFileProcessorView::dropEvent( QDropEvent * _de )
{
QString type = StringPairDrag::decodeKey( _de );
@@ -640,6 +654,7 @@ void AudioFileProcessorView::dropEvent( QDropEvent * _de )
{
castModel<audioFileProcessor>()->setAudioFile( value );
_de->accept();
newWaveView();
return;
}
else if( type == QString( "tco_%1" ).arg( Track::SampleTrack ) )
@@ -693,6 +708,7 @@ void AudioFileProcessorView::paintEvent( QPaintEvent * )
void AudioFileProcessorView::sampleUpdated( void )
{
newWaveView();
m_waveView->update();
update();
}
@@ -709,6 +725,7 @@ void AudioFileProcessorView::openAudioFile( void )
{
castModel<audioFileProcessor>()->setAudioFile( af );
Engine::getSong()->setModified();
newWaveView();
}
}

View File

@@ -118,7 +118,7 @@ public:
AudioFileProcessorView( Instrument * _instrument, QWidget * _parent );
virtual ~AudioFileProcessorView();
void newWaveView();
protected slots:
void sampleUpdated();
void openAudioFile();

View File

@@ -30,14 +30,14 @@
#include "Song.h"
DelayControls::DelayControls( DelayEffect* effect ):
EffectControls( effect ),
m_effect ( effect ),
m_delayTimeModel( 0.5, 0.01, 20.0, 0.0001, 20000.0, this, tr( "Delay Samples" )) ,
m_feedbackModel(0.0f,0.0f,1.0f,0.01f,this,tr( "Feedback" ) ),
m_lfoTimeModel(2.0, 0.01, 20.0, 0.0001, 20000.0, this, tr( "Lfo Frequency" ) ),
m_lfoAmountModel(0.0, 0.0, 2.0, 0.0001, 2000.0, this, tr ( "Lfo Amount" ) )
EffectControls( effect ),
m_effect ( effect ),
m_delayTimeModel( 0.5, 0.01, 20.0, 0.0001, 20000.0, this, tr( "Delay Samples" )) ,
m_feedbackModel(0.0f,0.0f,1.0f,0.01f,this,tr( "Feedback" ) ),
m_lfoTimeModel(2.0, 0.01, 20.0, 0.0001, 20000.0, this, tr( "Lfo Frequency" ) ),
m_lfoAmountModel(0.0, 0.0, 2.0, 0.0001, 2000.0, this, tr ( "Lfo Amount" ) )
{
connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changeSampleRate() ) );
connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changeSampleRate() ) );
}
@@ -45,10 +45,10 @@ DelayControls::DelayControls( DelayEffect* effect ):
void DelayControls::loadSettings( const QDomElement &_this )
{
m_delayTimeModel.loadSettings(_this, "DelayTimeSamples" );
m_feedbackModel.loadSettings( _this, "FeebackAmount" );
m_lfoTimeModel.loadSettings( _this , "LfoFrequency");
m_lfoAmountModel.loadSettings( _this, "LfoAmount");
m_delayTimeModel.loadSettings(_this, "DelayTimeSamples" );
m_feedbackModel.loadSettings( _this, "FeebackAmount" );
m_lfoTimeModel.loadSettings( _this , "LfoFrequency");
m_lfoAmountModel.loadSettings( _this, "LfoAmount");
}
@@ -56,15 +56,15 @@ void DelayControls::loadSettings( const QDomElement &_this )
void DelayControls::saveSettings( QDomDocument& doc, QDomElement& _this )
{
m_delayTimeModel.saveSettings( doc, _this, "DelayTimeSamples" );
m_feedbackModel.saveSettings( doc, _this ,"FeebackAmount" );
m_lfoTimeModel.saveSettings( doc, _this, "LfoFrequency" );
m_lfoAmountModel.saveSettings( doc, _this ,"LfoAmount" );
m_delayTimeModel.saveSettings( doc, _this, "DelayTimeSamples" );
m_feedbackModel.saveSettings( doc, _this ,"FeebackAmount" );
m_lfoTimeModel.saveSettings( doc, _this, "LfoFrequency" );
m_lfoAmountModel.saveSettings( doc, _this ,"LfoAmount" );
}
void DelayControls::changeSampleRate()
{
m_effect->changeSampleRate();
m_effect->changeSampleRate();
}

View File

@@ -35,38 +35,38 @@ class DelayEffect;
class DelayControls : public EffectControls
{
Q_OBJECT
Q_OBJECT
public:
DelayControls( DelayEffect* effect );
virtual ~DelayControls()
{
}
virtual void saveSettings( QDomDocument& doc, QDomElement& parent );
virtual void loadSettings( const QDomElement& _this );
inline virtual QString nodeName() const
{
return "Delay";
}
virtual int controlCount(){
return 4;
}
virtual EffectControlDialog* createView()
{
return new DelayControlsDialog( this );
}
DelayControls( DelayEffect* effect );
virtual ~DelayControls()
{
}
virtual void saveSettings( QDomDocument& doc, QDomElement& parent );
virtual void loadSettings( const QDomElement& _this );
inline virtual QString nodeName() const
{
return "Delay";
}
virtual int controlCount(){
return 4;
}
virtual EffectControlDialog* createView()
{
return new DelayControlsDialog( this );
}
private slots:
void changeSampleRate();
void changeSampleRate();
private:
DelayEffect* m_effect;
TempoSyncKnobModel m_delayTimeModel;
FloatModel m_feedbackModel;
TempoSyncKnobModel m_lfoTimeModel;
TempoSyncKnobModel m_lfoAmountModel;
DelayEffect* m_effect;
TempoSyncKnobModel m_delayTimeModel;
FloatModel m_feedbackModel;
TempoSyncKnobModel m_lfoTimeModel;
TempoSyncKnobModel m_lfoAmountModel;
friend class DelayControlsDialog;
friend class DelayEffect;
friend class DelayControlsDialog;
friend class DelayEffect;
};
#endif // DELAYCONTROLS_H

View File

@@ -39,33 +39,36 @@ DelayControlsDialog::DelayControlsDialog( DelayControls *controls ) :
setPalette( pal );
setFixedSize( 200, 75 );
TempoSyncKnob* sampleDelayKnob = new TempoSyncKnob( knobBright_26, this );
sampleDelayKnob->move( 20,10 );
sampleDelayKnob->setVolumeKnob( false );
sampleDelayKnob->setModel( &controls->m_delayTimeModel );
sampleDelayKnob->setLabel( tr( "Delay" ) );
sampleDelayKnob->setHintText( tr( "Delay Time" ) + " ", " s" );
TempoSyncKnob* sampleDelayKnob = new TempoSyncKnob( knobBright_26, this );
sampleDelayKnob->move( 20,10 );
sampleDelayKnob->setVolumeKnob( false );
sampleDelayKnob->setModel( &controls->m_delayTimeModel );
sampleDelayKnob->setLabel( tr( "Delay" ) );
sampleDelayKnob->setHintText( tr( "Delay Time" ) + " ", " s" );
Knob * feedbackKnob = new Knob( knobBright_26, this );
feedbackKnob->move( 63,10 );
feedbackKnob->setVolumeKnob( true) ;
feedbackKnob->setModel( &controls->m_feedbackModel);
feedbackKnob->setLabel( tr( "Regen" ) );
feedbackKnob->setHintText( tr ( "Feedback Amount" ) + " " , "" );
Knob * feedbackKnob = new Knob( knobBright_26, this );
feedbackKnob->move( 63,10 );
feedbackKnob->setVolumeKnob( true) ;
feedbackKnob->setModel( &controls->m_feedbackModel);
feedbackKnob->setLabel( tr( "Regen" ) );
feedbackKnob->setHintText( tr ( "Feedback Amount" ) + " " , "" );
TempoSyncKnob * lfoFreqKnob = new TempoSyncKnob( knobBright_26, this );
lfoFreqKnob->move( 106,10 );
lfoFreqKnob->setVolumeKnob( false );
lfoFreqKnob->setModel( &controls->m_lfoTimeModel );
lfoFreqKnob->setLabel( tr( "Rate" ) );
lfoFreqKnob->setHintText( tr ( "Lfo") + " ", " s" );
TempoSyncKnob * lfoFreqKnob = new TempoSyncKnob( knobBright_26, this );
lfoFreqKnob->move( 106,10 );
lfoFreqKnob->setVolumeKnob( false );
lfoFreqKnob->setModel( &controls->m_lfoTimeModel );
lfoFreqKnob->setLabel( tr( "Rate" ) );
lfoFreqKnob->setHintText( tr ( "Lfo") + " ", " s" );
TempoSyncKnob * lfoAmtKnob = new TempoSyncKnob( knobBright_26, this );
lfoAmtKnob->move( 150,10 );
lfoAmtKnob->setVolumeKnob( false );
lfoAmtKnob->setModel( &controls->m_lfoAmountModel );
lfoAmtKnob->setLabel( tr( "Lfo" ) );
lfoAmtKnob->setHintText( tr ( "Lfo Amt" ) + " " , " s" );
TempoSyncKnob * lfoAmtKnob = new TempoSyncKnob( knobBright_26, this );
lfoAmtKnob->move( 150,10 );
lfoAmtKnob->setVolumeKnob( false );
lfoAmtKnob->setModel( &controls->m_lfoAmountModel );
lfoAmtKnob->setLabel( tr( "Lfo" ) );
lfoAmtKnob->setHintText( tr ( "Lfo Amt" ) + " " , " s" );
}
#include "moc_delaycontrols.cxx"

View File

@@ -32,10 +32,10 @@ class DelayControls;
class DelayControlsDialog : public EffectControlDialog
{
public:
DelayControlsDialog( DelayControls* controls );
virtual ~DelayControlsDialog()
{
}
DelayControlsDialog( DelayControls* controls );
virtual ~DelayControlsDialog()
{
}
};
#endif // DELAYCONTROLSDIALOG_H

View File

@@ -32,27 +32,27 @@ extern "C"
Plugin::Descriptor PLUGIN_EXPORT delay_plugin_descriptor =
{
STRINGIFY( PLUGIN_NAME ),
"Delay",
QT_TRANSLATE_NOOP( "pluginBrowser", "A native delay plugin" ),
"Dave French <contact/dot/dave/dot/french3/at/googlemail/dot/com>",
0x0100,
Plugin::Effect,
new PluginPixmapLoader( "logo" ),
NULL,
NULL
STRINGIFY( PLUGIN_NAME ),
"Delay",
QT_TRANSLATE_NOOP( "pluginBrowser", "A native delay plugin" ),
"Dave French <contact/dot/dave/dot/french3/at/googlemail/dot/com>",
0x0100,
Plugin::Effect,
new PluginPixmapLoader( "logo" ),
NULL,
NULL
} ;
DelayEffect::DelayEffect( Model* parent, const Plugin::Descriptor::SubPluginFeatures::Key* key ) :
Effect( &delay_plugin_descriptor, parent, key ),
m_delayControls( this )
Effect( &delay_plugin_descriptor, parent, key ),
m_delayControls( this )
{
m_delay = 0;
m_delay = new StereoDelay( 20, Engine::mixer()->processingSampleRate() );
m_lfo = new Lfo( Engine::mixer()->processingSampleRate() );
m_delay = 0;
m_delay = new StereoDelay( 20, Engine::mixer()->processingSampleRate() );
m_lfo = new Lfo( Engine::mixer()->processingSampleRate() );
}
@@ -60,14 +60,14 @@ DelayEffect::DelayEffect( Model* parent, const Plugin::Descriptor::SubPluginFeat
DelayEffect::~DelayEffect()
{
if( m_delay )
{
delete m_delay;
}
if( m_lfo )
{
delete m_lfo;
}
if( m_delay )
{
delete m_delay;
}
if( m_lfo )
{
delete m_lfo;
}
}
@@ -75,37 +75,37 @@ DelayEffect::~DelayEffect()
bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
{
if( !isEnabled() || !isRunning () )
{
return( false );
}
double outSum = 0.0;
const float d = dryLevel();
const float w = wetLevel();
const float length = m_delayControls.m_delayTimeModel.value() * Engine::mixer()->processingSampleRate();
const float amplitude = m_delayControls.m_lfoAmountModel.value() * Engine::mixer()->processingSampleRate();
m_lfo->setFrequency( 1.0 / m_delayControls.m_lfoTimeModel.value() );
m_delay->setFeedback( m_delayControls.m_feedbackModel.value() );
sample_t dryS[2];
for( fpp_t f = 0; f < frames; ++f )
{
dryS[0] = buf[f][0];
dryS[1] = buf[f][1];
m_delay->setLength( ( float )length + ( amplitude * ( float )m_lfo->tick() ) );
m_delay->tick( buf[f] );
if( !isEnabled() || !isRunning () )
{
return( false );
}
double outSum = 0.0;
const float d = dryLevel();
const float w = wetLevel();
const float length = m_delayControls.m_delayTimeModel.value() * Engine::mixer()->processingSampleRate();
const float amplitude = m_delayControls.m_lfoAmountModel.value() * Engine::mixer()->processingSampleRate();
m_lfo->setFrequency( 1.0 / m_delayControls.m_lfoTimeModel.value() );
m_delay->setFeedback( m_delayControls.m_feedbackModel.value() );
sample_t dryS[2];
for( fpp_t f = 0; f < frames; ++f )
{
dryS[0] = buf[f][0];
dryS[1] = buf[f][1];
m_delay->setLength( ( float )length + ( amplitude * ( float )m_lfo->tick() ) );
m_delay->tick( buf[f] );
buf[f][0] = ( d * dryS[0] ) + ( w * buf[f][0] );
buf[f][1] = ( d * dryS[1] ) + ( w * buf[f][1] );
outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1];
}
checkGate( outSum / frames );
return isRunning();
buf[f][0] = ( d * dryS[0] ) + ( w * buf[f][0] );
buf[f][1] = ( d * dryS[1] ) + ( w * buf[f][1] );
outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1];
}
checkGate( outSum / frames );
return isRunning();
}
void DelayEffect::changeSampleRate()
{
m_lfo->setSampleRate( Engine::mixer()->processingSampleRate() );
m_delay->setSampleRate( Engine::mixer()->processingSampleRate() );
m_lfo->setSampleRate( Engine::mixer()->processingSampleRate() );
m_delay->setSampleRate( Engine::mixer()->processingSampleRate() );
}
@@ -117,7 +117,7 @@ extern "C"
//needed for getting plugin out of shared lib
Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data )
{
return new DelayEffect( parent , static_cast<const Plugin::Descriptor::SubPluginFeatures::Key *>( data ) );
return new DelayEffect( parent , static_cast<const Plugin::Descriptor::SubPluginFeatures::Key *>( data ) );
}
}}

View File

@@ -33,19 +33,19 @@
class DelayEffect : public Effect
{
public:
DelayEffect(Model* parent , const Descriptor::SubPluginFeatures::Key* key );
virtual ~DelayEffect();
virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames );
virtual EffectControls* controls()
{
return &m_delayControls;
}
void changeSampleRate();
DelayEffect(Model* parent , const Descriptor::SubPluginFeatures::Key* key );
virtual ~DelayEffect();
virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames );
virtual EffectControls* controls()
{
return &m_delayControls;
}
void changeSampleRate();
private:
DelayControls m_delayControls;
StereoDelay* m_delay;
Lfo* m_lfo;
DelayControls m_delayControls;
StereoDelay* m_delay;
Lfo* m_lfo;
};
#endif // DELAYEFFECT_H

View File

@@ -30,8 +30,8 @@
Lfo::Lfo( int samplerate )
{
m_samplerate = samplerate;
m_twoPiOverSr = F_2PI / samplerate;
m_samplerate = samplerate;
m_twoPiOverSr = F_2PI / samplerate;
}
@@ -39,8 +39,8 @@ Lfo::Lfo( int samplerate )
float Lfo::tick()
{
float output = sinf( m_phase );
m_phase += m_increment;
float output = sinf( m_phase );
m_phase += m_increment;
return output;
return output;
}

View File

@@ -30,50 +30,50 @@
class Lfo
{
public:
Lfo( int samplerate );
~Lfo()
{
}
Lfo( int samplerate );
~Lfo()
{
}
inline void setFrequency( double frequency )
{
if( frequency < 0 || frequency > ( m_samplerate / 2.0 ) || frequency == m_frequency )
{
return;
}
m_frequency = frequency;
m_increment = m_frequency * m_twoPiOverSr;
inline void setFrequency( double frequency )
{
if( frequency < 0 || frequency > ( m_samplerate / 2.0 ) || frequency == m_frequency )
{
return;
}
m_frequency = frequency;
m_increment = m_frequency * m_twoPiOverSr;
if( m_phase >= F_2PI )
{
m_phase -= F_2PI;
}
}
if( m_phase >= F_2PI )
{
m_phase -= F_2PI;
}
}
inline void setSampleRate ( int samplerate )
{
m_samplerate = samplerate;
m_twoPiOverSr = F_2PI / samplerate;
m_increment = m_frequency * m_twoPiOverSr;
}
inline void setSampleRate ( int samplerate )
{
m_samplerate = samplerate;
m_twoPiOverSr = F_2PI / samplerate;
m_increment = m_frequency * m_twoPiOverSr;
}
float tick();
float tick();
private:
double m_frequency;
double m_phase;
double m_increment;
double m_twoPiOverSr;
int m_samplerate;
double m_frequency;
double m_phase;
double m_increment;
double m_twoPiOverSr;
int m_samplerate;
};
#endif // LFO_H

View File

@@ -31,14 +31,14 @@
StereoDelay::StereoDelay( int maxTime, int sampleRate )
{
m_buffer = 0;
m_maxTime = maxTime;
m_maxLength = maxTime * sampleRate;
m_length = m_maxLength;
m_buffer = 0;
m_maxTime = maxTime;
m_maxLength = maxTime * sampleRate;
m_length = m_maxLength;
m_index = 0;
m_feedback = 0.0f;
setSampleRate( sampleRate );
m_index = 0;
m_feedback = 0.0f;
setSampleRate( sampleRate );
}
@@ -46,10 +46,10 @@ StereoDelay::StereoDelay( int maxTime, int sampleRate )
StereoDelay::~StereoDelay()
{
if( m_buffer )
{
delete m_buffer;
}
if( m_buffer )
{
delete m_buffer;
}
}
@@ -57,24 +57,24 @@ StereoDelay::~StereoDelay()
void StereoDelay::tick( sampleFrame frame )
{
m_buffer[m_index][0] = frame[0];
m_buffer[m_index][1] = frame[1];
m_buffer[m_index][0] = frame[0];
m_buffer[m_index][1] = frame[1];
int readIndex = m_index - ( int )m_length;
if( readIndex < 0 )
{
readIndex += m_maxLength;
}
float fract = fraction( m_length );
frame[0] = linearInterpolate( m_buffer[readIndex][0] ,
m_buffer[( readIndex+1) % m_maxLength][0], fract );
frame[1] = linearInterpolate( m_buffer[readIndex][1] ,
m_buffer[( readIndex+1) % m_maxLength][1], fract );
int readIndex = m_index - ( int )m_length - 1;
if( readIndex < 0 )
{
readIndex += m_maxLength;
}
float fract = 1.0f - fraction( m_length );
frame[0] = linearInterpolate( m_buffer[readIndex][0] ,
m_buffer[( readIndex+1) % m_maxLength][0], fract );
frame[1] = linearInterpolate( m_buffer[readIndex][1] ,
m_buffer[( readIndex+1) % m_maxLength][1], fract );
m_buffer[m_index][0] += frame[0] * m_feedback;
m_buffer[m_index][1] += frame[1] * m_feedback;
m_buffer[m_index][0] += frame[0] * m_feedback;
m_buffer[m_index][1] += frame[1] * m_feedback;
m_index = ( m_index + 1) % m_maxLength;
m_index = ( m_index + 1) % m_maxLength;
}
@@ -82,13 +82,18 @@ void StereoDelay::tick( sampleFrame frame )
void StereoDelay::setSampleRate( int sampleRate )
{
if( m_buffer )
{
delete m_buffer;
}
if( m_buffer )
{
delete m_buffer;
}
m_buffer = new sampleFrame[( int )( sampleRate * m_maxTime )];
int bufferSize = ( int )( sampleRate * m_maxTime );
m_buffer = new sampleFrame[bufferSize];
for( int i = 0 ; i < bufferSize ; i++)
{
m_buffer[i][0] = 0.0;
m_buffer[i][1] = 0.0;
}
}

View File

@@ -30,31 +30,31 @@
class StereoDelay
{
public:
StereoDelay( int maxLength, int sampleRate );
~StereoDelay();
inline void setLength( float length )
{
if( length <= m_maxLength && length >= 0 )
{
m_length = length;
}
}
StereoDelay( int maxLength, int sampleRate );
~StereoDelay();
inline void setLength( float length )
{
if( length <= m_maxLength && length >= 0 )
{
m_length = length;
}
}
inline void setFeedback( float feedback )
{
m_feedback = feedback;
}
inline void setFeedback( float feedback )
{
m_feedback = feedback;
}
void tick( sampleFrame frame );
void setSampleRate( int sampleRate );
void tick( sampleFrame frame );
void setSampleRate( int sampleRate );
private:
sampleFrame* m_buffer;
int m_maxLength;
float m_length;
int m_index;
float m_feedback;
float m_maxTime;
sampleFrame* m_buffer;
int m_maxLength;
float m_length;
int m_index;
float m_feedback;
float m_maxTime;
};
#endif // STEREODELAY_H

View File

@@ -552,6 +552,12 @@ void MainWindow::finalize()
Engine::pianoRoll()->parentWidget()->hide();
Engine::songEditor()->parentWidget()->move(5, 5);
Engine::songEditor()->parentWidget()->show();
// reset window title every time we change the state of a subwindow to show the correct title
foreach( QMdiSubWindow * subWindow, workspace()->subWindowList() )
{
connect( subWindow, SIGNAL( windowStateChanged(Qt::WindowStates,Qt::WindowStates) ), this, SLOT( resetWindowTitle() ) );
}
}