@@ -248,3 +248,61 @@ void ActionMIDISetNoteLyrics::getRecoveryData(juce::MemoryOutputStream& stream)
248
248
stream.writeString (this ->lyrics );
249
249
stream.writeString (this ->oldLyrics );
250
250
}
251
+
252
+ ActionMIDIRemoveNote::ActionMIDIRemoveNote (
253
+ uint64_t ref, int track, int index)
254
+ : ref(ref), track(track), index(index) {}
255
+
256
+ bool ActionMIDIRemoveNote::doAction () {
257
+ /* * Get Note Data */
258
+ auto note = SourceManager::getInstance ()->getMIDINote (
259
+ this ->ref , this ->track , this ->index );
260
+ if (note.eventOffIndex < 0 ) { return false ; }
261
+
262
+ this ->startTime = note.timeSec ;
263
+ this ->endTime = note.endSec ;
264
+ this ->channel = note.channel ;
265
+ this ->pitch = note.pitch ;
266
+ this ->vel = note.vel ;
267
+ this ->lyrics = note.lyrics ;
268
+
269
+ this ->oldEndIndex = note.eventOffIndex ;
270
+
271
+ /* * Remove Note */
272
+ return SourceManager::getInstance ()->removeNote (
273
+ this ->ref , this ->track , this ->index );
274
+ }
275
+
276
+ bool ActionMIDIRemoveNote::undoAction () {
277
+ /* * Restore Note */
278
+ int index = SourceManager::getInstance ()->addNote (
279
+ this ->ref , this ->track , this ->startTime , this ->endTime ,
280
+ this ->channel , this ->pitch , this ->vel , this ->lyrics ,
281
+ this ->index , this ->oldEndIndex );
282
+ return (index == this ->index );
283
+ }
284
+
285
+ const juce::String ActionMIDIRemoveNote::getStatusStr () const {
286
+ return " Source: " + juce::String{ this ->ref } + " \n " +
287
+ " Track: " + juce::String{ this ->track } + " \n " +
288
+ " Index: " + juce::String{ this ->index } + " \n " +
289
+ " Time: " + juce::String{ this ->startTime , 2 } + " - " + juce::String{ this ->endTime , 2 } + " \n " +
290
+ " Channel: " + juce::String{ this ->channel } + " \n " +
291
+ " Pitch: " + juce::String{ this ->pitch } + " \n " +
292
+ " Velocity: " + juce::String{ this ->vel } + " \n " +
293
+ " Lyrics: " + this ->lyrics + " \n " ;
294
+ }
295
+
296
+ void ActionMIDIRemoveNote::getRecoveryData (juce::MemoryOutputStream& stream) {
297
+ stream.writeInt64 ((int64_t )this ->ref );
298
+ stream.writeInt (this ->track );
299
+ stream.writeInt (this ->index );
300
+ stream.writeDouble (this ->startTime );
301
+ stream.writeDouble (this ->endTime );
302
+ stream.writeByte ((char )this ->channel );
303
+ stream.writeByte ((char )this ->pitch );
304
+ stream.writeByte ((char )this ->vel );
305
+ stream.writeString (this ->lyrics );
306
+
307
+ stream.writeInt (this ->oldEndIndex );
308
+ }
0 commit comments