% SUpDEq - Spatial Upsampling by Directional Equalization function [itd_ms, itd_ys] = supdeq_calcITD( hrir, fs, th, us, fc ) This function calculates the ITD (Interaural Time Delay) of a HRIR based on onset detection Output: itd_ms - ITD of the HRIR(s) in ms itd_ys - ITD of the HRIR(s) in micro seconds Input: hrir - [N x 2] HRIR with N samples and 2 channels fs - Sampling Rate Default: 48000 th - Threshold (in dB) of the onset detection Default: -20 us - Upsampling factor for onset detection Default: 10 fc - Frequency in Hz at which an 8th order Butterworth lowpass is applied to the hrir before onset detection Default: 3000 Dependencies: AKTools Reference: A. Andreopoulou and B. F. G. Katz, ?Identification of perceptually relevant methods of inter-aural time difference estimation,? J. Acoust. Soc. Am., vol. 142, no. 2, pp. 588?598, 2017. (C) 2020 by JMA, Johannes M. Arend TH Köln - University of Applied Sciences Institute of Communications Engineering Department of Acoustics and Audio Signal Processing
0001 %% SUpDEq - Spatial Upsampling by Directional Equalization 0002 % 0003 % function [itd_ms, itd_ys] = supdeq_calcITD( hrir, fs, th, us, fc ) 0004 % 0005 % This function calculates the ITD (Interaural Time Delay) of a HRIR based 0006 % on onset detection 0007 % 0008 % Output: 0009 % itd_ms - ITD of the HRIR(s) in ms 0010 % itd_ys - ITD of the HRIR(s) in micro seconds 0011 % 0012 % Input: 0013 % hrir - [N x 2] HRIR with N samples and 2 channels 0014 % fs - Sampling Rate 0015 % Default: 48000 0016 % th - Threshold (in dB) of the onset detection 0017 % Default: -20 0018 % us - Upsampling factor for onset detection 0019 % Default: 10 0020 % fc - Frequency in Hz at which an 8th order Butterworth 0021 % lowpass is applied to the hrir before onset detection 0022 % Default: 3000 0023 % 0024 % Dependencies: AKTools 0025 % 0026 % Reference: 0027 % A. Andreopoulou and B. F. G. Katz, ?Identification of perceptually relevant 0028 % methods of inter-aural time difference estimation,? 0029 % J. Acoust. Soc. Am., vol. 142, no. 2, pp. 588?598, 2017. 0030 % 0031 % (C) 2020 by JMA, Johannes M. Arend 0032 % TH Köln - University of Applied Sciences 0033 % Institute of Communications Engineering 0034 % Department of Acoustics and Audio Signal Processing 0035 0036 function [itd_ms, itd_ys] = supdeq_calcITD( hrir, fs, th, us, fc ) 0037 0038 if nargin < 2 || isempty(fs) 0039 fs = 48000; 0040 end 0041 0042 if nargin < 3 || isempty(th) 0043 th = -20; 0044 end 0045 0046 if nargin < 4 || isempty(us) 0047 us = 10; 0048 end 0049 0050 if nargin < 5 || isempty(fc) 0051 fc = 3000; 0052 end 0053 0054 %Check type of array 0055 if size(hrir,2) > size(hrir,1) 0056 hrir = hrir'; 0057 end 0058 0059 %% 0060 0061 onsetL = AKonsetDetect(hrir(:,1), us, th, 'rel', [fc fs]); 0062 onsetR = AKonsetDetect(hrir(:,2), us, th, 'rel', [fc fs]); 0063 0064 itdSamples = onsetL-onsetR; 0065 itd_ms = itdSamples/fs*1000; 0066 itd_ys = itd_ms*1000; 0067 0068 end 0069