private void HandleNote(MidiEvent midiEvent, ChannelMessage previousChannelMessage) { double lengthOfNote = CalculatePartOfBar(_previousNoteAbsoluteTicks, midiEvent.AbsoluteTicks); double availableLengthBar = EasyTimeSignature.Top - _notesOfBarReached; while (lengthOfNote > 0) { // Get note int midiKeyNote = previousChannelMessage.Data1; NoteBuilder noteBuilder = NoteBuilderDictionary[midiKeyNote % 12]; int distance = midiKeyNote - _previousMidiKey; _previousMidiKey = midiKeyNote; while (distance < -6) { noteBuilder.DecreaseOctave(); distance += 8; } while (distance > 6) { noteBuilder.IncreaseOctave(); distance -= 8; } // Get duration int duration; int dots; bool isTied; HandleDuration(lengthOfNote, availableLengthBar, out lengthOfNote, out availableLengthBar, out duration, out dots, out isTied); // Create note and add noteBuilder.Duration((DurationType)duration); noteBuilder.IsDotted(dots); noteBuilder.IsTied(isTied); if (NoteIsTied) { noteBuilder.IsTied(); NoteIsTied = false; } AddToPiece(noteBuilder.Build()); // Check bar if (availableLengthBar == 0) { availableLengthBar = EasyTimeSignature.Top; } _notesOfBarReached = EasyTimeSignature.Top - availableLengthBar; } _previousNoteAbsoluteTicks = midiEvent.AbsoluteTicks; }
private bool increaseOctave() { NoteBuilder.IncreaseOctave(); return(true); }