8 #ifndef __VRV_MIDIFUNCTOR_H__
9 #define __VRV_MIDIFUNCTOR_H__
15 #include "alignfunctor.h"
23 class FeatureExtractor;
52 FunctorCode VisitChordEnd(
Chord *chord)
override;
53 FunctorCode VisitLayer(
Layer *layer)
override;
54 FunctorCode VisitLayerElement(
LayerElement *layerElement)
override;
55 FunctorCode VisitMeasure(
Measure *measure)
override;
56 FunctorCode VisitStaff(
Staff *staff)
override;
57 FunctorCode VisitTabGrpEnd(
TabGrp *tabGrp)
override;
70 double m_currentRealTimeSeconds;
74 data_NOTATIONTYPE m_notationType;
76 double m_currentTempo;
105 void SetCurrentTempo(
double tempo) { m_currentTempo = tempo; }
106 void SetTempoAdjustment(
double adjustment) { m_tempoAdjustment = adjustment; }
113 FunctorCode VisitLayerElement(LayerElement *layerElement)
override;
114 FunctorCode VisitMeasure(Measure *measure)
override;
115 FunctorCode VisitMeasureEnd(Measure *measure)
override;
116 FunctorCode VisitScoreDef(ScoreDef *scoreDef)
override;
117 FunctorCode VisitTempo(Tempo *tempo)
override;
124 double GetAdjustedTempo()
const {
return m_currentTempo * m_tempoAdjustment; }
130 Fraction m_currentScoreTime;
132 double m_currentRealTimeSeconds;
134 double m_currentTempo;
136 double m_tempoAdjustment;
138 int m_multiRestFactor;
167 FunctorCode VisitTie(
Tie *tie)
override;
205 void SetNoCue(
bool noCue) { m_noCue = noCue; }
212 FunctorCode VisitArpeg(Arpeg *arpeg)
override;
213 FunctorCode VisitChord(Chord *chord)
override;
214 FunctorCode VisitGraceGrpEnd(GraceGrp *graceGrp)
override;
215 FunctorCode VisitMeasure(Measure *measure)
override;
216 FunctorCode VisitNote(Note *note)
override;
226 std::list<Note *> notes;
227 data_DURATION duration;
234 void SetGraceNotesFor(Note *refNote);
239 void SetNoteStartStop(Note *note,
const Fraction &startTime,
const Fraction &stopTime);
240 void SetNoteStart(Note *note,
const Fraction &startTime);
248 std::list<Grace> m_graces;
250 bool m_accentedGraceNote;
252 double m_currentTempo;
296 void SetCurrentTempo(
double tempo) { m_currentTempo = tempo; }
297 const std::list<OctaveInfo> &GetOctaves()
const {
return m_octaves; }
304 FunctorCode VisitMeasure(
const Measure *measure)
override;
305 FunctorCode VisitOctave(
const Octave *octave)
override;
316 double m_currentTempo;
318 std::list<OctaveInfo> m_octaves;
333 using MIDINoteSequence = std::list<MIDINote>;
340 double m_stopTime = 0;
365 std::set<int> GetTempoEventTicks()
const {
return m_tempoEventTicks; }
372 void SetChannel(
int channel) { m_midiChannel = channel; }
373 void SetControlEvents(
bool controlEvents) { m_controlEvents = controlEvents; }
374 void SetNoCue(
bool noCue) { m_noCue = noCue; }
375 void SetCurrentTempo(
double tempo) { m_currentTempo = tempo; }
376 void SetDeferredNotes(
const std::map<const Note *, double> &deferredNotes) { m_deferredNotes = deferredNotes; }
377 void SetLayerN(
int layerN) { m_layerN = layerN; }
378 void SetOctaves(
const std::list<OctaveInfo> &octaves) { m_octaves = octaves; }
379 void SetStaffN(
int staffN) { m_staffN = staffN; }
380 void SetTempoEventTicks(
const std::set<int> &ticks) { m_tempoEventTicks = ticks; }
381 void SetTrack(
int track) { m_midiTrack = track; }
382 void SetTransSemi(
int transSemi) { m_transSemi = transSemi; }
389 FunctorCode VisitBeatRpt(
const BeatRpt *beatRpt)
override;
390 FunctorCode VisitBTrem(
const BTrem *bTrem)
override;
391 FunctorCode VisitChord(
const Chord *chord)
override;
392 FunctorCode VisitFTrem(
const FTrem *fTrem)
override;
393 FunctorCode VisitHalfmRpt(
const HalfmRpt *halfmRpt)
override;
394 FunctorCode VisitLayer(
const Layer *layer)
override;
395 FunctorCode VisitLayerEnd(
const Layer *layer)
override;
396 FunctorCode VisitLayerElement(
const LayerElement *layerElement)
override;
397 FunctorCode VisitMeasure(
const Measure *measure)
override;
398 FunctorCode VisitMRpt(
const MRpt *mRpt)
override;
399 FunctorCode VisitNote(
const Note *note)
override;
400 FunctorCode VisitPedal(
const Pedal *pedal)
override;
401 FunctorCode VisitScoreDef(
const ScoreDef *scoreDef)
override;
402 FunctorCode VisitStaff(
const Staff *staff)
override;
403 FunctorCode VisitStaffDef(
const StaffDef *staffDef)
override;
404 FunctorCode VisitSyl(
const Syl *syl)
override;
405 FunctorCode VisitVerse(
const Verse *verse)
override;
414 void DeferMIDINote(
const Note *refNote,
double shift,
bool includeChordSiblings);
419 void HandleOctave(
const LayerElement *layerElement);
424 int GetMIDIPitch(
const Note *note) {
return note->GetMIDIPitch(m_transSemi, m_octaveShift); }
430 smf::MidiFile *m_midiFile;
446 double m_currentTempo;
449 std::set<int> m_tempoEventTicks;
451 const Note *m_lastNote;
453 std::map<const Note *, MIDINoteSequence> m_expandedNotes;
455 std::map<const Note *, double> m_deferredNotes;
457 std::list<OctaveInfo> m_octaves;
461 std::vector<MIDIHeldNote> m_heldNotes;
463 bool m_controlEvents;
491 void SetNoCue(
bool noCue) { m_noCue = noCue; }
497 FunctorCode VisitLayerElement(
const LayerElement *layerElement)
override;
498 FunctorCode VisitMeasure(
const Measure *measure)
override;
499 FunctorCode VisitNote(
const Note *note)
override;
500 FunctorCode VisitRest(
const Rest *rest)
override;
509 void AddTimemapEntry(
const Object *
object);
515 Fraction m_scoreTimeOffset;
517 double m_realTimeOffsetMilliseconds;
519 double m_currentTempo;
552 FunctorCode VisitObject(
const Object *
object)
override;
568 #endif // __VRV_MIDIFUNCTOR_H__