MCPcopy Create free account
hub / github.com/LMMS/lmms / visualize

Method visualize

src/core/SampleBuffer.cpp:949–984  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

947
948
949void SampleBuffer::visualize( QPainter & _p, const QRect & _dr,
950 const QRect & _clip, f_cnt_t _from_frame, f_cnt_t _to_frame )
951{
952 if( m_frames == 0 ) return;
953
954 const bool focus_on_range = _to_frame <= m_frames
955 && 0 <= _from_frame && _from_frame < _to_frame;
956 //_p.setClipRect( _clip );
957 const int w = _dr.width();
958 const int h = _dr.height();
959
960 const int yb = h / 2 + _dr.y();
961 const float y_space = h*0.5f;
962 const int nb_frames = focus_on_range ? _to_frame - _from_frame : m_frames;
963
964 const int fpp = tLimit<int>( nb_frames / w, 1, 20 );
965 QPointF * l = new QPointF[nb_frames / fpp + 1];
966 QPointF * r = new QPointF[nb_frames / fpp + 1];
967 int n = 0;
968 const int xb = _dr.x();
969 const int first = focus_on_range ? _from_frame : 0;
970 const int last = focus_on_range ? _to_frame : m_frames;
971 for( int frame = first; frame < last; frame += fpp )
972 {
973 l[n] = QPointF( xb + ( (frame - first) * double( w ) / nb_frames ),
974 ( yb - ( m_data[frame][0] * y_space * m_amplification ) ) );
975 r[n] = QPointF( xb + ( (frame - first) * double( w ) / nb_frames ),
976 ( yb - ( m_data[frame][1] * y_space * m_amplification ) ) );
977 ++n;
978 }
979 _p.setRenderHint( QPainter::Antialiasing );
980 _p.drawPolyline( l, nb_frames / fpp );
981 _p.drawPolyline( r, nb_frames / fpp );
982 delete[] l;
983 delete[] r;
984}
985
986
987

Callers 2

paintEventMethod · 0.80
updateGraphMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected