diff options
author | Stepan Moskovchenko <stevenm@rockbox.org> | 2007-10-21 19:47:33 +0000 |
---|---|---|
committer | Stepan Moskovchenko <stevenm@rockbox.org> | 2007-10-21 19:47:33 +0000 |
commit | 47d8323deb8c7351c66a89599f15b60e06a5b814 (patch) | |
tree | f046f7e1786930311b76a65b8a014ce7d1ee3a13 | |
parent | 6fac8fcc93fa1fc8a6f288f57258f1c8443cf9db (diff) | |
download | rockbox-47d8323deb8c7351c66a89599f15b60e06a5b814.tar.gz rockbox-47d8323deb8c7351c66a89599f15b60e06a5b814.zip |
MIDI: Fix ringing/beeks in music caused by improper parsing of some pitch bend events.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15252 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/midi/midiutil.c | 3 | ||||
-rw-r--r-- | apps/plugins/midi/midiutil.h | 15 | ||||
-rw-r--r-- | apps/plugins/midi/sequencer.c | 33 | ||||
-rw-r--r-- | apps/plugins/midi/synth.c | 2 |
4 files changed, 47 insertions, 6 deletions
diff --git a/apps/plugins/midi/midiutil.c b/apps/plugins/midi/midiutil.c index 92ab8db8d6..65ba9c8989 100644 --- a/apps/plugins/midi/midiutil.c +++ b/apps/plugins/midi/midiutil.c | |||
@@ -28,7 +28,8 @@ int chPW[16] IBSS_ATTR; /* Channel pitch wheel, MSB only */ | |||
28 | int chPBDepth[16] IBSS_ATTR; /* Channel pitch bend depth */ | 28 | int chPBDepth[16] IBSS_ATTR; /* Channel pitch bend depth */ |
29 | int chPBNoteOffset[16] IBSS_ATTR; /* Pre-computed whole semitone offset */ | 29 | int chPBNoteOffset[16] IBSS_ATTR; /* Pre-computed whole semitone offset */ |
30 | int chPBFractBend[16] IBSS_ATTR; /* Fractional bend applied to delta */ | 30 | int chPBFractBend[16] IBSS_ATTR; /* Fractional bend applied to delta */ |
31 | 31 | unsigned char chLastCtrlMSB[16]; /* MIDI regs, used for Controller 6. */ | |
32 | unsigned char chLastCtrlLSB[16]; /* The non-registered ones are ignored */ | ||
32 | 33 | ||
33 | struct GPatch * gusload(char *); | 34 | struct GPatch * gusload(char *); |
34 | struct GPatch * patchSet[128]; | 35 | struct GPatch * patchSet[128]; |
diff --git a/apps/plugins/midi/midiutil.h b/apps/plugins/midi/midiutil.h index cb89e004aa..dfffe39dd6 100644 --- a/apps/plugins/midi/midiutil.h +++ b/apps/plugins/midi/midiutil.h | |||
@@ -62,10 +62,19 @@ | |||
62 | #define MIDI_PITCHW 224 | 62 | #define MIDI_PITCHW 224 |
63 | 63 | ||
64 | /* MIDI Controllers */ | 64 | /* MIDI Controllers */ |
65 | #define CTRL_PWDEPTH 6 | 65 | #define CTRL_DATAENT_MSB 6 |
66 | #define CTRL_VOLUME 7 | 66 | #define CTRL_VOLUME 7 |
67 | #define CTRL_BALANCE 8 | 67 | #define CTRL_BALANCE 8 |
68 | #define CTRL_PANNING 10 | 68 | #define CTRL_PANNING 10 |
69 | #define CTRL_NONREG_LSB 98 | ||
70 | #define CTRL_NONREG_MSB 99 | ||
71 | #define CTRL_REG_LSB 100 | ||
72 | #define CTRL_REG_MSB 101 | ||
73 | |||
74 | #define REG_PITCHBEND_MSB 0 | ||
75 | #define REG_PITCHBEND_LSB 0 | ||
76 | |||
77 | |||
69 | #define CHANNEL 1 | 78 | #define CHANNEL 1 |
70 | 79 | ||
71 | /* Most of these are deprecated.. rampdown is used, maybe one other one too */ | 80 | /* Most of these are deprecated.. rampdown is used, maybe one other one too */ |
@@ -145,8 +154,8 @@ extern int chPW[16]; /* Channel pitch wheel, MSB only */ | |||
145 | extern int chPBDepth[16]; /* Channel pitch bend depth (Controller 6 */ | 154 | extern int chPBDepth[16]; /* Channel pitch bend depth (Controller 6 */ |
146 | extern int chPBNoteOffset[16] IBSS_ATTR; /* Pre-computed whole semitone offset */ | 155 | extern int chPBNoteOffset[16] IBSS_ATTR; /* Pre-computed whole semitone offset */ |
147 | extern int chPBFractBend[16] IBSS_ATTR; /* Fractional bend applied to delta */ | 156 | extern int chPBFractBend[16] IBSS_ATTR; /* Fractional bend applied to delta */ |
148 | 157 | extern unsigned char chLastCtrlMSB[16]; /* MIDI regs, used for Controller 6. */ | |
149 | 158 | extern unsigned char chLastCtrlLSB[16]; /* The non-registered ones are ignored */ | |
150 | 159 | ||
151 | extern struct GPatch * gusload(char *); | 160 | extern struct GPatch * gusload(char *); |
152 | extern struct GPatch * patchSet[128]; | 161 | extern struct GPatch * patchSet[128]; |
diff --git a/apps/plugins/midi/sequencer.c b/apps/plugins/midi/sequencer.c index 536d411902..c4ddfcf95a 100644 --- a/apps/plugins/midi/sequencer.c +++ b/apps/plugins/midi/sequencer.c | |||
@@ -299,10 +299,39 @@ static void sendEvent(struct Event * ev) | |||
299 | chPan[status_low]=d2; | 299 | chPan[status_low]=d2; |
300 | return; | 300 | return; |
301 | } | 301 | } |
302 | case CTRL_PWDEPTH: | 302 | case CTRL_DATAENT_MSB: |
303 | { | 303 | { |
304 | /* TODO: Update all deltas. Is this really needed? */ | 304 | /* TODO: Update all deltas. Is this really needed? */ |
305 | chPBDepth[status_low] = d2; | 305 | if(chLastCtrlMSB[status_low] == REG_PITCHBEND_MSB && |
306 | chLastCtrlLSB[status_low] == REG_PITCHBEND_LSB) | ||
307 | { | ||
308 | // printf("Pitch bend depth set to %d\n", d2); | ||
309 | chPBDepth[status_low] = d2; | ||
310 | } | ||
311 | return; | ||
312 | } | ||
313 | |||
314 | case CTRL_NONREG_LSB: | ||
315 | { | ||
316 | chLastCtrlLSB[status_low] = 0xFF; /* Ignore nonregistered writes */ | ||
317 | return; | ||
318 | } | ||
319 | |||
320 | case CTRL_NONREG_MSB: | ||
321 | { | ||
322 | chLastCtrlMSB[status_low] = 0xFF; /* Ignore nonregistered writes */ | ||
323 | return; | ||
324 | } | ||
325 | |||
326 | case CTRL_REG_LSB: | ||
327 | { | ||
328 | chLastCtrlLSB[status_low] = d2; | ||
329 | return; | ||
330 | } | ||
331 | |||
332 | case CTRL_REG_MSB: | ||
333 | { | ||
334 | chLastCtrlMSB[status_low] = d2; | ||
306 | return; | 335 | return; |
307 | } | 336 | } |
308 | 337 | ||
diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c index 7ae7a78583..3c60d9bd82 100644 --- a/apps/plugins/midi/synth.c +++ b/apps/plugins/midi/synth.c | |||
@@ -68,6 +68,8 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig) | |||
68 | chPBDepth[a]=2; /* Default bend value is 2 */ | 68 | chPBDepth[a]=2; /* Default bend value is 2 */ |
69 | chPBNoteOffset[a]=0; /* No offset */ | 69 | chPBNoteOffset[a]=0; /* No offset */ |
70 | chPBFractBend[a]=65536; /* Center.. no bend */ | 70 | chPBFractBend[a]=65536; /* Center.. no bend */ |
71 | chLastCtrlMSB[a]=0; /* Set to pitch bend depth */ | ||
72 | chLastCtrlLSB[a]=0; /* Set to pitch bend depth */ | ||
71 | } | 73 | } |
72 | for(a=0; a<128; a++) | 74 | for(a=0; a<128; a++) |
73 | { | 75 | { |