ref: 75686444e07d768ce76c383ba434fdeb55c6c13d
dir: /dsp/piano.h/
//Parameters for piano.dsp //©Romain Michon (rmichon@ccrma.stanford.edu), 2011 //licence: FAUST-STK // translated to C static double lookupValue(double *points, int numpoints, double x) { // Note: Assumes points are monotonically increasing in X! int i=0; while (x>points[i*2] && i<numpoints) i++; if (i==0) return points[1]; if (i>=numpoints) return points[(numpoints-1)*2+1]; double ratio = (x - points[(i-1)*2]) / (points[i*2] - points[(i-1)*2]); return points[(i-1)*2+1]*(1-ratio) + points[i*2+1]*(ratio); } #define lookup(t,x) lookupValue(t, nelem(t)/2, x) /* PianoDriver.sb */ static double noteOffDelayTime[] = { 89.000,3.000, 93.000,2.000, 95.000,1.500, 99.782,1.020, 108.000,0.300, }; /* pianoDriverC.sb */ /* Coupling Filter */ static double singleStringDecayRate[] = { 21.000,-1.500, 24.000,-1.500, 28.000,-1.500, 29.000,-6.000, 36.000,-6.000, 42.000,-6.100, 48.000,-7.000, 52.836,-7.000, 60.000,-7.300, 66.000,-7.700, 72.000,-8.000, 78.000,-8.800, 84.000,-10.000, 88.619,-11.215, 92.368,-12.348, 95.684,-13.934, 99.000,-15.000 }; static double singleStringZero[] = { 21.000,-1.000, 24.000,-1.000, 28.000,-1.000, 29.000,-1.000, 32.534,-1.000, 36.000,-0.700, 42.000,-0.400, 48.000,-0.200, 54.000,-0.120, 60.000,-0.080, 66.000,-0.070, 72.000,-0.070, 79.000,-0.065, 84.000,-0.063, 88.000,-0.060, 96.000,-0.050, 99.000,-0.050 }; static double singleStringPole[] = { 21.000,0.350, 24.604,0.318, 26.335,0.279, 28.000,0.250, 32.000,0.150, 36.000,0.000, 42.000,0.000, 48.000,0.000, 54.000,0.000, 60.000,0.000, 66.000,0.000, 72.000,0.000, 76.000,0.000, 84.000,0.000, 88.000,0.000, 96.000,0.000, 99.000,0.000 }; static double releaseLoopGain[] = { 21.000,0.865, 24.000,0.880, 29.000,0.896, 36.000,0.910, 48.000,0.920, 60.000,0.950, 72.000,0.965, 84.000,0.988, 88.000,0.997, 99.000,0.988 }; static double detuningHz[] = { 21.000,0.003, 24.000,0.003, 28.000,0.003, 29.000,0.060, 31.000,0.100, 36.000,0.110, 42.000,0.120, 48.000,0.200, 54.000,0.200, 60.000,0.250, 66.000,0.270, 72.232,0.300, 78.000,0.350, 84.000,0.500, 88.531,0.582, 92.116,0.664, 95.844,0.793, 99.000,1.000 }; static double stiffnessCoefficient[] = { 21.000,-0.850, 23.595,-0.850, 27.055,-0.830, 29.000,-0.700, 37.725,-0.516, 46.952,-0.352, 60.000,-0.250, 73.625,-0.036, 93.810,-0.006, 99.000,1.011 }; static double strikePosition[] = { 21.000,0.050, 24.000,0.050, 28.000,0.050, 35.000,0.050, 41.000,0.050, 42.000,0.125, 48.000,0.125, 60.000,0.125, 72.000,0.125, 84.000,0.125, 96.000,0.125, 99.000,0.125 }; static double EQGain[] = { 21.000,2.000, 24.000,2.000, 28.000,2.000, 30.000,2.000, 35.562,1.882, 41.000,1.200, 42.000,0.600, 48.000,0.500, 54.000,0.500, 59.928,0.502, 66.704,0.489, 74.201,0.477, 91.791,1.000, 99.000,1.000 }; static double EQBandwidthFactor[] = { 21.000,5.000, 24.112,5.000, 28.000,5.000, 35.000,4.956, 41.000,6.000, 42.000,2.000, 48.773,1.072, 57.558,1.001, 63.226,1.048, 69.178,1.120, 72.862,1.525, 80.404,2.788, 97.659,1.739 }; /* PianoDriverA */ /* HammerFilter */ static double loudPole[] = { 21.000,0.875, 23.719,0.871, 27.237,0.836, 28.996,0.828, 32.355,0.820, 36.672,0.816, 40.671,0.820, 45.788,0.812, 47.867,0.812, 54.000,0.810, 60.000,0.800, 66.000,0.800, 72.000,0.810, 78.839,0.824, 84.446,0.844, 89.894,0.844, 96.463,0.848, 103.512,0.840, 107.678,0.840 }; static double softPole[] = { 21.000,0.990, 24.000,0.990, 28.000,0.990, 29.000,0.990, 36.000,0.990, 42.000,0.990, 48.000,0.985, 54.000,0.970, 60.000,0.960, 66.000,0.960, 72.000,0.960, 78.000,0.970, 84.673,0.975, 91.157,0.990, 100.982,0.970, 104.205,0.950 }; static double normalizedVelocity[] = { 0.000,0.000, 0.170,0.318, 0.316,0.546, 0.460,0.709, 0.599,0.825, 0.717,0.894, 0.841,0.945, 1.000,1.000 }; static double loudGain[] = { 21.873,0.891, 25.194,0.870, 30.538,0.848, 35.448,0.853, 41.513,0.842, 47.434,0.826, 53.644,0.820, 60.720,0.815, 65.630,0.820, 72.995,0.853, 79.060,0.920, 85.270,1.028, 91.624,1.247, 95.668,1.296, 99.000,1.300, 100.000,1.100 }; static double softGain[] = { 20.865,0.400, 22.705,0.400, 25.960,0.400, 28.224,0.400, 31.196,0.400, 36.715,0.400, 44.499,0.400, 53.981,0.400, 60.000,0.350, 66.000,0.350, 72.661,0.350, 81.435,0.430, 88.311,0.450, 93.040,0.500, 96.434,0.500 }; /* Soundboard */ static double sustainPedalLevel[] = { 21.000,0.050, 24.000,0.050, 31.000,0.030, 36.000,0.025, 48.000,0.010, 60.000,0.005, 66.000,0.003, 72.000,0.002, 78.000,0.002, 84.000,0.003, 90.000,0.003, 96.000,0.003, 108.000,0.002 }; static double DryTapAmpT60[] = { 21.001,0.491, 26.587,0.498, 34.249,0.470, 40.794,0.441, 47.977,0.392, 55.000,0.370, 60.000,0.370, 66.000,0.370, 71.934,0.370, 78.000,0.370, 83.936,0.390, 88.557,0.387, 92.858,0.400, 97.319,0.469, 102.400,0.500, 107.198,0.494 }; static double DryTapAmpCurrent = 0.15; static double DCBa1[] = { 21.000,-0.999, 24.000,-0.999, 30.000,-0.999, 36.000,-0.999, 42.000,-0.999, 48.027,-0.993, 60.000,-0.995, 72.335,-0.960, 78.412,-0.924, 84.329,-0.850, 87.688,-0.770, 91.000,-0.700, 92.000,-0.910, 96.783,-0.850, 99.000,-0.800, 100.000,-0.850, 104.634,-0.700, 107.518,-0.500 }; /* pianoDriverB */ /* High Notes */ static double secondStageAmpRatio[] = { 82.277,-18.508, 88.000,-30.000, 90.000,-30.000, 93.451,-30.488, 98.891,-30.633, 107.573,-30.633 }; static double r1_1db[] = { 100.000,-75.000, 103.802,-237.513, 108.000,-400.000 }; static double r1_2db[] = { 98.388,-16.562, 100.743,-75.531, 103.242,-154.156, 108.000,-300.000 }; double r2db[2*2] = { 100.000,-115.898, 107.858,-250.000 }; double r3db[2*2] = { 100.000,-150.000, 108.000,-400.000 }; double secondPartialFactor[2*2] = { 88.000,2.000, 108.000,2.100 }; double thirdPartialFactor[2*2] = { 88.000,3.100, 108.000,3.100 }; double bq4_gEarBalled[6*2] = { 100.000,0.040, 102.477,0.100, 104.518,0.300, 106.000,0.500, 107.000,1.000, 108.000,1.500 }; #define getValueDryTapAmpT60(x) lookup(DryTapAmpT60, x) #define getValueSustainPedalLevel(x) lookup(sustainPedalLevel, x) #define getValueLoudPole(x) lookup(loudPole, x) #define getValuePoleValue(x) lookup(poleValue, x) #define getValueLoudGain(x) lookup(loudGain, x) #define getValueSoftGain(x) lookup(softGain, x) #define getValueDCBa1(x) lookup(DCBa1, x) #define getValuer1_1db(x) lookup(r1_1db, x) #define getValuer1_2db(x) lookup(r1_2db, x) #define getValuer2db(x) lookup(r2db, x) #define getValuer3db(x) lookup(r3db, x) #define getValueSecondStageAmpRatio(x) lookup(secondStageAmpRatio, x) #define getValueSecondPartialFactor(x) lookup(secondPartialFactor, x) #define getValueThirdPartialFactor(x) lookup(thirdPartialFactor, x) #define getValueBq4_gEarBalled(x) lookup(bq4_gEarBalled, x) #define getValueStrikePosition(x) lookup(strikePosition, x) #define getValueEQBandWidthFactor(x) lookup(EQBandwidthFactor, x) #define getValueEQGain(x) lookup(EQGain, x) #define getValueDetuningHz(x) lookup(detuningHz, x) #define getValueSingleStringDecayRate(x) lookup(singleStringDecayRate, x) #define getValueSingleStringZero(x) lookup(singleStringZero, x) #define getValueSingleStringPole(x) lookup(singleStringPole, x) #define getValueStiffnessCoefficient(x) lookup(stiffnessCoefficient, x) #define getValueReleaseLoopGain(x) lookup(releaseLoopGain, x) //Harpsichord static double loopFilterb0[] = { 35.000,0.94373, 36.000,0.94731, 46.000,0.94731, 47.000,0.96202, 52.000,0.96202, 53.000,0.97477, 58.000,0.97477, 59.000,0.97733, 64.000,0.97733, 65.000,0.97971, 70.000,0.97971, 71.000,0.97971, 76.000,0.97971, 77.000,0.98698, 82.000,0.98698, 83.000,0.98462, 86.000,0.98462, 87.000,0.98611, }; static double loopFilterb1[] = { 35.000,0.60010, 36.000,-0.59124, 46.000,-0.59124, 47.000,-0.21243, 52.000,-0.21243, 53.000,-0.39280, 58.000,-0.39280, 59.000,-0.48307, 64.000,-0.48307, 65.000,0.51965, 70.000,0.51965, 71.000,0.51965, 76.000,0.51965, 77.000,-0.42463, 82.000,-0.42463, 83.000,0.85655, 86.000,0.85655, 87.000,0.68851, }; static double loopFilterb2[] = { 35.000,-0.00360, 36.000,-0.12249, 46.000,-0.12249, 47.000,-0.16044, 52.000,-0.16044, 53.000,-0.21680, 58.000,-0.21680, 59.000,-0.16346, 64.000,-0.16346, 65.000,0.22162, 70.000,0.22162, 71.000,0.22162, 76.000,0.22162, 77.000,-0.14973, 82.000,-0.14973, 83.000,0.24937, 86.000,0.24937, 87.000,0.14838, }; static double loopFiltera1[] = { 35.000,0.5941, 36.000,-0.65928, 46.000,-0.65928, 47.000,-0.24222, 52.000,-0.24222, 53.000,-0.41402, 58.000,-0.41402, 59.000,-0.50837, 64.000,-0.50837, 65.000,0.51263, 70.000,0.51263, 71.000,0.51263, 76.000,0.51263, 77.000,-0.43976, 82.000,-0.43976, 83.000,0.85396, 86.000,0.85396, 87.000,0.68332, }; static double loopFiltera2[] = { 35.000,-0.02641, 36.000,-0.10275, 46.000,-0.10275, 47.000,-0.15842, 52.000,-0.15842, 53.000,-0.21653, 58.000,-0.21653, 59.000,-0.15833, 64.000,-0.15833, 65.000,0.22025, 70.000,0.22025, 71.000,0.22025, 76.000,0.22025, 77.000,-0.14583, 82.000,-0.14583, 83.000,0.24405, 86.000,0.24405, 87.000,0.14370, }; #define getValueLoopFilterb0(x) lookup(LoopFilterb0, x) #define getValueLoopFilterb1(x) lookup(LoopFilterb1, x) #define getValueLoopFilterb2(x) lookup(LoopFilterb2, x) #define getValueLoopFiltera1(x) lookup(LoopFiltera1, x) #define getValueLoopFiltera2(x) lookup(LoopFiltera2, x) //bass static double bassLoopFilterb0[] = { 24.000,0.54355, 26.000,0.54355, 27.000,0.55677, 29.000,0.55677, 32.000,0.55677, 33.000,0.83598, 36.000,0.83598, 43.000,0.83598, 44.000,0.88292, 48.000,0.88292, 51.000,0.88292, 52.000,0.77805, 54.000,0.77805, 57.000,0.77805, 58.000,0.91820, 60.000,0.91820, 61.000,0.91820, 63.000,0.94594, 65.000,0.91820, }; static double bassLoopFilterb1[] = { 24.000,-0.36586, 26.000,-0.36586, 27.000,-0.37628, 29.000,-0.37628, 32.000,-0.37628, 33.000,-0.60228, 36.000,-0.60228, 43.000,-0.60228, 44.000,-0.65721, 48.000,-0.65721, 51.000,-0.65721, 52.000,-0.51902, 54.000,-0.51902, 57.000,-0.51902, 58.000,-0.80765, 60.000,-0.80765, 61.000,-0.80765, 63.000,-0.83230, 65.000,-0.83230, }; static double bassLoopFiltera1[] = { 24.000,-0.81486, 26.000,-0.81486, 27.000,-0.81147, 29.000,-0.81147, 32.000,-0.81147, 33.000,-0.76078, 36.000,-0.76078, 43.000,-0.76078, 44.000,-0.77075, 48.000,-0.77075, 51.000,-0.77075, 52.000,-0.73548, 54.000,-0.73548, 57.000,-0.73548, 58.000,-0.88810, 60.000,-0.88810, 61.000,-0.88810, 63.000,-0.88537, 65.000,-0.88537, }; #define getValueBassLoopFilterb0(x) lookup(BassLoopFilterb0, x) #define getValueBassLoopFilterb1(x) lookup(BassLoopFilterb1, x) #define getValueBassLoopFiltera1(x) lookup(BassLoopFiltera1, x)