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

17 visualizaciones (últimos 30 días)
Danijel
Danijel el 21 de Mzo. de 2017
Comentada: Danijel el 7 de En. de 2019
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.

Respuestas (1)

Danijel
Danijel el 24 de Mzo. de 2017
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 comentarios
William Chambers
William Chambers el 23 de Dic. de 2018
Do you have an example of your manaul crossoverFilter implementation, I'm trying to do something similar
Danijel
Danijel el 7 de En. de 2019
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.)

Iniciar sesión para comentar.

Categorías

Más información sobre Audio Processing Algorithm Design en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by