From 0ff002cbc3aaf8b7664d31ec7591ab3faafdaa6b Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 10 Nov 2019 20:27:36 +0100 Subject: [PATCH] midipattern: fix writing notes independent of BPM --- source/native-plugins/midi-pattern.cpp | 15 +-------------- source/native-plugins/resources/midipattern-ui | 10 +++++----- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/source/native-plugins/midi-pattern.cpp b/source/native-plugins/midi-pattern.cpp index 2c25e6abc..2731ac2bd 100644 --- a/source/native-plugins/midi-pattern.cpp +++ b/source/native-plugins/midi-pattern.cpp @@ -189,20 +189,7 @@ protected: switch (index) { case kParameterTimeSig: - /**/ if (value > 4.5f) - fTimeSigNum = 6; - else if (value > 3.5f) - fTimeSigNum = 5; - else if (value > 2.5f) - fTimeSigNum = 4; - /* FIXME - else if (value > 2.5f) - fTimeSigNum = 3; - */ - else if (value > 1.5f) - fTimeSigNum = 2; - else - fTimeSigNum = 1; + fTimeSigNum = static_cast(value + 1.5f); // fall through case kParameterMeasures: fMaxTicks = TICKS_PER_BEAT * fTimeSigNum * static_cast(fParameters[kParameterMeasures]); diff --git a/source/native-plugins/resources/midipattern-ui b/source/native-plugins/resources/midipattern-ui index a3b1ed40b..28e676bca 100755 --- a/source/native-plugins/resources/midipattern-ui +++ b/source/native-plugins/resources/midipattern-ui @@ -135,7 +135,7 @@ class MidiPatternW(ExternalUI, QMainWindow): try: timesig = tuple(map(float, sigtext.split('/'))) except ValueError: - pass + return if len(timesig) != 2: return @@ -225,15 +225,15 @@ class MidiPatternW(ExternalUI, QMainWindow): msg = data[0] if msg == "midievent-add": note, start, length, vel = data[1:5] - note_start = start * 60. / self.fTransportInfo["bpm"] * self.TICKS_PER_BEAT - note_stop = note_start + length * 60. / self.fTransportInfo["bpm"] * 4. * self.fTimeSignature[0] / self.fTimeSignature[1] * self.TICKS_PER_BEAT + note_start = start * self.TICKS_PER_BEAT + note_stop = note_start + length * 4. * self.fTimeSignature[0] / self.fTimeSignature[1] * self.TICKS_PER_BEAT self.send([msg, note_start, 3, MIDI_STATUS_NOTE_ON, note, vel]) self.send([msg, note_stop, 3, MIDI_STATUS_NOTE_OFF, note, vel]) elif msg == "midievent-remove": note, start, length, vel = data[1:5] - note_start = start * 60. / self.fTransportInfo["bpm"] * self.TICKS_PER_BEAT # 4. / self.fTransportInfo["sigDenom"] * self.TICKS_PER_BEAT - note_stop = note_start + length * 60. / self.fTransportInfo["bpm"] * 4. * self.fTimeSignature[0] / self.fTimeSignature[1] * self.TICKS_PER_BEAT + note_start = start * self.TICKS_PER_BEAT + note_stop = note_start + length * 4. * self.fTimeSignature[0] / self.fTimeSignature[1] * self.TICKS_PER_BEAT self.send([msg, note_start, 3, MIDI_STATUS_NOTE_ON, note, vel]) self.send([msg, note_stop, 3, MIDI_STATUS_NOTE_OFF, note, vel])