Ergonomic enhancements for AudioFileProcessor plugin (interactive wave view).

This patch includes:
* sampleBuffer::visualise(): add possibility to specified a range to visualize instead of the whole sample
* add sampleBuffer::sampleRate() and sampleBuffer::sampleLength() getters
* definition of AudioFileProcessorWaveView and AudioFileProcessorWaveView::knob classes for AudioFileProcessor plugin
* knob::getValue() specified “virtual” to allow redefinition in child class  AudioFileProcessorWaveView::knob
* delete audioFileKnob class (made obsolete by AudioFileProcessorWaveView::knob)
* add audioFileProcessor::isPlaying() signal, which is emitted in audioFileProcessor::playNote
* change type of AudioFileProcessorView::m_startKnob and AudioFileProcessorView::m_endKnob (AudioFileProcessorWaveView::knob instead of audioFileKnob)
* replace AudioFileProcessorView::m_graph (QPixmap) by AudioFileProcessorView::m_waveView (AudioFileProcessorWaveView)

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
NoiseByNorthwest
2012-02-21 00:32:47 +01:00
committed by Tobias Doerffel
parent ad3af97798
commit d448e6743d
5 changed files with 676 additions and 57 deletions

View File

@@ -699,8 +699,10 @@ f_cnt_t sampleBuffer::getLoopedIndex( f_cnt_t _index ) const
void sampleBuffer::visualize( QPainter & _p, const QRect & _dr,
const QRect & _clip )
const QRect & _clip, f_cnt_t _from_frame, f_cnt_t _to_frame )
{
const bool focus_on_range = _to_frame <= m_frames
&& 0 <= _from_frame && _from_frame < _to_frame;
// _p.setClipRect( _clip );
// _p.setPen( QColor( 0x22, 0xFF, 0x44 ) );
//_p.setPen( QColor( 64, 224, 160 ) );
@@ -709,25 +711,28 @@ void sampleBuffer::visualize( QPainter & _p, const QRect & _dr,
const int yb = h / 2 + _dr.y();
const float y_space = h*0.25f;
const int nb_frames = focus_on_range ? _to_frame - _from_frame : m_frames;
if( m_frames < 60000 )
if( nb_frames < 60000 )
{
_p.setRenderHint( QPainter::Antialiasing );
QColor c = _p.pen().color();
_p.setPen( QPen( c, 0.7 ) );
}
const int fpp = tLimit<int>( m_frames / w, 1, 20 );
QPoint * l = new QPoint[m_frames / fpp + 1];
const int fpp = tLimit<int>( nb_frames / w, 1, 20 );
QPoint * l = new QPoint[nb_frames / fpp + 1];
int n = 0;
const int xb = _dr.x();
for( int frame = 0; frame < m_frames; frame += fpp )
const int first = focus_on_range ? _from_frame : 0;
const int last = focus_on_range ? _to_frame : m_frames;
for( int frame = first; frame < last; frame += fpp )
{
l[n] = QPoint( xb + ( frame * w / m_frames ),
l[n] = QPoint( xb + ( (frame - first) * double( w ) / nb_frames ),
(int)( yb - ( ( m_data[frame][0]+m_data[frame][1] ) *
y_space ) ) );
++n;
}
_p.drawPolyline( l, m_frames / fpp );
_p.drawPolyline( l, nb_frames / fpp );
delete[] l;
}