diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index be7519179..f402c513e 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -716,7 +716,7 @@ void AudioFileProcessorView::paintEvent( QPaintEvent * ) void AudioFileProcessorView::sampleUpdated( void ) { - newWaveView(); + m_waveView->updateFromTo(); m_waveView->update(); update(); } @@ -733,7 +733,7 @@ void AudioFileProcessorView::openAudioFile( void ) { castModel()->setAudioFile( af ); Engine::getSong()->setModified(); - newWaveView(); + m_waveView->updateFromTo(); } } @@ -759,6 +759,16 @@ void AudioFileProcessorView::modelChanged( void ) +void AudioFileProcessorWaveView::updateFromTo() +{ + if( m_sampleBuffer.frames() > 1 ) + { + const f_cnt_t marging = ( m_sampleBuffer.endFrame() - m_sampleBuffer.startFrame() ) * 0.1; + m_from = qMax( 0, m_sampleBuffer.startFrame() - marging ); + m_to = qMin( m_sampleBuffer.endFrame() + marging, m_sampleBuffer.frames() ); + } +} + AudioFileProcessorWaveView::AudioFileProcessorWaveView( QWidget * _parent, int _w, int _h, SampleBuffer& buf ) : QWidget( _parent ), m_sampleBuffer( buf ), @@ -779,12 +789,7 @@ AudioFileProcessorWaveView::AudioFileProcessorWaveView( QWidget * _parent, int _ setFixedSize( _w, _h ); setMouseTracking( true ); - if( m_sampleBuffer.frames() > 1 ) - { - const f_cnt_t marging = ( m_sampleBuffer.endFrame() - m_sampleBuffer.startFrame() ) * 0.1; - m_from = qMax( 0, m_sampleBuffer.startFrame() - marging ); - m_to = qMin( m_sampleBuffer.endFrame() + marging, m_sampleBuffer.frames() ); - } + updateFromTo(); m_graph.fill( Qt::transparent ); update(); diff --git a/plugins/audio_file_processor/audio_file_processor.h b/plugins/audio_file_processor/audio_file_processor.h index 2e7a2b3a5..428917fb3 100644 --- a/plugins/audio_file_processor/audio_file_processor.h +++ b/plugins/audio_file_processor/audio_file_processor.h @@ -261,6 +261,7 @@ public: void setKnobs(knob *_start, knob *_end, knob *_loop ); + void updateFromTo(); private: void zoom( const bool _out = false ); void slide( int _px );