Merge pull request #1941 from curlymorphic/1939

AFP update parameters of wave display when loading sample
This commit is contained in:
Tres Finocchiaro
2015-04-09 02:12:11 +00:00
2 changed files with 14 additions and 8 deletions

View File

@@ -716,7 +716,7 @@ void AudioFileProcessorView::paintEvent( QPaintEvent * )
void AudioFileProcessorView::sampleUpdated( void )
{
newWaveView();
m_waveView->updateSampleRange();
m_waveView->update();
update();
}
@@ -733,7 +733,7 @@ void AudioFileProcessorView::openAudioFile( void )
{
castModel<audioFileProcessor>()->setAudioFile( af );
Engine::getSong()->setModified();
newWaveView();
m_waveView->updateSampleRange();
}
}
@@ -759,6 +759,16 @@ void AudioFileProcessorView::modelChanged( void )
void AudioFileProcessorWaveView::updateSampleRange()
{
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() );
}
updateSampleRange();
m_graph.fill( Qt::transparent );
update();

View File

@@ -261,6 +261,7 @@ public:
void setKnobs(knob *_start, knob *_end, knob *_loop );
void updateSampleRange();
private:
void zoom( const bool _out = false );
void slide( int _px );