MuseScore  3.4
Music composition and notation
importmidi_tuplet.h
Go to the documentation of this file.
1 #ifndef IMPORTMIDI_TUPLET_H
2 #define IMPORTMIDI_TUPLET_H
3 
4 #include "importmidi_fraction.h"
5 
6 
7 namespace Ms {
8 
9 class MidiChord;
10 class MidiNote;
11 class TimeSigMap;
12 class MTrack;
13 class DurationElement;
14 
15 namespace MidiTuplet {
16 
17 struct TupletInfo;
18 
19 struct TupletData
20  {
21  int voice;
25  std::vector<DurationElement *> elements;
26  };
27 
29  {
30  // ratio - for conversion from tuplet durations to regular durations
31  // for example, 8th note in triplet * 3/2 = regular 8th note
37  };
38 
40 
41 void removeEmptyTuplets(MTrack &track);
42 
44  const ReducedFraction &chordOnTime,
45  const QList<MidiNote> &notes,
46  const ReducedFraction &tupletOnTime,
47  const ReducedFraction &tupletLen);
48 
49 bool isTupletUseless(
50  int voice,
51  const ReducedFraction &onTime,
52  const ReducedFraction &len,
53  const ReducedFraction &maxChordLength,
54  const std::multimap<ReducedFraction, MidiChord> &chords);
55 
56 std::multimap<ReducedFraction, TupletData>::iterator
58  const std::multimap<ReducedFraction, TupletData>::iterator &tupletIt,
59  std::multimap<ReducedFraction, TupletData> &tuplets,
60  const ReducedFraction &maxChordLength,
61  std::multimap<ReducedFraction, MidiChord> &chords);
62 
63 std::multimap<ReducedFraction, TupletData>::iterator
65  const std::multimap<ReducedFraction, TupletData>::iterator &tupletIt,
66  std::multimap<ReducedFraction, TupletData> &tuplets,
67  const ReducedFraction &maxChordLength,
68  std::multimap<ReducedFraction, MidiChord> &chords);
69 
70 const TupletInfo& tupletFromId(int id, const std::vector<TupletInfo> &tuplets);
71 TupletInfo& tupletFromId(int id, std::vector<TupletInfo> &tuplets);
72 
73 std::pair<ReducedFraction, ReducedFraction>
74 tupletInterval(const TupletInfo &tuplet,
75  const ReducedFraction &basicQuant);
76 
77 std::vector<std::pair<ReducedFraction, ReducedFraction> >
78 findTupletIntervals(const std::vector<TupletInfo> &tuplets,
79  const ReducedFraction &basicQuant);
80 
81 std::vector<TupletData>
83  const ReducedFraction &barStartTick,
84  const ReducedFraction &durationOnTime,
85  const ReducedFraction &durationLen,
86  const std::multimap<ReducedFraction, TupletData> &tupletEvents);
87 
88 std::vector<std::multimap<ReducedFraction, TupletData>::const_iterator>
90  const ReducedFraction &onTime,
91  const ReducedFraction &len,
92  const std::multimap<ReducedFraction, TupletData> &tupletEvents,
93  bool strictComparison);
94 
95 std::multimap<ReducedFraction, TupletData>::const_iterator
97  const ReducedFraction &time,
98  const std::multimap<ReducedFraction, TupletData> &tupletEvents,
99  bool strictComparison);
100 
101 // Find tuplets and set bar indexes
102 
103 void findAllTuplets(
104  std::multimap<ReducedFraction, TupletData> &tuplets,
105  std::multimap<ReducedFraction, MidiChord> &chords,
106  const TimeSigMap *sigmap,
107  const ReducedFraction &basicQuant);
108 
110  const std::pair<const ReducedFraction, MidiChord> &chord,
111  const std::multimap<ReducedFraction, MidiChord> &chords,
112  const ReducedFraction &basicQuant,
113  const ReducedFraction &barStart);
114 
115 #ifdef QT_DEBUG
116 
117 bool areAllTupletsReferenced(
118  const std::multimap<ReducedFraction, MidiChord> &chords,
119  const std::multimap<ReducedFraction, TupletData> &tupletEvents);
120 
121 bool areTupletReferencesValid(const std::multimap<ReducedFraction, MidiChord> &chords);
122 
123 bool isTupletRangeOk(
124  const std::pair<const ReducedFraction, MidiChord> &chord,
125  const std::multimap<ReducedFraction, TupletData> &tuplets);
126 
127 bool areTupletRangesOk(
128  const std::multimap<ReducedFraction, MidiChord> &chords,
129  const std::multimap<ReducedFraction, TupletData> &tuplets);
130 
131 bool areAllTupletsDifferent(const std::multimap<ReducedFraction, TupletData> &tuplets);
132 
133 #endif
134 
135 } // namespace MidiTuplet
136 } // namespace Ms
137 
138 
139 #endif // IMPORTMIDI_TUPLET_H
int minNoteCount
Definition: importmidi_tuplet.h:33
void removeEmptyTuplets(MTrack &track)
Definition: importmidi_tuplet.cpp:157
int minNoteCountHuman
Definition: importmidi_tuplet.h:36
bool isTupletUseless(int voice, const ReducedFraction &onTime, const ReducedFraction &len, const ReducedFraction &maxChordLength, const std::multimap< ReducedFraction, MidiChord > &chords)
Definition: importmidi_tuplet.cpp:85
int minNoteCountAddVoice
Definition: importmidi_tuplet.h:34
Definition: importmidi_tuplet.h:28
std::vector< DurationElement * > elements
Definition: importmidi_tuplet.h:25
std::vector< std::pair< ReducedFraction, ReducedFraction > > findTupletIntervals(const std::vector< TupletInfo > &tuplets, const ReducedFraction &basicQuant)
Definition: importmidi_tuplet.cpp:239
std::pair< ReducedFraction, ReducedFraction > tupletInterval(const TupletInfo &tuplet, const ReducedFraction &basicQuant)
Definition: importmidi_tuplet.cpp:222
ReducedFraction ratio
Definition: importmidi_tuplet.h:32
std::multimap< ReducedFraction, TupletData >::iterator removeTuplet(const std::multimap< ReducedFraction, TupletData >::iterator &tupletIt, std::multimap< ReducedFraction, TupletData > &tuplets, const ReducedFraction &maxChordLength, std::multimap< ReducedFraction, MidiChord > &chords)
Definition: importmidi_tuplet.cpp:108
int voice
Definition: importmidi_tuplet.h:21
int minNoteCountStaccato
Definition: importmidi_tuplet.h:35
Definition: importmidi_inner.h:111
Definition: aeolus.cpp:26
Definition: importmidi_tuplet.h:19
void findAllTuplets(std::multimap< ReducedFraction, TupletData > &tuplets, std::multimap< ReducedFraction, MidiChord > &chords, const TimeSigMap *sigmap, const ReducedFraction &basicQuant)
Definition: importmidi_tuplet.cpp:1108
std::multimap< ReducedFraction, TupletData >::iterator removeTupletIfEmpty(const std::multimap< ReducedFraction, TupletData >::iterator &tupletIt, std::multimap< ReducedFraction, TupletData > &tuplets, const ReducedFraction &maxChordLength, std::multimap< ReducedFraction, MidiChord > &chords)
Definition: importmidi_tuplet.cpp:136
ReducedFraction onTime
Definition: importmidi_tuplet.h:22
bool hasNonTrivialChord(const ReducedFraction &chordOnTime, const QList< MidiNote > &notes, const ReducedFraction &tupletOnTime, const ReducedFraction &tupletLen)
Definition: importmidi_tuplet.cpp:56
const TupletInfo & tupletFromId(int id, const std::vector< TupletInfo > &tuplets)
Definition: importmidi_tuplet.cpp:40
std::multimap< ReducedFraction, TupletData >::const_iterator findTupletContainingTime(int voice, const ReducedFraction &time, const std::multimap< ReducedFraction, TupletData > &tupletEvents, bool strictComparison)
Definition: importmidi_tuplet.cpp:317
ReducedFraction findOnTimeBetweenChords(const std::pair< const ReducedFraction, MidiChord > &chord, const std::multimap< ReducedFraction, MidiChord > &chords, const ReducedFraction &basicQuant, const ReducedFraction &barStart)
Definition: importmidi_tuplet.cpp:907
ReducedFraction len
Definition: importmidi_tuplet.h:23
Definition: importmidi_inner.h:71
Definition: importmidi_fraction.h:9
int tupletNumber
Definition: importmidi_tuplet.h:24
std::vector< std::multimap< ReducedFraction, TupletData >::const_iterator > findTupletsForTimeRange(int voice, const ReducedFraction &onTime, const ReducedFraction &len, const std::multimap< ReducedFraction, TupletData > &tupletEvents, bool strictComparison)
Definition: importmidi_tuplet.cpp:280
Definition: sig.h:127
const TupletLimits & tupletLimits(int tupletNumber)
Definition: importmidi_tuplet.cpp:31
std::vector< TupletData > findTupletsInBarForDuration(int voice, const ReducedFraction &barStartTick, const ReducedFraction &durationOnTime, const ReducedFraction &durationLen, const std::multimap< ReducedFraction, TupletData > &tupletEvents)
Definition: importmidi_tuplet.cpp:252