96 QColor defaultColor = pPref->
getColorTheme()->m_songEditor_backgroundColor;
99 qreal pixelRatio = devicePixelRatio();
108 int currentWidth = width();
110 if( pLayer ==
nullptr || currentWidth <= 0 ){
130 if ( pLayer && pLayer->get_sample() ) {
136 auto pSampleData = pLayer->get_sample()->get_data_l();
138 float fLengthOfPlaybackTrackInSecs = ( float )( nSampleLength / (
float)
m_pLayer->
get_sample()->get_sample_rate() );
139 float fRemainingLengthOfPlaybackTrack = fLengthOfPlaybackTrackInSecs;
140 float fGain = height() / 2.0 * pLayer->get_gain();
144 std::vector<PatternList*> *pPatternColumns = pSong->getPatternGroupVector();
145 int nColumns = pPatternColumns->size();
147 int nSongEditorGridWith;
152 nSongEditorGridWith = 16;
155 int nRenderStartPosition = 0.8 * nSongEditorGridWith;
157 for (
int patternPosition = 0; patternPosition < nMaxBars; ++patternPosition ) {
158 int maxPatternSize = 0;
160 if( patternPosition < nColumns ) {
161 PatternList *pColumn = ( *pPatternColumns )[ patternPosition ];
163 for (
unsigned j = 0; j < pColumn->
size(); j++ ) {
167 if(maxPatternSize < nPatternSize) {
168 maxPatternSize = nPatternSize;
174 if( maxPatternSize == 0 ) {
175 maxPatternSize = 192;
179 float fLengthOfCurrentPatternInSecs = (maxPatternSize/24) / ((pSong->getBpm() * 2) / 60);
181 if( fRemainingLengthOfPlaybackTrack >= fLengthOfCurrentPatternInSecs ) {
183 float nScaleFactor = fLengthOfCurrentPatternInSecs / fLengthOfPlaybackTrackInSecs;
184 int nSamplesToRender = nScaleFactor * nSampleLength;
188 for (
int i = nRenderStartPosition; i < nRenderStartPosition + nSongEditorGridWith ; ++i ) {
192 int nSamplesToRenderInThisStep = (nSamplesToRender / nSongEditorGridWith);
193 for (
int j = 0; j < nSamplesToRenderInThisStep; ++j ) {
194 if ( nSamplePos < nSampleLength ) {
195 int newVal = (int)( pSampleData[ nSamplePos ] * fGain );
196 if ( newVal > nVal ) {
208 nRenderStartPosition += nSongEditorGridWith;
209 fRemainingLengthOfPlaybackTrack -= fLengthOfCurrentPatternInSecs;
236 QPainter painter(
this );
238 qreal pixelRatio = devicePixelRatio();
247 QRectF( pixelRatio * ev->rect().x(),
248 pixelRatio * ev->rect().y(),
249 pixelRatio * ev->rect().width(),
250 pixelRatio * ev->rect().height() ) );
254 if (
m_fTick != -1 && pSongEditorPanel !=
nullptr ) {
255 if ( pSongEditorPanel->getSongEditor() !=
nullptr ) {
258 static_cast<float>(pSongEditorPanel->getSongEditor()->
263 painter.drawLine( nX + nOffset, 0, nX + nOffset, height() );