Browse Source

midipattern: fix writing notes independent of BPM

tags/v2.1-rc1
falkTX 6 years ago
parent
commit
0ff002cbc3
2 changed files with 6 additions and 19 deletions
  1. +1
    -14
      source/native-plugins/midi-pattern.cpp
  2. +5
    -5
      source/native-plugins/resources/midipattern-ui

+ 1
- 14
source/native-plugins/midi-pattern.cpp View File

@@ -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<int>(value + 1.5f);
// fall through
case kParameterMeasures:
fMaxTicks = TICKS_PER_BEAT * fTimeSigNum * static_cast<double>(fParameters[kParameterMeasures]);


+ 5
- 5
source/native-plugins/resources/midipattern-ui View File

@@ -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])



Loading…
Cancel
Save