@@ -230,29 +230,31 @@ RectF SamplePlayer::getHorizontalRect(int octaveIndex, int noteIndex, bool isWhi
230
230
return RectF (noteLeftX, m_area.y , noteWidth, m_area.h * (isWhiteKey ? 1 . : 2 . / 3 .));
231
231
}
232
232
233
- void SamplePlayer::drawVertical2 (const PianoRoll& pianoroll, const MidiData& midiData ) const
233
+ void SamplePlayer::drawVertical (const PianoRoll& pianoroll, const Optional< MidiData>& midiDataOpt ) const
234
234
{
235
235
const int octaveMin = m_octaveMin + 1 ;
236
236
// const int octaveMax = m_octaveMax + 1;
237
237
238
238
// const double currentTick = pianoroll.currentTick();
239
239
const double currentSeconds = pianoroll.currentSeconds ();
240
240
241
- const auto & tracks = midiData.notes ();
242
-
243
241
HashTable<int , std::pair<double , int >> pressedKeyTick;
244
- for ( const auto & [i, track] : Indexed (tracks) )
242
+ if (midiDataOpt )
245
243
{
246
- if (i == 10 )
244
+ const auto & tracks = midiDataOpt.value ().notes ();
245
+ for (const auto & [i, track] : Indexed (tracks))
247
246
{
248
- continue ;
249
- }
247
+ if (i == 10 )
248
+ {
249
+ continue ;
250
+ }
250
251
251
- for (const auto & note : track.notes ())
252
- {
253
- if (note.beginSec <= currentSeconds && currentSeconds < note.endSec )
252
+ for (const auto & note : track.notes ())
254
253
{
255
- pressedKeyTick[note.key ] = std::make_pair (currentSeconds - note.beginSec , static_cast <int >(i));
254
+ if (note.beginSec <= currentSeconds && currentSeconds < note.endSec )
255
+ {
256
+ pressedKeyTick[note.key ] = std::make_pair (currentSeconds - note.beginSec , static_cast <int >(i));
257
+ }
256
258
}
257
259
}
258
260
}
@@ -329,29 +331,31 @@ void SamplePlayer::drawVertical2(const PianoRoll& pianoroll, const MidiData& mid
329
331
}
330
332
}
331
333
332
- void SamplePlayer::drawHorizontal (const PianoRoll& pianoroll, const MidiData& midiData ) const
334
+ void SamplePlayer::drawHorizontal (const PianoRoll& pianoroll, const Optional< MidiData>& midiDataOpt ) const
333
335
{
334
336
const int octaveMin = m_octaveMin + 1 ;
335
337
// const int octaveMax = m_octaveMax + 1;
336
338
337
339
// const double currentTick = pianoroll.currentTick();
338
340
const double currentSeconds = pianoroll.currentSeconds ();
339
341
340
- const auto & tracks = midiData.notes ();
341
-
342
342
HashTable<int , std::pair<double , int >> pressedKeyTick;
343
- for ( const auto & [i, track] : Indexed (tracks) )
343
+ if (midiDataOpt )
344
344
{
345
- if (i == 10 )
345
+ const auto & tracks = midiDataOpt.value ().notes ();
346
+ for (const auto & [i, track] : Indexed (tracks))
346
347
{
347
- continue ;
348
- }
348
+ if (i == 10 )
349
+ {
350
+ continue ;
351
+ }
349
352
350
- for (const auto & note : track.notes ())
351
- {
352
- if (note.beginSec <= currentSeconds && currentSeconds < note.endSec )
353
+ for (const auto & note : track.notes ())
353
354
{
354
- pressedKeyTick[note.key ] = std::make_pair (currentSeconds - note.beginSec , static_cast <int >(i));
355
+ if (note.beginSec <= currentSeconds && currentSeconds < note.endSec )
356
+ {
357
+ pressedKeyTick[note.key ] = std::make_pair (currentSeconds - note.beginSec , static_cast <int >(i));
358
+ }
355
359
}
356
360
}
357
361
}
0 commit comments