Browse Source

midi pattern: Do not delete notes when changing number of measures

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.3.0-RC1
falkTX 4 years ago
parent
commit
cb8477cf1c
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 19 additions and 3 deletions
  1. +12
    -3
      source/frontend/widgets/pianoroll.py
  2. +7
    -0
      source/native-plugins/midi-base.hpp

+ 12
- 3
source/frontend/widgets/pianoroll.py View File

@@ -297,6 +297,7 @@ class PianoRoll(QGraphicsScene):
self.mousePos = QPointF() self.mousePos = QPointF()


self.notes = [] self.notes = []
self.removed_notes = []
self.selected_notes = [] self.selected_notes = []
self.piano_keys = [] self.piano_keys = []


@@ -316,8 +317,7 @@ class PianoRoll(QGraphicsScene):
self.start_octave = -2 self.start_octave = -2
self.end_octave = 8 self.end_octave = 8
self.notes_in_octave = 12 self.notes_in_octave = 12
self.total_notes = (self.end_octave - self.start_octave) \
* self.notes_in_octave + 1
self.total_notes = (self.end_octave - self.start_octave) * self.notes_in_octave + 1
self.piano_height = self.note_height * self.total_notes self.piano_height = self.note_height * self.total_notes
self.octave_height = self.notes_in_octave * self.note_height self.octave_height = self.notes_in_octave * self.note_height


@@ -694,10 +694,12 @@ class PianoRoll(QGraphicsScene):
self.drawHeader() self.drawHeader()
self.drawGrid() self.drawGrid()
self.drawPlayHead() self.drawPlayHead()

for note in self.notes[:]: for note in self.notes[:]:
if note.note[1] >= (self.num_measures * self.time_sig[0]): if note.note[1] >= (self.num_measures * self.time_sig[0]):
self.notes.remove(note) self.notes.remove(note)
self.midievent.emit(["midievent-remove", note.note[0], note.note[1], note.note[2], note.note[3]])
self.removed_notes.append(note)
#self.midievent.emit(["midievent-remove", note.note[0], note.note[1], note.note[2], note.note[3]])
elif note.note[2] > self.max_note_length: elif note.note[2] > self.max_note_length:
new_note = note.note[:] new_note = note.note[:]
new_note[2] = self.max_note_length new_note[2] = self.max_note_length
@@ -705,6 +707,12 @@ class PianoRoll(QGraphicsScene):
self.drawNote(new_note[0], new_note[1], self.max_note_length, new_note[3], False) self.drawNote(new_note[0], new_note[1], self.max_note_length, new_note[3], False)
self.midievent.emit(["midievent-remove", note.note[0], note.note[1], note.note[2], note.note[3]]) self.midievent.emit(["midievent-remove", note.note[0], note.note[1], note.note[2], note.note[3]])
self.midievent.emit(["midievent-add", new_note[0], new_note[1], new_note[2], new_note[3]]) self.midievent.emit(["midievent-add", new_note[0], new_note[1], new_note[2], new_note[3]])

for note in self.removed_notes[:]:
if note.note[1] < (self.num_measures * self.time_sig[0]):
self.removed_notes.remove(note)
self.notes.append(note)

list(map(self.addItem, self.notes)) list(map(self.addItem, self.notes))
if self.views(): if self.views():
self.views()[0].setSceneRect(self.itemsBoundingRect()) self.views()[0].setSceneRect(self.itemsBoundingRect())
@@ -712,6 +720,7 @@ class PianoRoll(QGraphicsScene):
def clearNotes(self): def clearNotes(self):
self.clear() self.clear()
self.notes = [] self.notes = []
self.removed_notes = []
self.selected_notes = [] self.selected_notes = []
self.drawPiano() self.drawPiano()
self.drawHeader() self.drawHeader()


+ 7
- 0
source/native-plugins/midi-base.hpp View File

@@ -277,6 +277,13 @@ public:
if (ldtime > timePosFrame + frames) if (ldtime > timePosFrame + frames)
break; break;


if (carla_isEqual(ldtime, timePosFrame + frames))
{
// only allow a few events to pass through in this special case
if (! MIDI_IS_STATUS_NOTE_OFF(rawMidiEvent->data[0]))
continue;
}

kPlayer->writeMidiEvent(fMidiPort, ldtime + offset - timePosFrame, rawMidiEvent); kPlayer->writeMidiEvent(fMidiPort, ldtime + offset - timePosFrame, rawMidiEvent);
} }




Loading…
Cancel
Save