Generate XO in Matlab

From DRC

Jump to: navigation, search

Matlab is a matrix based maths package. Octave is a free clone which implements many of the most useful features of Matlab. Most scrips can be easily implemented on either

Contents

How to generate XOs using Matlab/Octave

Butterworth

[b,a] = butter(order,cutoff)

order=crossover order cutoff = freq cut off in radians (= desired freq / samplerate * pi)

See also: butterord(wp, ws, rp, rs) to get the order and the cuttoff frequency eg, using wp=55, ws=96, rp=3, rs=12, butterord came back with an order of 2

Linkwitz-Riley

This is two butterworth filters cascaded

Linear Phase Crossovers

Use the "fir1" and "fir2" functions from Matlab/octave

eg from User:Birkinshawc

#
# Robert Scheer 10/6/2004
# Chris Birkinshaw 06/05/05
#
# Beginning of user parameters
#
n=10; # exponent for filter size
fxo1=100; # sub crossover frequency in Hz
fxo=3000; # mid/high crossover frequency in Hz
fs=44100; # sample rate in Hz
#
# End of user parameters
#
#
k=2^n; # order of filter
fn1=2*fxo1/fs; # normalized subsonic cutoff frequency
fnxo=2*fxo/fs; # normalized xo frequency
i=linspace(1,k,k); # k-tap filter array
f_lo=linspace(0,200,512); # for plot of low end of freq response
f_hi=linspace(0,20000,512);# for plot of entire freq response
hir=fir1(k,fnxo,'high','scale'); # high-pass impulse response
lir=fir1(k,[fn1,fnxo],'pass','scale'); # band-pass ir
sub=fir1(k,fn1,'low','scale'); # low-pass ir
hirtxt=hir(i); # my klugey way of taking k elements
lirtxt=lir(i); # from the k-element impulse responses
subtxt=sub(i);
save -ascii filters/mid_high.txt hirtxt
save -ascii filters/mid_low.txt lirtxt
save -ascii filters/sub_low.txt subtxt


Further info

ftp://ftp.funet.fi/pub/sci/audio/devel/dsp/ (Remark: link is dead)

The file "crossovers.tar.gz" contains two papers. The Linkwitz-Riley filter paper from Journal of AES (www.aes.org) Jan/Feb 1976, and the Thiele paper from JAES Sep 2000.

Personal tools