搜索
bottom↓
回复: 0

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

[复制链接]

出0入0汤圆

发表于 2011-5-6 12:04:31 | 显示全部楼层 |阅读模式
在这里看到的这个基于声卡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周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-8-26 08:22

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表