summaryrefslogtreecommitdiff
path: root/apps/plugins/midi/sequencer.c
diff options
context:
space:
mode:
authorStepan Moskovchenko <stevenm@rockbox.org>2007-10-15 05:11:37 +0000
committerStepan Moskovchenko <stevenm@rockbox.org>2007-10-15 05:11:37 +0000
commit1515ff852224c822a6d3db8c458eab2c9037704f (patch)
treee427fbec1b397d18abffc12b7fe74e67c2cad807 /apps/plugins/midi/sequencer.c
parent99f955088149d5938ce4c9ca5624377f464b1380 (diff)
downloadrockbox-1515ff852224c822a6d3db8c458eab2c9037704f.tar.gz
rockbox-1515ff852224c822a6d3db8c458eab2c9037704f.zip
MIDI: At long last, though quick and dirty, pitch bend depth! Or, I think it works. Tested on two
files. Let me know if anyone discovers any problems with this. This commit also includes Nils's synth loop optimization patch. I hope committing it does not cause problems. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15112 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/midi/sequencer.c')
-rw-r--r--apps/plugins/midi/sequencer.c78
1 files changed, 74 insertions, 4 deletions
diff --git a/apps/plugins/midi/sequencer.c b/apps/plugins/midi/sequencer.c
index 1a00c078c6..638c9ba43a 100644
--- a/apps/plugins/midi/sequencer.c
+++ b/apps/plugins/midi/sequencer.c
@@ -75,7 +75,60 @@ long pitchTbl[]=
75}; 75};
76*/ 76*/
77 77
78
79/* 512 entries here */
80/*
81 for i=0:512, fprintf('%d,', round(2^16*2^((i-256)/1536))); end
82*/
83
78const uint32_t pitchTbl[] ICONST_ATTR={ 84const uint32_t pitchTbl[] ICONST_ATTR={
85 61858,61872,61886,61900,61914,61928,61942,61956,61970,61983,61997,62011,
86 62025,62039,62053,62067,62081,62095,62109,62124,62138,62152,62166,62180,
87 62194,62208,62222,62236,62250,62264,62278,62292,62306,62320,62334,62348,
88 62362,62376,62390,62404,62419,62433,62447,62461,62475,62489,62503,62517,
89 62531,62545,62560,62574,62588,62602,62616,62630,62644,62658,62673,62687,
90 62701,62715,62729,62743,62757,62772,62786,62800,62814,62828,62843,62857,
91 62871,62885,62899,62913,62928,62942,62956,62970,62984,62999,63013,63027,
92 63041,63056,63070,63084,63098,63112,63127,63141,63155,63169,63184,63198,
93 63212,63227,63241,63255,63269,63284,63298,63312,63326,63341,63355,63369,
94 63384,63398,63412,63427,63441,63455,63470,63484,63498,63512,63527,63541,
95 63555,63570,63584,63599,63613,63627,63642,63656,63670,63685,63699,63713,
96 63728,63742,63757,63771,63785,63800,63814,63829,63843,63857,63872,63886,
97 63901,63915,63929,63944,63958,63973,63987,64002,64016,64030,64045,64059,
98 64074,64088,64103,64117,64132,64146,64161,64175,64190,64204,64219,64233,
99 64248,64262,64277,64291,64306,64320,64335,64349,64364,64378,64393,64407,
100 64422,64436,64451,64465,64480,64494,64509,64524,64538,64553,64567,64582,
101 64596,64611,64626,64640,64655,64669,64684,64699,64713,64728,64742,64757,
102 64772,64786,64801,64815,64830,64845,64859,64874,64889,64903,64918,64933,
103 64947,64962,64976,64991,65006,65020,65035,65050,65065,65079,65094,65109,
104 65123,65138,65153,65167,65182,65197,65211,65226,65241,65256,65270,65285,
105 65300,65315,65329,65344,65359,65374,65388,65403,65418,65433,65447,65462,
106 65477,65492,65506,65521,65536,65551,65566,65580,65595,65610,65625,65640,
107 65654,65669,65684,65699,65714,65729,65743,65758,65773,65788,65803,65818,
108 65832,65847,65862,65877,65892,65907,65922,65936,65951,65966,65981,65996,
109 66011,66026,66041,66056,66071,66085,66100,66115,66130,66145,66160,66175,
110 66190,66205,66220,66235,66250,66265,66280,66294,66309,66324,66339,66354,
111 66369,66384,66399,66414,66429,66444,66459,66474,66489,66504,66519,66534,
112 66549,66564,66579,66594,66609,66624,66639,66654,66670,66685,66700,66715,
113 66730,66745,66760,66775,66790,66805,66820,66835,66850,66865,66880,66896,
114 66911,66926,66941,66956,66971,66986,67001,67016,67032,67047,67062,67077,
115 67092,67107,67122,67137,67153,67168,67183,67198,67213,67228,67244,67259,
116 67274,67289,67304,67320,67335,67350,67365,67380,67395,67411,67426,67441,
117 67456,67472,67487,67502,67517,67532,67548,67563,67578,67593,67609,67624,
118 67639,67655,67670,67685,67700,67716,67731,67746,67761,67777,67792,67807,
119 67823,67838,67853,67869,67884,67899,67915,67930,67945,67961,67976,67991,
120 68007,68022,68037,68053,68068,68083,68099,68114,68129,68145,68160,68176,
121 68191,68206,68222,68237,68252,68268,68283,68299,68314,68330,68345,68360,
122 68376,68391,68407,68422,68438,68453,68468,68484,68499,68515,68530,68546,
123 68561,68577,68592,68608,68623,68639,68654,68670,68685,68701,68716,68732,
124 68747,68763,68778,68794,68809,68825,68840,68856,68871,68887,68902,68918,
125 68933,68949,68965,68980,68996,69011,69027,69042,69058,69074,69089,69105,
126 69120,69136,69152,69167,69183,69198,69214,69230,69245,69261,69276,69292,
127 69308,69323,69339,69355,69370,69386,69402,69417,69433
128
129};
130
131/*
79 58386,58412,58439,58465,58491,58518,58544,58571,58597,58624,58650,58676, 132 58386,58412,58439,58465,58491,58518,58544,58571,58597,58624,58650,58676,
80 58703,58729,58756,58782,58809,58836,58862,58889,58915,58942,58968,58995, 133 58703,58729,58756,58782,58809,58836,58862,58889,58915,58942,58968,58995,
81 59022,59048,59075,59102,59128,59155,59182,59208,59235,59262,59289,59315, 134 59022,59048,59075,59102,59128,59155,59182,59208,59235,59262,59289,59315,
@@ -119,7 +172,10 @@ const uint32_t pitchTbl[] ICONST_ATTR={
119 72507,72540,72573,72605,72638,72671,72704,72736,72769,72802,72835,72868, 172 72507,72540,72573,72605,72638,72671,72704,72736,72769,72802,72835,72868,
120 72901,72934,72967,72999,73032,73065,73098,73131,73164,73197,73230,73264, 173 72901,72934,72967,72999,73032,73065,73098,73131,73164,73197,73230,73264,
121 73297,73330,73363,73396,73429,73462,73495,73528 174 73297,73330,73363,73396,73429,73462,73495,73528
122}; 175};*/
176
177
178
123 179
124static void findDelta(struct SynthObject * so, int ch, int note) 180static void findDelta(struct SynthObject * so, int ch, int note)
125{ 181{
@@ -128,8 +184,15 @@ static void findDelta(struct SynthObject * so, int ch, int note)
128 so->wf=wf; 184 so->wf=wf;
129 unsigned int delta= 0; 185 unsigned int delta= 0;
130 186
131 delta = (((gustable[note]<<FRACTSIZE) / (wf->rootFreq)) * wf->sampRate / (SAMPLE_RATE)); 187 int totalBend = (chPW[ch]-256) * chPBDepth[ch];
132 delta = (delta * pitchTbl[chPW[ch]])>> 16; 188
189 int noteOffset = totalBend >> 8;
190
191 int pitchOffset = totalBend - (noteOffset<<8);
192
193
194 delta = (((gustable[note+noteOffset]<<FRACTSIZE) / (wf->rootFreq)) * wf->sampRate / (SAMPLE_RATE));
195 delta = (delta * pitchTbl[pitchOffset+256])>> 16;
133 196
134 so->delta = delta; 197 so->delta = delta;
135} 198}
@@ -280,6 +343,13 @@ static void sendEvent(struct Event * ev)
280 chPan[status_low]=d2; 343 chPan[status_low]=d2;
281 return; 344 return;
282 } 345 }
346 case CTRL_PWDEPTH:
347 {
348 /* TODO: Update all deltas. Is this really needed? */
349 chPBDepth[status_low] = d2;
350 return;
351 }
352
283 } 353 }
284 break; 354 break;
285 355
@@ -293,7 +363,7 @@ static void sendEvent(struct Event * ev)
293 case 0: /* Release by vol=0 */ 363 case 0: /* Release by vol=0 */
294 releaseNote(status_low, d1); 364 releaseNote(status_low, d1);
295 return; 365 return;
296 366
297 default: 367 default:
298 pressNote(status_low, d1, d2); 368 pressNote(status_low, d1, d2);
299 return; 369 return;