Direct Form 1

The most straightforward implementation is the Direct Form 1, which has the following difference equation:

or, if normalized:

Here the , and coefficients determine zeros, and , determine the position of the poles.

Flow graph of biquad filter in Direct Form 1:

Direct Form 2

The Direct Form 1 implementation requires four delay registers. An equivalent circuit is the Direct Form 2 implementation, which requires only two delay registers:

The Direct Form 2 implementation is called the canonical form, because it uses the minimal amount of delays, adders and multipliers, yielding in the same transfer function as the Direct Form 1 implementation. The difference equations for DF2 are:

where

 

//ASM example

/////////////////////////////////////////////////////////////
//                                                                     //
//     Process the audio stream                            //
//                                                                    //
/////////////////////////////////////////////////////////////

#include <def21262.h>
#define SECTIONS 3   /* Number of second-order sections (biquads) */

.section /pm seg_pmco;
.global _Cascaded_IIR_Filter_SIMD;
.extern inbuf;
.extern outbuf;
.extern delaybuf;
.extern coefficients;

_Cascaded_IIR_Filter_SIMD:

/*****************************************************************************
The algorithm:

IIR Second order sections - The cannonic second-order section implemented as
"Direct Form II" biquads.  Note that the SIMD architecture of the 2126x SHARC
family enables the two parallel execution units to filter the left and right
channel simultaneously.  All register moves and memory reads implicitly apply
to the shadow processing element (PEy) as well as the primary computational
unit (PEx).
*****************************************************************************

  Given the most general biquadratic (second order rational polynomial)

                b0 + b1'*z^-1 + b2'*z^-2
        H(z) = -------------------------- ,
                a0 + a1'*z^-1 + a2'*z^-2

  we may factor out the gain of the transfer function,

                b0     (b1'/a0)*z^-1 + (b2'/a0)*z^-2
        H(z) = ---- * -------------------------------
                a0     (a1'/b0)*z^-1 + (a2'/b0)*z^-2

  and normalize the coefficients, such that

                    a1*z^-1 + a2*z^-2
        H(z) = A * -------------------
                    b1*z^-1 + b2*z^-2

  where A = gain = b1'/a0

        a1 = a1'/b0,  a2 = a2'/b0,  b1 = b1'/a0,  b2 = b2'/a0

  This leaves only four true filter coefficients.  The gain values from
  all of the sections may be combined into a single channel gain applied
  apart from the inner computational loop.  With the simplified coefficients,
  the cannonic direct form II may be written as a pair of difference
  equations:

          w[n] = x[n] + a1*w[n-1] + a2*w[n-2]
          y[n] = w[n] + b1*w[n-1] + b2*w[n-2]

which leads to the following pseudocode:

read(x[n])
f12=0,                                                                     f2=w[n-1],           read(a1)
--- Loop --------------------------------------------------------------------
f12=a1*w[n-1], f8=f8 + f12,                                      f3=w[n-2],           read(a2)
f12=a2*w[n-2], f8=x[n] + a1*w[n-2],                        w[n-1] -> w[n-2]', read(b1)
f12=b1*w[n-2], w[n]=x[n] + a1*w[n-2] + a2*w[n-1],  f2=w[n-1],           read(b2)
f12=b2*w[n-1], f8=w[n] + b1*w[n-2],                        w[n] -> w[n-1]',   read(a1)
-----------------------------------------------------------------------------
                y[n]=f8 + f12

**************************************************************************/

  /*  Subroutine that implements the pseudocode above */

cascaded_biquad:
  bit set mode1 CBUFEN | PEYEN ;                    // Enable SIMD mode
   
  b0 = delaybuf;
  b1 = b0;
  b3 = inbuf;
  b4 = outbuf;
  b9 = coefficients;
  r0 = SECTIONS;

    f8=dm(i3,m1);                                          // read inbuf
    r12=r12 xor r12,  f2=dm(i0,m1),  f4=pm(i8,m8);
  lcntr=r0, do quads until lce;
          f12=f2*f4,      f8=f8+f12,      f3=dm(i0,m1),     f4=pm(i8,m8);
          f12=f3*f4,      f8=f8+f12,      dm(i1,m1)=f3,     f4=pm(i8,m8);
          f12=f2*f4,      f8=f8+f12,      f2=dm(i0,m1),     f4=pm(i8,m8);
quads:f12=f3*f4,      f8=f8+f12,      dm(i1,m1)=f8,     f4=pm(i8,m8);

  f8=f8+f12;
  rts (db);
  dm(i4,m1)=f8;
  bit clr mode1 CBUFEN | PEYEN;                  // disable SIMD mode

_Cascaded_IIR_Filter_SIMD.end:

//--------------------------------------------

 

Digital biquad filter的更多相关文章

  1. biquad filter实现

    原始频谱: LPF: HPF: 代码: #include<stdio.h> #include<stdlib.h> #include<errno.h> #includ ...

  2. 转载:EQ--biquad filter

    http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt https://arachnoid.com/BiQuadDesigner/index.html ...

  3. H5的Web Audio Api

    概述 研究Web Audio Api的主要原因是:工作中需要在ios中实现声音的淡出效果,主要是通过setInterval来改audio标签的volume属性实现的,但是ios上面volume属性是只 ...

  4. 《DSP using MATLAB》示例Example 8.27

    %% ------------------------------------------------------------------------ %% Output Info about thi ...

  5. 《DSP using MATLAB》示例Example 8.26

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  6. 《DSP using MATLAB》示例Example 8.24

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  7. 《DSP using MATLAB》示例Example 8.23

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  8. 《DSP using MATLAB》示例Example 8.22

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  9. 《DSP using MATLAB》示例Example 8.21

    %% ------------------------------------------------------------------------ %% Output Info about thi ...

随机推荐

  1. 如何利用 Python 完成验签操作

    柠檬班Python8期的佑佑以及Python7期的掠掠同学昨天都私下问华华老师如何利用Python完成验签的操作. 今天我们就以佑佑的例子来跟大家进行简单的说明以及操作! 一.什么是验签: 用非常简单 ...

  2. NFS配置不当导致的那些事儿

    NFS(Network File System):是FreeBSD支持的文件系统中的一种,它允许网络中的计算机之间通过TCP/IP网络共享资源: NFS配置:(声明:以下NFS实验是在RedHat7上 ...

  3. sql 查询名字中有_的员工

    select * from emp where ename like '%\_%' escape '\' ;\可以换作任意的字符 select * from emp where ename like ...

  4. ubuntu 14.04界面美化

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABVYAAAMACAIAAABAXKuVAAAAA3NCSVQICAjb4U/gAAAgAElEQVR4Xu

  5. 【漏洞分析】两个例子-数组溢出修改返回函数与strcpy覆盖周边内存地址

    修改返回函数 return 0 下面的程序的运行流程为main()函数调用了Magic()函数,通常执行完Magic()函数后会调用return 0 的地址, 但是在执行Magic()函数中时,数组下 ...

  6. HTML学习笔记06-连接

    HTML超链接 HTML使用标签<a>来设置文本超链接. 超链接可以是文字,也可以是图片,点击这些内容跳转到新的文档或当前文档的某个部分 代码类似这样: <a href=" ...

  7. C:malloc/calloc/realloc/alloca内存分配函数

    原文地址:http://www.cnblogs.com/3me-linux/p/3962152.html calloc(), malloc(), realloc(), free(),alloca() ...

  8. 高级 Java 必须突破的 10 个知识点!

    1.Java基础技术体系.JVM内存分配.垃圾回收.类装载机制.性能优化.反射机制.多线程.网络编程.常用数据结构和相关算法. 2.对面向对象的软件开发思想有清晰的认识.熟悉掌握常用的设计模式. 3. ...

  9. 026_关于shell中的特殊变量$0 $n $* $@ $! $?

    一. $n:获取当前执行的shell脚本的第N个参数,n=1..9,当n为0时表示脚本的文件名,如果n大于9,用大括号括起来like${10}. $*:获取当前shell的所有参数,将所有的命令行参数 ...

  10. openwrt 分区

    下面以ar9344 16M flash为例子: uboot启动时传递给内核的参数为: bootargs=console=ttyS0,115200 root=31:02 rootfstype=jffs2 ...