|
在这里看到的这个基于声卡rlc表 http://www.ourdev.cn/bbs/bbs_content.jsp?bbs_sn=3929774
看到其中的主要运算代码中,似乎只有右声道的数据参与了运算,请问他是如何计算的?:
public boolean determine(double[] valuesLeft, double[] valuesRight, int length) {
hilbert.calculate(valuesRight, length);
desired = valuesLeft;
real = hilbert.getReal();
imag = hilbert.getImag();
for(int i=0; i < length; i++){
//calculate
w0 = w0 + failure * mikro * real;
w1 = w1 + failure * mikro * imag;
res = w0 * real + w1 * imag;
failure = desired - res ;
}
calcValues();
return true;
}
public void calcValues() {
double phi = Math.atan(w1/w0)*(180/Math.PI);
impedance = Math.sqrt( Math.pow(w0*referenceR, 2) + Math.pow(w1*referenceR, 2) );
double real = impedance * Math.cos(Math.abs(phi) * Math.PI/180);
double imag = impedance * Math.sin(Math.abs(phi) * Math.PI/180);
// Typ bestimmen
if(phi < (0.0 - tolerance)) {
// Kondensator
setTyp(ComponentTyp.CAPACITOR);
setUnit(Unit.nF);
setValue(1 / (2 * Math.PI * frequency * imag) * Math.pow(10, 9));
}else if(phi > (0 + tolerance)) {
// Spule
setTyp(ComponentTyp.INDUCTOR);
setUnit(Unit.mH);
setValue((imag / (2 * Math.PI * frequency))*1000);
}else {
// Widerstand
setTyp(ComponentTyp.RESISTOR);
setUnit(Unit.Ohm);
setValue(impedance);
}
//additional infos
Map<String, Double> additionalInfos = new TreeMap<String, Double>();
additionalInfos.put("weight 0", w0);
additionalInfos.put("weight 1", w1);
additionalInfos.put("impedance", impedance);
additionalInfos.put("phi", phi);
additionalInfos.put("real", real);
additionalInfos.put("imag", imag);
additionalInfos.put("imag", imag);
setAdditonalInfos(additionalInfos);
}
public void setReferenceR(double referenceR) {
this.referenceR = referenceR;
}
public void setTolerance(double tolerance) {
this.tolerance = tolerance;
}
hilbert的几个函数:
public double[] getReal() {
return realBuffer;
}
public double[] getImag() {
return imagBuffer;
}
/**
* Calculates the real and imag Signal from the source signal
* @param sourceBuffer
* @param bufferSize
*/
public void calculate(double[] sourceBuffer, int bufferSize) {
realBuffer = new double[bufferSize];
imagBuffer = new double[bufferSize];
for(int i=0; i < (bufferSize); i++) {
realBuffer = sourceBuffer;
if(i < periodSize/4) {
imagBuffer = cacheBuffer;
}else {
imagBuffer = sourceBuffer[i - periodSize/4];
}
// cut a quarte of a period
if(i < (periodSize/4)) {
cacheBuffer = sourceBuffer[periodSize - periodSize/4 + i];
}
}
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|