Commit 4d50d27
committed
Route MIDI Poly/Channel Pressure to aftertouch, not pitchBend
The 0xA0 (Poly Key Pressure) and 0xD0 (Channel Pressure) handlers
in handleMidi() were both calling setFromInt on
ParameterID::pitchBend, even though the inline comments said
'Aftertouch'. Looks like a copy-paste of the 0xE0 (pitch bend)
case that never got its parameter ID corrected.
Effect today: pressure values were silently misrouted into the
pitchBend parameter. The mismatch was nearly inaudible because the
pitchBend scale is [-8192, 8191] (14-bit) but data[2] is 0-127, so
the misrouted values produced only a tiny upward pitch drift.
Two coordinated fixes:
1. Route both 0xA0 and 0xD0 to ParameterID::aftertouch. Scales are
already aligned: Scales::aftertouch is (0.0, 127.0) — exactly
the MIDI value range.
2. Relax the early-return size guard from \`!= 3\` to \`< 2\`. Channel
Pressure is a 2-byte message (status + value, no data[2]). The
old strict-3 guard silently dropped every 0xD0 event before it
could reach the switch, so even after the routing fix, channel
pressure would still do nothing without this. The new floor lets
each case rely on its own status-byte size convention; only 0xD0
actually needs the 2-byte allowance, the other cases still
inspect data[2] safely because all their status bytes mean
3-byte messages.
Poly Key Pressure (0xA0) on a monophonic synth applies globally
(there's only one note); the data[1] note-number field is ignored.
Found while looking into MPE support — pressure routing is one of
the things any MPE mapping needs to get right, so this had to be
correct first.1 parent 13e2275 commit 4d50d27
1 file changed
Lines changed: 10 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
157 | 161 | | |
158 | 162 | | |
159 | 163 | | |
| |||
178 | 182 | | |
179 | 183 | | |
180 | 184 | | |
181 | | - | |
| 185 | + | |
| 186 | + | |
182 | 187 | | |
183 | | - | |
| 188 | + | |
184 | 189 | | |
185 | 190 | | |
186 | 191 | | |
187 | 192 | | |
188 | 193 | | |
189 | 194 | | |
190 | 195 | | |
191 | | - | |
| 196 | + | |
192 | 197 | | |
193 | | - | |
| 198 | + | |
194 | 199 | | |
195 | 200 | | |
196 | 201 | | |
| |||
0 commit comments