%% %% *SpHEAR Project %% %% sphear_a_power: return array of power for all capsules in a range of frequencies %% %% usage: %% [R] = sphear_a_power(fmin, fmax, N, Npre) %% %% fmin, fmax: range of frequencies to consider %% Npre: number of samples before the main impulse %% N: total number of samples to analyze %% %% The names of reference microphone impulse response and capsule measurements are %% currently hardwired into this file, this needs to be fixed and turned into %% input parameters %% %% Copyright Fernando Lopez-Lezcano 2016 %% function [B] = sphear_bf_power(fmin, fmax, N, Fs) pkg load signal; %% R = zeros(16, 4); %% indexes in array for frequency bins imin = round((N/2) * fmin / (Fs/2)); imax = round((N/2) * fmax / (Fs/2)); %% all measurements for m = 1:16 %% all b format components, 4 channel soundfile bsignal = wavread(["../cal/2016.04.20/export/b-format-" sprintf("%02.0f", m) ".wav"]); bfft = fft(bsignal, N); %% return total power of signal in frequency range B(m, :) = sqrt(sum(bfft(imin:imax,:).*conj(bfft(imin:imax,:)))/size(bfft(imin:imax,:),1)); end end