1 #ifndef IMPORTMIDI_OPERATIONS_H 2 #define IMPORTMIDI_OPERATIONS_H 11 class ReducedFraction;
12 class InstrumentTemplate;
14 namespace MidiCharset {
21 namespace MidiOperations {
36 : _operation{{-1, defaultValue}}, _canRedefineDefaultLater(
true)
39 const T&
value(
int trackIndex)
const 41 const auto it = _operation.find(trackIndex);
42 if (it == _operation.end())
43 return _operation.find(-1)->second;
49 Q_ASSERT_X(trackIndex >= 0,
"TrackOperation",
"Invalid track index");
51 if (value != this->value(trackIndex))
52 _operation[trackIndex] = value;
57 return _operation.find(-1)->second;
64 Q_ASSERT_X(_canRedefineDefaultLater,
"TrackOp::setDefaultValue",
65 "Cannot set default value");
67 if (!_canRedefineDefaultLater)
69 _operation[-1] = value;
70 _canRedefineDefaultLater = canRedefineDefaultLater;
75 T defaultVal = defaultValue();
77 _operation[-1] = defaultVal;
91 explicit Op(T defaultValue)
92 : _value(defaultValue), _valueWasSet(false),
93 _defaultValue{defaultValue}, _canRedefineDefaultLater(
true)
105 if (value != this->value()) {
113 return _defaultValue;
120 Q_ASSERT_X(_canRedefineDefaultLater,
"Op::setDefaultValue",
121 "Cannot set default value");
123 if (!_canRedefineDefaultLater)
125 _defaultValue = value;
126 _canRedefineDefaultLater = canRedefineDefaultLater;
145 std::vector<const InstrumentTemplate *>());
184 int addedFirstBeats = 0;
185 int addedLastBeats = 0;
189 bool measureCount2xLess =
false;
196 int processingsOfOpenedFile = 0;
197 bool hasTempoText =
false;
219 void addNewMidiFile(
const QString &fileName);
220 int currentTrack()
const;
221 void setMidiFileData(
const QString &fileName,
const MidiFile &midiFile);
222 void excludeMidiFile(
const QString &fileName);
223 bool hasMidiFile(
const QString &fileName);
224 const MidiFile* midiFile(
const QString &fileName);
225 QStringList allMidiFiles()
const;
226 void setOperationsFile(
const QString &fileName);
234 int _currentTrack = -1;
246 _oldValue = _opers._currentTrack;
247 _opers._currentTrack = track;
252 _opers._currentTrack = _oldValue;
258 void*
operator new(size_t);
259 void*
operator new(size_t,
void*);
260 void*
operator new[](size_t);
261 void*
operator new[](size_t,
void*);
271 _oldValue = _opers._currentMidiFile;
272 _opers._currentMidiFile = fileName;
277 _opers._currentMidiFile = _oldValue;
283 void*
operator new(size_t);
284 void*
operator new(size_t,
void*);
285 void*
operator new[](size_t);
286 void*
operator new[](size_t,
void*);
295 #endif // IMPORTMIDI_OPERATIONS_H Definition: importmidi_operations.h:240
std::map< int, T > _operation
Definition: importmidi_operations.h:82
Definition: importmidi_operations.h:87
Definition: importmidi_operations.h:213
QString _midiOperationsFile
Definition: importmidi_operations.h:233
T _value
Definition: importmidi_operations.h:129
void setValue(int trackIndex, T value)
Definition: importmidi_operations.h:47
bool canRedefineDefaultLater() const
Definition: importmidi_operations.h:116
void setValue(T value)
Definition: importmidi_operations.h:103
CurrentTrackSetter(Data &opers, int track)
Definition: importmidi_operations.h:243
QuantValue
Definition: importmidi_operation.h:16
Definition: importmidi_operations.h:192
std::map< QString, FileData > _data
Definition: importmidi_operations.h:236
~CurrentTrackSetter()
Definition: importmidi_operations.h:250
Opers trackOpers
Definition: importmidi_operations.h:201
bool _valueWasSet
Definition: importmidi_operations.h:130
TrackOp(T defaultValue)
Definition: importmidi_operations.h:35
MidiOperations::Data midiImportOperations
Definition: importmidi_operations.cpp:6
ReducedFraction firstChordTick
Definition: importmidi_operations.h:186
void clear()
Definition: importmidi_operations.h:73
const T & defaultValue() const
Definition: importmidi_operations.h:55
bool _canRedefineDefaultLater
Definition: importmidi_operations.h:132
T value() const
Definition: importmidi_operations.h:96
QString _currentMidiFile
Definition: importmidi_operations.h:232
QList< MTrack > tracks
Definition: importmidi_operations.h:195
void simplifyDurations(std::multimap< int, MTrack > &tracks, const TimeSigMap *sigmap, bool simplifyDrumTracks)
Definition: importmidi_simplify.cpp:276
QByteArray HHeaderData
Definition: importmidi_operations.h:198
Definition: midifile.h:70
ReducedFraction lastChordTick
Definition: importmidi_operations.h:187
void setDefaultValue(T value, bool canRedefineDefaultLater=true)
Definition: importmidi_operations.h:118
ReducedFraction timeSig
Definition: importmidi_operations.h:188
bool isHumanPerformance(const std::multimap< ReducedFraction, MidiChord > &chords, const TimeSigMap *sigmap)
Definition: importmidi_quant.cpp:338
Definition: importmidi_operations.h:180
QByteArray VHeaderData
Definition: importmidi_operations.h:199
Definition: aeolus.cpp:26
HumanBeatData humanBeatData
Definition: importmidi_operations.h:210
bool _canRedefineDefaultLater
Definition: importmidi_operations.h:83
Definition: importmidi_operations.h:32
void setDefaultValue(T value, bool canRedefineDefaultLater=true)
Definition: importmidi_operations.h:62
~CurrentMidiFileSetter()
Definition: importmidi_operations.h:275
QString defaultCharset()
Definition: importmidi_inner.cpp:246
Op(T defaultValue)
Definition: importmidi_operations.h:91
std::multimap< ReducedFraction, QString > chordNames
Definition: importmidi_operations.h:209
std::set< ReducedFraction > beatSet
Definition: importmidi_operations.h:182
QString _oldValue
Definition: importmidi_operations.h:281
MidiOperations::QuantValue defaultQuantValueFromPreferences()
Definition: importmidi_quant.cpp:81
Definition: importmidi_operations.h:265
Data & _opers
Definition: importmidi_operations.h:280
bool canRedefineDefaultLater() const
Definition: importmidi_operations.h:60
Definition: importmidi_fraction.h:9
const T & value(int trackIndex) const
Definition: importmidi_operations.h:39
T _defaultValue
Definition: importmidi_operations.h:131
QList< std::multimap< ReducedFraction, std::string > > lyricTracks
Definition: importmidi_operations.h:208
MidiFile midiFile
Definition: importmidi_operations.h:194
Data & _opers
Definition: importmidi_operations.h:255
CurrentMidiFileSetter(Data &opers, const QString &fileName)
Definition: importmidi_operations.h:268
T defaultValue() const
Definition: importmidi_operations.h:111
Definition: importmidi_operations.h:137
int _oldValue
Definition: importmidi_operations.h:256