diff options
-rw-r--r-- | apps/plugins/midi/guspat.c | 39 | ||||
-rw-r--r-- | apps/plugins/midi/guspat.h | 2 | ||||
-rw-r--r-- | apps/plugins/midi/sequencer.c | 6 |
3 files changed, 28 insertions, 19 deletions
diff --git a/apps/plugins/midi/guspat.c b/apps/plugins/midi/guspat.c index c5b5832ddb..f650555520 100644 --- a/apps/plugins/midi/guspat.c +++ b/apps/plugins/midi/guspat.c | |||
@@ -22,21 +22,30 @@ | |||
22 | #include "guspat.h" | 22 | #include "guspat.h" |
23 | #include "midiutil.h" | 23 | #include "midiutil.h" |
24 | 24 | ||
25 | /* This came from one of the Gravis documents */ | 25 | /* Note frequencies in milliHz, base A = 440000 |
26 | const uint32_t gustable[]= | 26 | * Calculated using: |
27 | * double base_a=440000; | ||
28 | * double offset; | ||
29 | * for(offset=-69;offset<=58;offset++) | ||
30 | * { | ||
31 | * int value = (int)round(base_a*pow(2,offset/12)); | ||
32 | * printf("%d, ",value); | ||
33 | * } | ||
34 | */ | ||
35 | const uint32_t freqtable[]= | ||
27 | { | 36 | { |
28 | 8175, 8661, 9177, 9722, 10300, 10913, 11562, 12249, 12978, 13750, 14567, 15433, | 37 | /* C, C#, D, D#, E, F, F#, G, G#, A, A#, B */ |
29 | 16351, 17323, 18354, 19445, 20601, 21826, 23124, 24499, 25956, 27500, 29135, 30867, | 38 | 8176, 8662, 9177, 9723, 10301, 10913, 11562, 12250, 12978, 13750, 14568, 15434, |
30 | 32703, 34647, 36708, 38890, 41203, 43653, 46249, 48999, 51913, 54999, 58270, 61735, | 39 | 16352, 17324, 18354, 19445, 20602, 21827, 23125, 24500, 25957, 27500, 29135, 30868, |
31 | 65406, 69295, 73416, 77781, 82406, 87306, 92498, 97998, 103826, 109999, 116540, 123470, | 40 | 32703, 34648, 36708, 38891, 41203, 43654, 46249, 48999, 51913, 55000, 58270, 61735, |
32 | 130812, 138591, 146832, 155563, 164813, 174614, 184997, 195997, 207652, 219999, 233081, 246941, | 41 | 65406, 69296, 73416, 77782, 82407, 87307, 92499, 97999, 103826, 110000, 116541, 123471, |
33 | 261625, 277182, 293664, 311126, 329627, 349228, 369994, 391995, 415304, 440000, 466163, 493883, | 42 | 130813, 138591, 146832, 155563, 164814, 174614, 184997, 195998, 207652, 220000, 233082, 246942, |
34 | 523251, 554365, 587329, 622254, 659255, 698456, 739989, 783991, 830609, 880000, 932328, 987767, | 43 | 261626, 277183, 293665, 311127, 329628, 349228, 369994, 391995, 415305, 440000, 466164, 493883, |
35 | 1046503, 1108731, 1174660, 1244509, 1318511, 1396914, 1479979, 1567983, 1661220, 1760002, 1864657, 1975536, | 44 | 523251, 554365, 587330, 622254, 659255, 698456, 739989, 783991, 830609, 880000, 932328, 987767, |
36 | 2093007, 2217464, 2349321, 2489019, 2637024, 2793830, 2959960, 3135968, 3322443, 3520006, 3729316, 3951073, | 45 | 1046502, 1108731, 1174659, 1244508, 1318510, 1396913, 1479978, 1567982, 1661219, 1760000, 1864655, 1975533, |
37 | 4186073, 4434930, 4698645, 4978041, 5274051, 5587663, 5919922, 6271939, 6644889, 7040015, 7458636, 7902150, | 46 | 2093005, 2217461, 2349318, 2489016, 2637020, 2793826, 2959955, 3135963, 3322438, 3520000, 3729310, 3951066, |
38 | 8372036, 8869863, 9397293, 9956085, 10548105, 11175328, 11839847, 12543881 | 47 | 4186009, 4434922, 4698636, 4978032, 5274041, 5587652, 5919911, 6271927, 6644875, 7040000, 7458620, 7902133, |
39 | }; | 48 | 8372018, 8869844, 9397273, 9956063, 10548082, 11175303, 11839822, 12543854 }; |
40 | 49 | ||
41 | static unsigned int readWord(int file) | 50 | static unsigned int readWord(int file) |
42 | { | 51 | { |
@@ -141,7 +150,7 @@ static struct GWaveform * loadWaveform(int file) | |||
141 | static int selectWaveform(struct GPatch * pat, int midiNote) | 150 | static int selectWaveform(struct GPatch * pat, int midiNote) |
142 | { | 151 | { |
143 | /* We divide by 100 here because everyone's freq formula is slightly different */ | 152 | /* We divide by 100 here because everyone's freq formula is slightly different */ |
144 | unsigned int tabFreq = gustable[midiNote]/100; /* Comparison */ | 153 | unsigned int tabFreq = freqtable[midiNote]/100; /* Comparison */ |
145 | unsigned int a=0; | 154 | unsigned int a=0; |
146 | for(a=0; a<pat->numWaveforms; a++) | 155 | for(a=0; a<pat->numWaveforms; a++) |
147 | { | 156 | { |
diff --git a/apps/plugins/midi/guspat.h b/apps/plugins/midi/guspat.h index ebb5f227d7..428d99ba0e 100644 --- a/apps/plugins/midi/guspat.h +++ b/apps/plugins/midi/guspat.h | |||
@@ -19,7 +19,7 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | extern const uint32_t gustable[]; | 22 | extern const uint32_t freqtable[]; |
23 | 23 | ||
24 | struct GWaveform | 24 | struct GWaveform |
25 | { | 25 | { |
diff --git a/apps/plugins/midi/sequencer.c b/apps/plugins/midi/sequencer.c index e860dbd2dd..d35a057c32 100644 --- a/apps/plugins/midi/sequencer.c +++ b/apps/plugins/midi/sequencer.c | |||
@@ -148,12 +148,12 @@ static void findDelta(struct SynthObject * so, int ch, int note) | |||
148 | 148 | ||
149 | /* | 149 | /* |
150 | Old formula: | 150 | Old formula: |
151 | delta = (((gustable[note+chPBNoteOffset[ch]]<<FRACTSIZE) / (wf->rootFreq)) * wf->sampRate / (SAMPLE_RATE)); | 151 | delta = (((freqtable[note+chPBNoteOffset[ch]]<<FRACTSIZE) / (wf->rootFreq)) * wf->sampRate / (SAMPLE_RATE)); |
152 | 152 | ||
153 | Plus some pitch stuff. See old SVN for how it used to be | 153 | Plus some pitch stuff. See old SVN for how it used to be |
154 | */ | 154 | */ |
155 | 155 | ||
156 | delta = (((gustable[note+chPBNoteOffset[ch]]))); /* anywhere from 8000 to 8000000 */ | 156 | delta = (((freqtable[note+chPBNoteOffset[ch]]))); /* anywhere from 8000 to 8000000 */ |
157 | delta = delta * wf->sampRate; /* approx 20000 - 44000 but can vary with tuning */ | 157 | delta = delta * wf->sampRate; /* approx 20000 - 44000 but can vary with tuning */ |
158 | delta = (delta * chPBFractBend[ch]); /* approx 60000 - 70000 */ | 158 | delta = (delta * chPBFractBend[ch]); /* approx 60000 - 70000 */ |
159 | delta = delta / (SAMPLE_RATE); /* 44100 or 22050 */ | 159 | delta = delta / (SAMPLE_RATE); /* 44100 or 22050 */ |
@@ -263,7 +263,7 @@ static inline void pressNote(int ch, int note, int vol) | |||
263 | 263 | ||
264 | struct GWaveform * wf = drumSet[note]->waveforms[0]; | 264 | struct GWaveform * wf = drumSet[note]->waveforms[0]; |
265 | voices[a].wf = wf; | 265 | voices[a].wf = wf; |
266 | voices[a].delta = (((gustable[note]<<FRACTSIZE) / wf->rootFreq) * wf->sampRate / SAMPLE_RATE); | 266 | voices[a].delta = (((freqtable[note]<<FRACTSIZE) / wf->rootFreq) * wf->sampRate / SAMPLE_RATE); |
267 | if (wf->mode & 28) | 267 | if (wf->mode & 28) |
268 | // midi_debug("\nWoah, a drum patch has a loop. Stripping the loop..."); | 268 | // midi_debug("\nWoah, a drum patch has a loop. Stripping the loop..."); |
269 | wf->mode = wf->mode & (255-28); | 269 | wf->mode = wf->mode & (255-28); |