Replicating crossoverFilter() by using butter() and filter()

조회 수: 17 (최근 30일)
Danijel
Danijel 2017년 3월 21일
댓글: Danijel 2019년 1월 7일
How do I replicate Matlab crossoverFilter() from Audio Toolbox by using standard butter() and filter() functions?
I used parallel combination of two butter filters connected in series, but that produced slightly different output than the crossoverFilter.
Is there an error in my `butter`/`filter` usage?
I even tried negating high pass output, as it is expected that there will always be a phase difference of 180° between the outputs of a second order low-pass filter and a high-pass filter having the same crossover frequency. But that didn't help too.

답변 (1개)

Danijel
Danijel 2017년 3월 24일
OK, figured it out. I used
'CrossoverSlopes', 12,...
which is wrong for my use case where I have two 2nd order Butterworth filters cascaded.
Cascading any order Butterworth filter produces 2x that order Linkwitz-Riley. So, cascading two 2nd order Butterworth filters creates a LR-4 design. This means the crossover slope is 24 dB/octave, not 12 as I thought.
Changing the above line to
'CrossoverSlopes', 24,
makes the output from crossoverFilter() the same as my "manual" setup using butter() and filter().
  댓글 수: 2
William Chambers
William Chambers 2018년 12월 23일
Do you have an example of your manaul crossoverFilter implementation, I'm trying to do something similar
Danijel
Danijel 2019년 1월 7일
Hi William, something like:
1. calculate coefficients:
[B_highpass, A_highpass] = butter( filter_order, crossover_frequency/sampling_frequency*2, 'high' );
[B_lowpass, A_lowpass ] = butter( filter_order, crossover_frequency/sampling_frequency*2, 'low' );
2. filter it:
[output_low, state_lowpass_1st ] = filter( B_lowpass, A_lowpass, input_pcm_samples, state_lowpass_1st );
[output_low, state_lowpass_2nd ] = filter( B_lowpass, A_lowpass, output_low, state_lowpass_2nd );
[output_high, state_highpass_1st] = filter( B_highpass, A_highpass, input_pcm_samples, state_highpass_1st);
[output_high, state_highpass_2nd] = filter( B_highpass, A_highpass, output_high, state_highpass_2nd);
This gives the output in output_low and output_high.
How it works: feeds input to first low pass filter, then feeds output from first low pass, to second low pass. The same is done with high pass.The whole setup is called Linkwitz–Riley audio crossover. In this case cascading two 2nd order Butterworth filters creates a Linkwitz–Riley-4 design, with 24 dB/octave slope at crossover frequency. (More theory at Linkwitz-Riley Crossovers: A Primer.)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio Processing Algorithm Design에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by