1.在做项目的过程中,对于volume 我们有一个volume curve,就是 0~63 step,每个step对应一个dB值,例如0step对应-90dB, 63 step对应0dB。关于这个0dB,是由客户规定的,最大的输出是9V,20W,阻抗4Ω。dB一般是负值,dBa是由分贝仪测出来的,dBa有一套专门的标准来测
2.Balance(左右) 和 Fader(前后)是用来调节左右前后音量的, 调节Balance,对左边或者邮编的dB进行减少,Fader调前后,可以见下图
3.Loudness,对于当前音量,有一个低频/高频的音量补偿,直接上代码,
; /*take care of this value, volume table boost 18db for each step, so when calculate the volume table + LoudnessOffset, need attentuate 18db, so define the init value to -18*/ ; static float OffsetPoints[CalNofPoints] = {0.0F, -10.0F, -20.0F, -30.0F, -40.0F, -50.0F, -60.0F, -70.0F,-80.0F, -90.0F, -90.0F}; static float BassBoostValues[CalNofPoints] = {0.0F, 0.0F, 0.0F, 2.0F, 5.0F, 6.0F, 7.0F, 12.0F, 13.5F, 15.0F, 15.0F}; static float BassFilterFrequence[CalNofPoints] = {80.0F, 80.0F, 80.0F, 80.0F, 100.0F, 200.0F, 250.0F, 350.0F, 400.0F, 400.0F, 400.0F}; static float TrebleBoostValues[CalNofPoints] = {0.0F, 0.0F, 0.0F, 1.0F, 1.5F, 2.5F, 3.5F, 4.0F, 4.5F, 5.0F, 5.0F}; static float TrebleFilterFrequence[CalNofPoints] = {12000.0F, 12000.0F, 12000.0F, 12000.0F, 12000.0F, 11000.0F, 10000.0F, 9000.0F, 8000.0F, 7000.0F, 7000.0F}; float interpolate(float const x, uint_t const nof, float const xValues[], float const yValues[])//return y { float yRetval = 0.0F; //yValues are expected to be constant rising or falling //nof at least 2 otherwise there is nothing to interpolate <=nof) { uint_t ; ] < xValues[last]; //check lower limit ])) || ((!rising) && (x > xValues[])) ) { yRetval = yValues[]; } //check upper limit else if ( ( (rising) && (x > xValues[last])) || ((!rising) && (x < xValues[last])) ) { yRetval = yValues[last]; } else//interpolate { //find index for x value uint_t index = ; ;i<last;i++) { ]) ) ||( (!rising) && (xValues[i] >= x) &&(x >= xValues[i+]) ) ) { index = i; break; } } //interpolate ]; ]; //check xDiff not 0 if (fabs(xDiff) <= FLT_EPSILON) { yRetval = yValues[index]; } else//xDiff not 0 -> calculate y { const float gradient = yDiff / xDiff; const float yOffset = (x-xValues[index]) * gradient; yRetval = yValues[index] + yOffset; } } }//check nof return yRetval; } bool_t CavDiranaRoutingCfg::getLoudnessCurveBoost(uint16_t filterID, uint16_t cfgID, float volume, float& loudnessBoost) const { bool_t retval = true; if(m_isLoudnessEnable == true) { ; EFilterID filtertype = static_cast<EFilterID>(filterID); loudnessBoost = ; //volume -> loudnessBoost OverallOffset = LoudnessOffset + volume; if (filtertype == FILTER_LOUDNESS_BASS) { loudnessBoost = interpolate(OverallOffset, CalNofPoints, OffsetPoints, BassBoostValues); } else if (filtertype == FILTER_LOUDNESS_TREBLE) { loudnessBoost = interpolate(OverallOffset, CalNofPoints, OffsetPoints, TrebleBoostValues); } } else { retval = false; } return retval; } bool_t CavDiranaRoutingCfg::getLoudnessCurveFilterPrm(uint16_t filterID, uint16_t cfgID, float volume, float& frequency, float& quality) const { bool_t retval = true; if(m_isLoudnessEnable == true) { ; EFilterID filtertype = static_cast<EFilterID>(filterID); quality = ; frequency = ; //volume -> bass filterprm OverallOffset = LoudnessOffset + volume; if (filtertype == FILTER_LOUDNESS_BASS) { frequency = interpolate(OverallOffset, CalNofPoints, OffsetPoints, BassFilterFrequence); } else if (filtertype == FILTER_LOUDNESS_TREBLE) { frequency = interpolate(OverallOffset, CalNofPoints, OffsetPoints, TrebleFilterFrequence); } } else { retval = false; } return retval; }
4.Adjustable Bass, Midrange, and Treble tone controls. 是对低频中频高频的一个调节
The bass tone control shall have the following characteristics:
fcenter = 80Hz
Filter: Shelving type, 1st order
The midrange tone control shall have the following characteristics:
fcenter = 775Hz
Filter: Peaking type, 2nd order, Q value calibratable with initial value of 1.1
The treble tone control shall have the following characteristics:
fcenter = 8kHz
Filter: Shelving type, 1st order
5.Source Offset
按照需求,对于不同的source,有不同的音量输出要求,在原来的音量上面进行一个dB值的调整