From 1515ff852224c822a6d3db8c458eab2c9037704f Mon Sep 17 00:00:00 2001 From: Stepan Moskovchenko Date: Mon, 15 Oct 2007 05:11:37 +0000 Subject: 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 --- apps/plugins/midi/sequencer.c | 78 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 4 deletions(-) (limited to 'apps/plugins/midi/sequencer.c') 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[]= }; */ + +/* 512 entries here */ +/* + for i=0:512, fprintf('%d,', round(2^16*2^((i-256)/1536))); end +*/ + const uint32_t pitchTbl[] ICONST_ATTR={ + 61858,61872,61886,61900,61914,61928,61942,61956,61970,61983,61997,62011, + 62025,62039,62053,62067,62081,62095,62109,62124,62138,62152,62166,62180, + 62194,62208,62222,62236,62250,62264,62278,62292,62306,62320,62334,62348, + 62362,62376,62390,62404,62419,62433,62447,62461,62475,62489,62503,62517, + 62531,62545,62560,62574,62588,62602,62616,62630,62644,62658,62673,62687, + 62701,62715,62729,62743,62757,62772,62786,62800,62814,62828,62843,62857, + 62871,62885,62899,62913,62928,62942,62956,62970,62984,62999,63013,63027, + 63041,63056,63070,63084,63098,63112,63127,63141,63155,63169,63184,63198, + 63212,63227,63241,63255,63269,63284,63298,63312,63326,63341,63355,63369, + 63384,63398,63412,63427,63441,63455,63470,63484,63498,63512,63527,63541, + 63555,63570,63584,63599,63613,63627,63642,63656,63670,63685,63699,63713, + 63728,63742,63757,63771,63785,63800,63814,63829,63843,63857,63872,63886, + 63901,63915,63929,63944,63958,63973,63987,64002,64016,64030,64045,64059, + 64074,64088,64103,64117,64132,64146,64161,64175,64190,64204,64219,64233, + 64248,64262,64277,64291,64306,64320,64335,64349,64364,64378,64393,64407, + 64422,64436,64451,64465,64480,64494,64509,64524,64538,64553,64567,64582, + 64596,64611,64626,64640,64655,64669,64684,64699,64713,64728,64742,64757, + 64772,64786,64801,64815,64830,64845,64859,64874,64889,64903,64918,64933, + 64947,64962,64976,64991,65006,65020,65035,65050,65065,65079,65094,65109, + 65123,65138,65153,65167,65182,65197,65211,65226,65241,65256,65270,65285, + 65300,65315,65329,65344,65359,65374,65388,65403,65418,65433,65447,65462, + 65477,65492,65506,65521,65536,65551,65566,65580,65595,65610,65625,65640, + 65654,65669,65684,65699,65714,65729,65743,65758,65773,65788,65803,65818, + 65832,65847,65862,65877,65892,65907,65922,65936,65951,65966,65981,65996, + 66011,66026,66041,66056,66071,66085,66100,66115,66130,66145,66160,66175, + 66190,66205,66220,66235,66250,66265,66280,66294,66309,66324,66339,66354, + 66369,66384,66399,66414,66429,66444,66459,66474,66489,66504,66519,66534, + 66549,66564,66579,66594,66609,66624,66639,66654,66670,66685,66700,66715, + 66730,66745,66760,66775,66790,66805,66820,66835,66850,66865,66880,66896, + 66911,66926,66941,66956,66971,66986,67001,67016,67032,67047,67062,67077, + 67092,67107,67122,67137,67153,67168,67183,67198,67213,67228,67244,67259, + 67274,67289,67304,67320,67335,67350,67365,67380,67395,67411,67426,67441, + 67456,67472,67487,67502,67517,67532,67548,67563,67578,67593,67609,67624, + 67639,67655,67670,67685,67700,67716,67731,67746,67761,67777,67792,67807, + 67823,67838,67853,67869,67884,67899,67915,67930,67945,67961,67976,67991, + 68007,68022,68037,68053,68068,68083,68099,68114,68129,68145,68160,68176, + 68191,68206,68222,68237,68252,68268,68283,68299,68314,68330,68345,68360, + 68376,68391,68407,68422,68438,68453,68468,68484,68499,68515,68530,68546, + 68561,68577,68592,68608,68623,68639,68654,68670,68685,68701,68716,68732, + 68747,68763,68778,68794,68809,68825,68840,68856,68871,68887,68902,68918, + 68933,68949,68965,68980,68996,69011,69027,69042,69058,69074,69089,69105, + 69120,69136,69152,69167,69183,69198,69214,69230,69245,69261,69276,69292, + 69308,69323,69339,69355,69370,69386,69402,69417,69433 + +}; + +/* 58386,58412,58439,58465,58491,58518,58544,58571,58597,58624,58650,58676, 58703,58729,58756,58782,58809,58836,58862,58889,58915,58942,58968,58995, 59022,59048,59075,59102,59128,59155,59182,59208,59235,59262,59289,59315, @@ -119,7 +172,10 @@ const uint32_t pitchTbl[] ICONST_ATTR={ 72507,72540,72573,72605,72638,72671,72704,72736,72769,72802,72835,72868, 72901,72934,72967,72999,73032,73065,73098,73131,73164,73197,73230,73264, 73297,73330,73363,73396,73429,73462,73495,73528 -}; +};*/ + + + static void findDelta(struct SynthObject * so, int ch, int note) { @@ -128,8 +184,15 @@ static void findDelta(struct SynthObject * so, int ch, int note) so->wf=wf; unsigned int delta= 0; - delta = (((gustable[note]<rootFreq)) * wf->sampRate / (SAMPLE_RATE)); - delta = (delta * pitchTbl[chPW[ch]])>> 16; + int totalBend = (chPW[ch]-256) * chPBDepth[ch]; + + int noteOffset = totalBend >> 8; + + int pitchOffset = totalBend - (noteOffset<<8); + + + delta = (((gustable[note+noteOffset]<rootFreq)) * wf->sampRate / (SAMPLE_RATE)); + delta = (delta * pitchTbl[pitchOffset+256])>> 16; so->delta = delta; } @@ -280,6 +343,13 @@ static void sendEvent(struct Event * ev) chPan[status_low]=d2; return; } + case CTRL_PWDEPTH: + { + /* TODO: Update all deltas. Is this really needed? */ + chPBDepth[status_low] = d2; + return; + } + } break; @@ -293,7 +363,7 @@ static void sendEvent(struct Event * ev) case 0: /* Release by vol=0 */ releaseNote(status_low, d1); return; - + default: pressNote(status_low, d1, d2); return; -- cgit v1.2.3