Merge pull request #213 from wongcc966422/issue174

[not ready]Temporary fix for audio file processor knobs
This commit is contained in:
Tobias Doerffel
2014-01-31 04:08:27 -08:00
2 changed files with 34 additions and 23 deletions

View File

@@ -72,8 +72,8 @@ audioFileProcessor::audioFileProcessor( InstrumentTrack * _instrument_track ) :
Instrument( _instrument_track, &audiofileprocessor_plugin_descriptor ),
m_sampleBuffer(),
m_ampModel( 100, 0, 500, 1, this, tr( "Amplify" ) ),
m_startPointModel( 0, 0, 1, 0.0000001f, this, tr( "Start of sample") ),
m_endPointModel( 1, 0, 1, 0.0000001f, this, tr( "End of sample" ) ),
m_startPointModel( 0, 0, 1, 0.001f, this, tr( "Start of sample") ),
m_endPointModel( 1, 0, 1, 0.001f, this, tr( "End of sample" ) ),
m_reverseModel( false, this, tr( "Reverse sample" ) ),
m_loopModel( false, this, tr( "Loop") ),
m_stutterModel( false, this, tr( "Stutter" ) ),
@@ -393,7 +393,7 @@ AudioFileProcessorView::AudioFileProcessorView( Instrument * _instrument,
"Otherwise it will be amplified up or down (your "
"actual sample-file isn't touched!)" ) );
m_startKnob = new AudioFileProcessorWaveView::knob( this );
m_startKnob = new AudioFileProcessorWaveView::afpKnob( this );
m_startKnob->move( 68, 108 );
m_startKnob->setHintText( tr( "Startpoint:" )+" ", "" );
m_startKnob->setWhatsThis(
@@ -403,7 +403,7 @@ AudioFileProcessorView::AudioFileProcessorView( Instrument * _instrument,
"which AudioFileProcessor returns if a note is longer "
"than the sample between the start and end-points." ) );
m_endKnob = new AudioFileProcessorWaveView::knob( this );
m_endKnob = new AudioFileProcessorWaveView::afpKnob( this );
m_endKnob->move( 119, 108 );
m_endKnob->setHintText( tr( "Endpoint:" )+" ", "" );
m_endKnob->setWhatsThis(
@@ -415,13 +415,25 @@ AudioFileProcessorView::AudioFileProcessorView( Instrument * _instrument,
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 )
);
connect( castModel<audioFileProcessor>(), SIGNAL( isPlaying( f_cnt_t ) ),
/* TODO: fix setKnobs()
* This line was used to enable user to change the value of knobs with
* m_waveView, by using the mouse to resize/move the place of the audio
* file to be played. However, it have been broken for a while(not working
* even in 0.4.15 ). Even worse, this feature causes is bugged that it
* prevent user from changing the value of START and END from the knobs.
* Therefore, I temporarily disable this function.
*/
/*m_waveView->setKnobs(
dynamic_cast<AudioFileProcessorWaveView::afpKnob *>( m_startKnob ),
dynamic_cast<AudioFileProcessorWaveView::afpKnob *>( m_endKnob )
);*/
audioFileProcessor * a = castModel<audioFileProcessor>();
connect( a, SIGNAL( isPlaying( f_cnt_t ) ),
m_waveView, SLOT( isPlaying( f_cnt_t ) ) );
connect( &a->m_sampleBuffer, SIGNAL( sampleUpdated() ),
this, SLOT( sampleUpdated() ) );
qRegisterMetaType<f_cnt_t>( "f_cnt_t" );
@@ -554,8 +566,7 @@ void AudioFileProcessorView::openAudioFile( void )
void AudioFileProcessorView::modelChanged( void )
{
audioFileProcessor * a = castModel<audioFileProcessor>();
connect( &a->m_sampleBuffer, SIGNAL( sampleUpdated() ),
this, SLOT( sampleUpdated() ) );
m_ampKnob->setModel( &a->m_ampModel );
m_startKnob->setModel( &a->m_startPointModel );
m_endKnob->setModel( &a->m_endPointModel );
@@ -936,7 +947,7 @@ void AudioFileProcessorWaveView::slide( int _px )
void AudioFileProcessorWaveView::setKnobs( knob * _start, knob * _end )
void AudioFileProcessorWaveView::setKnobs( afpKnob * _start, afpKnob * _end )
{
m_startKnob = _start;
m_endKnob = _end;
@@ -964,7 +975,7 @@ void AudioFileProcessorWaveView::slideSamplePointByPx( knobType _point, int _px
void AudioFileProcessorWaveView::slideSamplePointByFrames( knobType _point, f_cnt_t _frames, bool _slide_to )
{
knob * knob = _point == start ? m_startKnob : m_endKnob;
afpKnob * knob = _point == start ? m_startKnob : m_endKnob;
if( ! knob )
{
return;
@@ -1020,7 +1031,7 @@ void AudioFileProcessorWaveView::reverse()
void AudioFileProcessorWaveView::knob::slideTo( double _v, bool _check_bound )
void AudioFileProcessorWaveView::afpKnob::slideTo( double _v, bool _check_bound )
{
if( _check_bound && ! checkBound( _v ) )
{
@@ -1033,7 +1044,7 @@ void AudioFileProcessorWaveView::knob::slideTo( double _v, bool _check_bound )
float AudioFileProcessorWaveView::knob::getValue( const QPoint & _p )
float AudioFileProcessorWaveView::afpKnob::getValue( const QPoint & _p )
{
const double dec_fact = ! m_waveView ? 1 :
double( m_waveView->m_to - m_waveView->m_from )
@@ -1051,7 +1062,7 @@ float AudioFileProcessorWaveView::knob::getValue( const QPoint & _p )
bool AudioFileProcessorWaveView::knob::checkBound( double _v ) const
bool AudioFileProcessorWaveView::afpKnob::checkBound( double _v ) const
{
if( ! m_relatedKnob || ! m_waveView )
{

View File

@@ -161,14 +161,14 @@ public:
end,
} ;
class knob : public ::knob
class afpKnob : public ::knob
{
const AudioFileProcessorWaveView * m_waveView;
const knob * m_relatedKnob;
const afpKnob * m_relatedKnob;
public:
knob( QWidget * _parent ) :
afpKnob( QWidget * _parent ) :
::knob( knobStyled, _parent ),
m_waveView( 0 ),
m_relatedKnob( 0 )
@@ -181,7 +181,7 @@ public:
m_waveView = _wv;
}
void setRelatedKnob( const knob * _knob )
void setRelatedKnob( const afpKnob * _knob )
{
m_relatedKnob = _knob;
}
@@ -230,8 +230,8 @@ private:
f_cnt_t m_to;
f_cnt_t m_last_from;
f_cnt_t m_last_to;
knob * m_startKnob;
knob * m_endKnob;
afpKnob * m_startKnob;
afpKnob * m_endKnob;
f_cnt_t m_startFrameX;
f_cnt_t m_endFrameX;
bool m_isDragging;
@@ -243,7 +243,7 @@ private:
public:
AudioFileProcessorWaveView( QWidget * _parent, int _w, int _h, SampleBuffer& buf );
void setKnobs( knob * _start, knob * _end );
void setKnobs( afpKnob * _start, afpKnob * _end );
private: