Skip to content

Commit

Permalink
Revert "Merge pull request #4538 from MichaelFroelich/68456_fixesPitc…
Browse files Browse the repository at this point in the history
…hBends"

This reverts commit 1d5ae8a.
  • Loading branch information
anatoly-os committed May 22, 2019
1 parent ada5188 commit 740c428
Show file tree
Hide file tree
Showing 17 changed files with 8 additions and 19 deletions.
3 changes: 1 addition & 2 deletions fluid/chan.cpp
Expand Up @@ -21,7 +21,6 @@
#include "fluid.h"
#include "sfont.h"
#include "gen.h"
#include "synthesizer/event.h"

namespace FluidS {

Expand Down Expand Up @@ -70,7 +69,7 @@ void Channel::initCtrl()
key_pressure = 0;
channel_pressure = 0;
pitch_bend = 0x2000; // Range is 0x4000, pitch bend wheel starts in centered position
pitch_wheel_sensitivity = PITCH_BEND_SENSITIVITY; /* four semi-tones, default for many DAWs */
pitch_wheel_sensitivity = 12; /* twelve semi-tones */
bank_msb = 0;

for (int i = 0; i < GEN_LAST; i++) {
Expand Down
8 changes: 4 additions & 4 deletions libmscore/rendermidi.cpp
Expand Up @@ -331,9 +331,9 @@ static void collectNote(EventMap* events, int channel, const Note* note, int vel
int pitch = pitchValue.pitch;

if (pitchIndex == 0 && (pitch == nextPitch.pitch)) {
int midiPitch = midiBendPitch(pitch);
int msb = (midiPitch / 128);
int lsb = (midiPitch % 128);
int midiPitch = (pitch * 16384) / 1200 + 8192;
int msb = midiPitch / 128;
int lsb = midiPitch % 128;
NPlayEvent ev(ME_PITCHBEND, channel, lsb, msb);
ev.setOriginatingStaff(staffIdx);
events->insert(std::pair<int, NPlayEvent>(lastPointTick, ev));
Expand All @@ -358,7 +358,7 @@ static void collectNote(EventMap* events, int channel, const Note* note, int vel
int p = pitch + dx * pitchDelta / tickDelta;

// We don't support negative pitch, but Midi does. Let's center by adding 8192.
int midiPitch = midiBendPitch(p);
int midiPitch = (p * 16384) / 1200 + 8192;
// Representing pitch as two bytes
int msb = midiPitch / 128;
int lsb = midiPitch % 128;
Expand Down
2 changes: 1 addition & 1 deletion mscore/exportmidi.cpp
Expand Up @@ -258,7 +258,7 @@ bool ExportMidi::write(QIODevice* device, bool midiExpandRepeats, bool exportRPN
// set pitch bend sensitivity to 12 semitones:
track.insert(0, MidiEvent(ME_CONTROLLER, channel, CTRL_LRPN, 0));
track.insert(0, MidiEvent(ME_CONTROLLER, channel, CTRL_HRPN, 0));
track.insert(0, MidiEvent(ME_CONTROLLER, channel, CTRL_HDATA, PITCH_BEND_SENSITIVITY));
track.insert(0, MidiEvent(ME_CONTROLLER, channel, CTRL_HDATA, 12));

// reset fine tuning
/*track.insert(0, MidiEvent(ME_CONTROLLER, channel, CTRL_LRPN, 1));
Expand Down
4 changes: 2 additions & 2 deletions mscore/seq.cpp
Expand Up @@ -987,14 +987,14 @@ void Seq::initInstruments(bool realTime)
if (realTime) {
putEvent(NPlayEvent(ME_CONTROLLER, channel->channel(), CTRL_LRPN, 0));
putEvent(NPlayEvent(ME_CONTROLLER, channel->channel(), CTRL_HRPN, 0));
putEvent(NPlayEvent(ME_CONTROLLER, channel->channel(), CTRL_HDATA, PITCH_BEND_SENSITIVITY));
putEvent(NPlayEvent(ME_CONTROLLER, channel->channel(), CTRL_HDATA,12));
putEvent(NPlayEvent(ME_CONTROLLER, channel->channel(), CTRL_LRPN, 127));
putEvent(NPlayEvent(ME_CONTROLLER, channel->channel(), CTRL_HRPN, 127));
}
else {
sendEvent(NPlayEvent(ME_CONTROLLER, channel->channel(), CTRL_LRPN, 0));
sendEvent(NPlayEvent(ME_CONTROLLER, channel->channel(), CTRL_HRPN, 0));
sendEvent(NPlayEvent(ME_CONTROLLER, channel->channel(), CTRL_HDATA, PITCH_BEND_SENSITIVITY));
sendEvent(NPlayEvent(ME_CONTROLLER, channel->channel(), CTRL_HDATA,12));
sendEvent(NPlayEvent(ME_CONTROLLER, channel->channel(), CTRL_LRPN, 127));
sendEvent(NPlayEvent(ME_CONTROLLER, channel->channel(), CTRL_HRPN, 127));
}
Expand Down
Binary file modified mtest/libmscore/midi/testArpeggio-ref.mid
Binary file not shown.
Binary file modified mtest/libmscore/midi/testBends1-ref.mid
Binary file not shown.
Binary file modified mtest/libmscore/midi/testBends2-ref.mid
Binary file not shown.
Binary file modified mtest/libmscore/midi/testInitialKeySigThenRepeatToMeas2-ref.mid
Binary file not shown.
Binary file modified mtest/libmscore/midi/testRepeatsWithKeySigs-ref.mid
Binary file not shown.
Binary file not shown.
Binary file modified mtest/libmscore/midi/testSingleNoteDynamics-ref.mid
Binary file not shown.
Binary file modified mtest/libmscore/midi/testTimeStretchFermata-ref.mid
Binary file not shown.
Binary file modified mtest/libmscore/midi/testVoltaDynamic-ref.mid
Binary file not shown.
Binary file modified mtest/libmscore/midi/testVoltaStaffText-ref.mid
Binary file not shown.
Binary file modified mtest/libmscore/midi/testVoltaTemp-ref.mid
Binary file not shown.
6 changes: 0 additions & 6 deletions synthesizer/event.cpp
Expand Up @@ -204,8 +204,6 @@ bool MidiCoreEvent::isChannelEvent() const
// return false;
}



//---------------------------------------------------------
// Event::write
//---------------------------------------------------------
Expand Down Expand Up @@ -356,10 +354,6 @@ QString midiMetaName(int meta)
return QString(s);
}

int midiBendPitch(int pitch) {
return (pitch * 8192) / (PITCH_BEND_SENSITIVITY * 100) + 8192;
}

//---------------------------------------------------------
// insert
//---------------------------------------------------------
Expand Down
4 changes: 0 additions & 4 deletions synthesizer/event.h
Expand Up @@ -22,9 +22,6 @@ class XmlWriter;

enum class BeatType : char;

// 4 is the default for the majority of synthesisers, aka VSTis
const int PITCH_BEND_SENSITIVITY = 4;

//---------------------------------------------------------
// Event types
//---------------------------------------------------------
Expand Down Expand Up @@ -336,7 +333,6 @@ typedef EventList::const_iterator ciEvent;

extern QString midiMetaName(int meta);

extern int midiBendPitch(int pitch);
}
#endif

0 comments on commit 740c428

Please sign in to comment.