Effacer les filtres
Effacer les filtres

Transfer function between two audio signals

5 vues (au cours des 30 derniers jours)
Luca Mastrangelo
Luca Mastrangelo le 3 Fév 2017
Hi, i'm trying to calculate a transfer function between 2 audio signals (x and x2). I applied an octave filter to each signal so I have the power for each band of the signals (x_oct_pow and x2_oct_pow), I want to know the transfer function. An example below:
[x_oct_pow, x2_oct_pow] = octave(x, x2, Fs);
What is the correct method to get the transfer function between x_oct_pow and x2_oct_pow? I have to divide the vectors:
tr_f = x2_oct_pow ./ x_oct_pow;
or, since I'm working with a power, I have to subtract them?
tr_f = x2_oct_pow - x_oct_pow;
Thank you for your help

Réponses (1)

Ankit Bhatnagar
Ankit Bhatnagar le 8 Fév 2017
Modifié(e) : Ankit Bhatnagar le 8 Fév 2017
I believe that you are using the Octave Filter function as there is no 'Octave' function in MATLAB. The usage of the Octave Filter is of the form: octFilt = octaveFilter(1000,'1/3 octave','SampleRate',96000) which creates a System object, octFilt, with a center frequency of 1000 Hz, a 1/3 octave filter bandwidth, and a sample rate of 96,000 Hz. For details on the output and other properties please refer to:
As far as transfer function for the signals, it can be obtained by dividing the signals not subtracting.
  1 commentaire
Luca Mastrangelo
Luca Mastrangelo le 8 Fév 2017
Hi Ankit, thank you for your answer. I wrote my own function to apply the octave filter. Taking two audio signals x and x2 as inputs it returns two vectors, x_oct_pow and x2_oct_pow, containing the power for each band. Below the code of the function:
function [x_pow_oct, x2_pow_oct, Fc] = octave(x, x2, Fs)
lx = length(x);
Fc = [20 25 31.5 40 50 63 80 100 125 160 200 250 315 400 ...
500 630 800 1000 1250 1600 2000 2500 3150 4000 5000 ...
6300 8000 10000 12500 16000 20000];% ANSI central frequencies
Fc = Fc(Fc<Fs/2);
fl = Fc*2^(-1/6); % lower frequencies
fu = Fc*2^(1/6); % upper frequencies
fu(fu>Fs/2) = Fs/2 -1;
numBands = length(Fc);
b = cell(numBands,1);
a = cell(numBands,1);
for n = 1:length(Fc)
[b{n},a{n}] = butter(2, [fl(n) fu(n)]/(Fs/2), 'bandpass');
end
% apply filter
x_oct = zeros(lx, numBands);
x2_oct = zeros(lx, numBands);
for i = 1:numBands
x_oct(:, i) = filtfilt(b{i}, a{i}, x);
x2_oct(:, i) = filtfilt(b{i}, a{i}, x2);
end
x_pow_oct = zeros(1, numBands);
x2_pow_oct = zeros(1, numBands);
for k = 1:numBands
s1 = sum(abs(fft(x_oct(:,k))).^2)/lx;
s2 = sum(abs(fft(x2_oct(:,k))).^2)/lx;
x_pow_oct(k) = 10*log10(s1/(lx/Fs));
x2_pow_oct(k) = 10*log10(s2/(lx/Fs));
end
end
Unfortunately this code doesn't work perfectly. With a pink noise it returns the same value for each band. But if I compare the results with a professional octave filter, applying both filters to a real signal, I obtain very different values. Can you check if I made any mistake?
Luca

Connectez-vous pour commenter.

Catégories

En savoir plus sur Measurements and Spatial Audio dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by