chnepi001 发表于 2011-5-6 12:04:31

请教 声卡2-Pound RLC Meter是如何计算的?

在这里看到的这个基于声卡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;
      imagBuffer = new double;

      for(int i=0; i < (bufferSize); i++) {
            realBuffer = sourceBuffer;
            if(i < periodSize/4) {
                imagBuffer = cacheBuffer;
            }else {
                imagBuffer = sourceBuffer;
            }
            // cut a quarte of a period
            if(i < (periodSize/4)) {
                cacheBuffer = sourceBuffer;
            }
      }
    }
页: [1]
查看完整版本: 请教 声卡2-Pound RLC Meter是如何计算的?