From 0ecb1e05dfe04fc2416ededcda902667784727e9 Mon Sep 17 00:00:00 2001 From: Wong Cho Ching Date: Fri, 31 Jan 2014 19:15:30 +0800 Subject: [PATCH] temporary fix for audio file processor knobs --- .../audio_file_processor.cpp | 43 ++++++++++++------- .../audio_file_processor.h | 14 +++--- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index c4d8b5a34..fff889493 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -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()->m_sampleBuffer ); m_waveView->move( 2, 172 ); - m_waveView->setKnobs( - dynamic_cast( m_startKnob ), - dynamic_cast( m_endKnob ) - ); - connect( castModel(), 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( m_startKnob ), + dynamic_cast( m_endKnob ) + );*/ + + audioFileProcessor * a = castModel(); + 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" ); @@ -554,8 +566,7 @@ void AudioFileProcessorView::openAudioFile( void ) void AudioFileProcessorView::modelChanged( void ) { audioFileProcessor * a = castModel(); - 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 ) { diff --git a/plugins/audio_file_processor/audio_file_processor.h b/plugins/audio_file_processor/audio_file_processor.h index 1bc81e73f..500b5b7a0 100644 --- a/plugins/audio_file_processor/audio_file_processor.h +++ b/plugins/audio_file_processor/audio_file_processor.h @@ -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: