Skip to content

Commit ae9ce8b

Browse files
committed
increase midi velocity with factor 2
1 parent 0549817 commit ae9ce8b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

synth_control.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ extern "C" {
4545

4646
#define VOLUME_FACTOR 0.005f;
4747

48+
#define VELO_MIDI_FIX 4
49+
4850
void MidiSend1(uint8_t b0) {
4951
midi_usb_MidiSend1(1, b0);
5052
#ifdef USE_MIDI_SERIAL
@@ -652,7 +654,7 @@ class Instrument {
652654
buttons[but].state = STATE_ON;
653655
buttons[but].midinote = buttons[but].midinote_base + start_note_offset;
654656
buttons[but].start_note_offset = start_note_offset;
655-
int velo = 0 + buttons[but].vpres * velo_sensitivity * 256;
657+
int velo = 0 + buttons[but].vpres * velo_sensitivity * 128 * VELO_MIDI_FIX;
656658
if (velo > 127) velo = 127;
657659
else if (velo < 1) velo = 1;
658660
MidiSend3(MIDI_NOTE_ON | midi_channel_offset,
@@ -755,7 +757,7 @@ class Instrument {
755757

756758
} else { // Note off
757759
buttons[but].state = STATE_OFF;
758-
int velo = 0 - buttons[but].vpres * velo_sensitivity * 256;
760+
int velo = 0 - buttons[but].vpres * velo_sensitivity * 128 * VELO_MIDI_FIX;
759761
if (velo > 127) velo = 127;
760762
else if (velo < 0) velo = 0;
761763
MidiSend3(MIDI_NOTE_OFF | midi_channel_offset,
@@ -895,7 +897,7 @@ class Instrument {
895897
buttons[but].state = STATE_OFF;
896898

897899
#ifdef USE_MIDI_OUT
898-
int velo = 0 - buttons[but].vpres * velo_sensitivity * 256;
900+
int velo = 0 - buttons[but].vpres * velo_sensitivity * 128 * VELO_MIDI_FIX;
899901
if (velo > 127) velo = 127;
900902
else if (velo < 0) velo = 0;
901903
MidiSend3(MIDI_NOTE_OFF | (midi_channel_offset + buttons[but].voice),
@@ -934,7 +936,7 @@ class Instrument {
934936
last_button = but;
935937

936938
#ifdef USE_MIDI_OUT
937-
int velo = 0 + buttons[but].vpres * velo_sensitivity * 256;
939+
int velo = 0 + buttons[but].vpres * velo_sensitivity * 128 * VELO_MIDI_FIX;
938940
if (velo > 127) velo = 127;
939941
else if (velo < 1) velo = 1;
940942

0 commit comments

Comments
 (0)