Aufgrund einer Wartung wird GitLab am 28.09. zwischen 10:00 und 11:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 28.09. between 10:00 and 11:00 am.

Commit 882c4ddf authored by rbo's avatar rbo

Auto stash before rebase of "origin/master"

- command window after first measurement
- convolve mic & TF, crop afterwards
- select measurements for EQ
- 0dB compensation
parent 5f6dd760
...@@ -14,6 +14,7 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -14,6 +14,7 @@ classdef itaHpTF_Audio < itaHpTF
% Audio Engineering Society Convention 130, May 2011) % Audio Engineering Society Convention 130, May 2011)
% normalized (Normalization of HpTF) % normalized (Normalization of HpTF)
% smoothing (Smoothing bandwidth has to be defined in fractions of octaves, see also ita_smooth) % smoothing (Smoothing bandwidth has to be defined in fractions of octaves, see also ita_smooth)
% mic (measured microphone transfer funcions - not inverted: length does not matter; will be adapted)
% %
% itaHpTF_Audio Methods (private): % itaHpTF_Audio Methods (private):
% HP_equalization If this.mic is not set, it will be unused % HP_equalization If this.mic is not set, it will be unused
...@@ -30,7 +31,9 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -30,7 +31,9 @@ classdef itaHpTF_Audio < itaHpTF
m_fUpper = 18000; m_fUpper = 18000;
mMethod = 'mSTD'; mMethod = 'mSTD';
mNormalized = true; mNormalized = true;
mGainComp = true;
mSmoothing = 1/6; mSmoothing = 1/6;
mSelectMeas = 1:8; % select the channels which should be used for the HpTF
end end
properties(Dependent = true, Hidden = false) properties(Dependent = true, Hidden = false)
...@@ -38,8 +41,10 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -38,8 +41,10 @@ classdef itaHpTF_Audio < itaHpTF
fLower = 100; fLower = 100;
fUpper = 18000; fUpper = 18000;
method = 'mSTD'; method = 'mSTD';
normalized = true; normalized = true; % normalization of the signal
gainComp = true; % microphone compensation
smoothing = 1/6; smoothing = 1/6;
selectMeas = 1:8; % select specific measurements
end end
properties (Dependent = true, SetAccess = private) properties (Dependent = true, SetAccess = private)
...@@ -122,6 +127,13 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -122,6 +127,13 @@ classdef itaHpTF_Audio < itaHpTF
function normalized = get.normalized(this) function normalized = get.normalized(this)
normalized = this.mNormalized; end normalized = this.mNormalized; end
function comp = get.gainComp(this)
comp = this.mGainComp; end
function sel = get.selectMeas(this)
sel = this.mSelectMeas; end
function smoothing = get.smoothing(this) function smoothing = get.smoothing(this)
smoothing = this.mSmoothing; end smoothing = this.mSmoothing; end
%% ................................................................ %% ................................................................
...@@ -151,6 +163,16 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -151,6 +163,16 @@ classdef itaHpTF_Audio < itaHpTF
this = HP_equalization(this); this = HP_equalization(this);
end end
function this = set.selectMeas(this,ch)
this.mSelectMeas = ch;
this = HP_equalization(this);
end
function this = set.gainComp(this,comp)
this.mGainComp = comp;
this = HP_equalization(this);
end
function this = set.smoothing(this,smoothing) function this = set.smoothing(this,smoothing)
this.mSmoothing = smoothing; this.mSmoothing = smoothing;
this = HP_equalization(this); this = HP_equalization(this);
...@@ -162,11 +184,12 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -162,11 +184,12 @@ classdef itaHpTF_Audio < itaHpTF
% SET PRIVATE % SET PRIVATE
%.................................................................. %..................................................................
function this = set.init(this,var) function this = set.init(this,var)
this.nameHP = var.nameHP; this.nameHP = var.nameHP;
this.nameMic = var.nameMic; this.nameMic = var.nameMic;
this.nameSubj = var.nameSubj; this.nameSubj = var.nameSubj;
this.repeat = var.repeat; this.repeat = var.repeat;
this.mTF.time = var.time; this.mTF.time = var.time;
this.selectMeas = 1:var.repeat;
this = HP_equalization(this); this = HP_equalization(this);
end end
...@@ -175,11 +198,8 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -175,11 +198,8 @@ classdef itaHpTF_Audio < itaHpTF
% Audio Engineering Society Convention 130, May 2011 % Audio Engineering Society Convention 130, May 2011
tWin = this.TF.trackLength; % crop HPTF tWin = this.TF.trackLength; % crop HPTF
if this.mic.dimensions == 2 % mic min phase + extension measSel = sort([2*this.selectMeas-1 2*this.selectMeas]);
minMic = ita_minimumphase(this.mic); TF = this.TF.ch(measSel);
[mic, TF] = ita_extend_dat(minMic,this.TF);
else TF = this.TF;
end
%init %init
thisEQ = this; thisEQ = this;
...@@ -200,14 +220,19 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -200,14 +220,19 @@ classdef itaHpTF_Audio < itaHpTF
otherwise otherwise
error('Unknown type'); error('Unknown type');
end end
if this.mic.dimensions == 2
Rec = ita_multiply_spk(Rec,mic); if this.mic.dimensions == 2 % Compensation of mic
minMic = ita_minimumphase(this.mic);
RecM = ita_convolve(Rec,minMic.ch(cdx));
RecM.fftDegree = TF.fftDegree;
else
RecM = Rec;
end end
%% Short Filter with no correction for low freqs and minimun phase %% Short Filter with no correction for low freqs and minimum phase
aux = max(abs(Rec.freqData),[],2); aux = max(abs(RecM.freqData),[],2);
% find first maximum and truncate low freq correction at this point % find first maximum and truncate low freq correction at this point
idxDF = Rec.freq2index([this.fLower this.fLower*1.5 ]); idxDF = RecM.freq2index([this.fLower this.fLower*1.5 ]);
d_aux = diff(aux(idxDF(1):idxDF(2))); d_aux = diff(aux(idxDF(1):idxDF(2)));
idx = find(diff(sign(d_aux)) ~= 0,1,'first'); % Bruno style... idx = find(diff(sign(d_aux)) ~= 0,1,'first'); % Bruno style...
aux(1:idxDF(1)+idx+1) = aux(idxDF(1)+idx+2); aux(1:idxDF(1)+idx+1) = aux(idxDF(1)+idx+2);
...@@ -227,10 +252,18 @@ classdef itaHpTF_Audio < itaHpTF ...@@ -227,10 +252,18 @@ classdef itaHpTF_Audio < itaHpTF
this_min = ita_minimumphase(ita_time_shift(HpTF,tWin/2)); this_min = ita_minimumphase(ita_time_shift(HpTF,tWin/2));
this_win = ita_time_window(this_min,[tWin*0.99,tWin],'time','crop'); this_win = ita_time_window(this_min,[tWin*0.99,tWin],'time','crop');
if this.normalized, if this.gainComp % compensate gains from mics (equalize)
this_norm = ita_normalize_dat(this_win); idxDF = this_win.freq2index(this.fLower);
chGain = 20*log10(abs(this_win.freqData(idxDF,:)));
this_comp = this_win;
this_comp.freqData = bsxfun(@times,this_win.freqData,10.^(-chGain/20));
else, this_comp = this_win;
end
if this.normalized
this_norm = ita_normalize_dat(this_comp);
thisEQ.timeData = this_norm.timeData; thisEQ.timeData = this_norm.timeData;
else thisEQ.timeData = this_win.timeData; else, thisEQ.timeData = this_comp.timeData;
end end
if ~isempty(this.savePath) if ~isempty(this.savePath)
......
...@@ -88,6 +88,7 @@ classdef itaHpTF_MS < itaHpTF ...@@ -88,6 +88,7 @@ classdef itaHpTF_MS < itaHpTF
% Measure Right side % Measure Right side
MS.inputChannels = chIn(2); MS.inputChannels = chIn(2);
MS.outputChannels = chOut(2); MS.outputChannels = chOut(2);
commandwindow
resultR = MS.run; resultR = MS.run;
resultR.channelNames{1} = strR; resultR.channelNames{1} = strR;
...@@ -108,7 +109,7 @@ classdef itaHpTF_MS < itaHpTF ...@@ -108,7 +109,7 @@ classdef itaHpTF_MS < itaHpTF
disp(['Measurement ',num2str(idxM),'/',num2str(this.repeat),' finished.']) disp(['Measurement ',num2str(idxM),'/',num2str(this.repeat),' finished.'])
disp('Put headphones off and on again. Press any key to continue.') disp('Put headphones off and on again. Press any key to continue.')
pause pause
pause(2) pause(1)
else else
commandwindow commandwindow
fprintf('\nMEASUREMENT DONE!\n') fprintf('\nMEASUREMENT DONE!\n')
...@@ -118,6 +119,7 @@ classdef itaHpTF_MS < itaHpTF ...@@ -118,6 +119,7 @@ classdef itaHpTF_MS < itaHpTF
MS.inputChannels = chIn; MS.inputChannels = chIn;
HpTF = itaHpTF_Audio(this); HpTF = itaHpTF_Audio(this);
HpTF.selectMeas = 1:this.repeat;
assignin('base', ['HpTF_' this.nameSubj], HpTF) assignin('base', ['HpTF_' this.nameSubj], HpTF)
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment