Commit 49935fe6 authored by la800319@rwth-aachen.de's avatar la800319@rwth-aachen.de

Merge branch 'master' of https://git.rwth-aachen.de/ita/toolbox

# Conflicts:
#	applications/VirtualAcoustics/Raven/itaRavenProject.m
parents bee11582 c45b310e
......@@ -31,3 +31,15 @@ end
% -
%% test moving unknown options to second output
struct.testpar = 1;
struct.testpar2 = 2;
parCell = {'testpar', 2, 'testpar2', 4,'unknown', 6};
% this should give a warning
[sArgs] = ita_parse_arguments(struct,parCell);
% this should not
[sArgs,unknownParams] = ita_parse_arguments(struct,parCell);
function varargout = PlotComet_3D(x_data, y_data, z_data, varargin)
%function creates a moving comet plot in 3 dimensions using the specificed
%x, y, and z line data
%
%PlotComet_3D(x_data, y_data, z_data)
%
%Optional Input Arguements:
%cFigure, handle to the current figure or axes to create the plot in (will
% add the line data to the plot regardless of whether hold is on
%
%Frequency, playback frequency, if not provided assumed to be 10 Hz
%
%blockSize, number of points in the comet tail, assumed to be 1/20 of
% length(x_data) if not provided
%
%PlotComet_3D(x_data, y_data, z_data, 'cFigure',FigureHandle,...
% 'Frequency',freq, 'blockSize',num_points)
%
%tailFormat, a structured variable containing the fomrating requirements of
% the tail (if different than the default red solid line)
% ex: Tail = struct('LineWidth',2,'Color','g','LineStyle','*');
% PlotComet_3D(x_data,y_data,z_data,'tailFormat',Tail);
%
%headFormat, a structued vairable containing the formating requirements of
% the head (if different than the default blue circle)
% ex: Head = struct('LineStyle','none','MarkerSize',8,'Marker','^','Color','k');
% PlotComet_3D(x_data,y_data,z_data,'headFormat',head);
% Note: 'LineSytle','none' is required since the head is plotted as a
% single point!
%
%Optional Output Arguements
%hFigure = figure handle to the comet plot
%
%Example: Create a surface plot and construct a moving line plot through it
%with connected cyan stars and dashed line on a 50 points long tail
%and large green square for a head.
%
%%create some data for the surface
%[X, Y] = meshgrid(linspace(-1, 1, 25), linspace(-1, 1, 25));
%Z = X .* exp(-X.^2 - Y.^2);
%%open a new figure and plot the surface
%surf(X, Y, Z);
%fig = gcf;
%%create the line data
%t = -pi:pi/500:pi;
%x = sin(5*t);
%y = cos(3*t);
%z = t;
%%define the tail formated structure
%Tail = struct('LineStyle','--','Marker','*','Color','c',...
% 'LineWidth',2,'MarkerSize',4);
%%define the head formated structure
%Head = struct('LineStyle','none','Marker','s','Color','g','MarkerSize',10);
%
%%Invoke the comet plot with 50 Hz playback, and a tail length of 50 pts
%PlotComet_3D(x,y,z,'cFigure',fig,'blockSize',50,'Frequency',50,...
% 'headFormat',Head,'tailFormat',Tail);
%
%Nick Hansford
%09/26/2013
%initialize the inputs
freq = 10;
blockSize = floor(1/20*length(x_data));
tailFormat = struct('LineWidth',1,'Color','r','LineStyle','-');
headFormat = struct('LineStyle','none','Marker','o','MarkerSize',6,...
'Color','b');
%parse out the inputs
argCount = nargin - 3;
for i = 1:2:argCount
% caseVar = varargin{i}
switch varargin{i}
case 'cFigure'
cFigure = varargin{i+1};
%get the original size:
cAxes = get(cFigure,'CurrentAxes');
xLim = get(cAxes,'XLim');
yLim = get(cAxes,'YLim');
zLim = get(cAxes,'ZLim');
%resize if the new plot will exceed them
if xLim(1) > min(x_data)
xLim(1) = min(x_data);
end
if xLim(2) < max(x_data)
xLim(2) = max(x_data);
end
if yLim(1) > min(y_data)
yLim(1) = min(y_data);
end
if yLim(2) < max(y_data)
yLim(2) = max(y_data);
end
if zLim(1) > min(z_data)
zLim(1) = min(z_data);
end
if zLim(2) < max(z_data)
zLim(2) = max(z_data);
end
axis([xLim, yLim, zLim]);
case 'blockSize'
blockSize = varargin{i+1};
case 'Frequency'
freq = varargin{i+1};
case 'tailFormat'
tailFormat = varargin{i+1};
case 'headFormat'
headFormat = varargin{i+1};
end
end
%make sure the figure exists, if not, create it
if ~exist('cFigure')
cFigure = figure;
view(3);
axis([min(x_data), max(x_data),...
min(y_data), max(y_data),...
min(z_data), max(z_data)]);
end
%user can pass in current axes, if so, get the parent for the figure window
%and use that instead...should make this compatible with GUIs?
if strcmp(get(cFigure,'Type'),'axes')
cFigure = get(cFigure,'Parent');
end
%activate the figure window
figure(cFigure);
cAxes = get(cFigure,'CurrentAxes');
oldNextPlot = get(cAxes,'NextPlot');
set(cAxes,'NextPlot','add');
pauseTime = 1./freq;
n_start = 1;
n_stop = 1;
%put on the starting point
plot3(x_data(n_start:n_stop),...
y_data(n_start:n_stop),...
z_data(n_start:n_stop),tailFormat);
plot3(x_data(n_stop), y_data(n_stop), z_data(n_stop),headFormat);
%playback!
for n = 1:1:length(x_data)
a = tic;
%delete the previous plot
hChild = get(cAxes,'Children');
delete(hChild(1:2));
if n <= blockSize
n_start = 1;
n_stop = n;
else
n_start = n_start + 1;
n_stop = n_stop + 1;
end
%new plot
plot3(x_data(n_start:n_stop),...
y_data(n_start:n_stop),...
z_data(n_start:n_stop),tailFormat);
plot3(x_data(n_stop), y_data(n_stop), z_data(n_stop),headFormat);
drawnow;
%update playback refresh rate
b = toc(a);
pause(pauseTime-b);
end
set(cAxes,'NextPlot',oldNextPlot);
% fprintf('Finished\n');
if nargout == 1
varargout{1} = cFigure;
end
Copyright (c) 2013, Nick Hansford
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
......@@ -41,7 +41,7 @@ switch Obj.GLOBAL_SOFAConventions
Obj.Data=rmfield(Obj.Data,'SOS');
Obj.API.Dimensions.Data=rmfield(Obj.API.Dimensions.Data,'SOS');
Obj=SOFAupdateDimensions(Obj);
case 'SimpleFreeFieldTF'
case {'SimpleFreeFieldTF' 'GeneralTF'}
fs=max(Obj.N)*2;
N=fs/min([min(diff(Obj.N)) Obj.N(1)]);
N=2*(round(N/2+1)-1);
......
function [out, azi, ele, idx] = SOFAspat(in,Obj,azi,ele)
function [out, azi, ele, idx] = SOFAspat(in,Obj,azi,ele,flag)
% SOFAspat
% [out, azi, ele, idx] = SOFAspat(in,Obj,azi,ele) spatializes the sound IN using
% the HRTFs from OBJ according to the trajectory given in AZI and ELE.
......@@ -7,6 +7,9 @@ function [out, azi, ele, idx] = SOFAspat(in,Obj,azi,ele)
% Obj: SOFA object containing the HRTFs
% azi, ele: vectors with the trajectory (in degrees) independent for
% azimuth and elevation
% flag: 'interaural-polar': azi and ele are given in the
% interaural-polar coordinate system as lateral and polar angles,
% respectively.
%
% Output:
% out: binaural signal
......@@ -57,6 +60,14 @@ else
ele=repmat(ele,1,S);
end;
%% Convert to spherical system if required
if exist('flag','var')
if strcmp(flag,'horizontal-polar')
x=SOFAconvertCoordinates([azi; ele; ones(size(azi))]','horizontal-polar','spherical');
azi=mod(x(:,1)',360);
ele=x(:,2)';
end
end
%% create a 2D-grid with nearest positions of the moving source
idx=zeros(S,1);
for ii=1:S % find nearest point on grid (LSP)
......@@ -87,12 +98,11 @@ while ii<iiend
%-----------
segTO=real(ifft(segFO)); % back to the time domain
out(ii+1:ii+2*N,:)=out(ii+1:ii+2*N,:)+segTO; % overlap and add
ii=ii+N*hop;
ii=ii+ceil(N*hop);
jj=jj+1;
end
%% Normalize
out(:,1)=out(:,1)/peak(1);
out(:,2)=out(:,2)/peak(2);
out=out./max(peak);
if exist('converted','var'), azi=nav2sph(azi,ele); end;
\ No newline at end of file
......@@ -43,4 +43,4 @@ Obj=SOFAupdateDimensions(Obj);
%% Fill with some additional data
Obj.GLOBAL_History='Converted from the ARI format';
if size(meta.pos,2)>2, Obj=SOFAaddVariable(Obj,'MeasurementSourceAudioChannel','M',meta.pos(1:size(hM,2),3)); end
Obj=SOFAaddVariable(Obj,'MeasurementAudioLatency','MR',meta.lat);
if isfield(meta,'lat'), Obj=SOFAaddVariable(Obj,'MeasurementAudioLatency','MR',meta.lat); end
function Obj = SOFAconvertBTDEI2SOFA(BTDEI)
% OBJ=SOFAconvertBTDEI2SOFA(BTDEI) converts the HRTFs described in BT-DEI
% to a SOFA object.
%
% BTDEI format is used by Michele Geronazzo, University of Padova.
%
% Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences;
% Licensed under the EUPL, Version 1.1 or as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License")
% You may not use this work except in compliance with the License.
% You may obtain a copy of the License at: http://joinup.ec.europa.eu/software/page/eupl
% Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and limitations under the License.
% get empty object (the flag 'm' provides the mandatory fields only)
Obj=SOFAgetConventions('SimpleHeadphoneIR','m');
Obj.GLOBAL_Title = 'HPIR';
Obj.GLOBAL_DatabaseName = BTDEI.specs.Database;
Obj.GLOBAL_History = 'Converted from the BT-DEI format';
Obj.GLOBAL_License = 'Creative Commons Attribution-NonCommercial-ShareAlike 3.0';
Obj.GLOBAL_ApplicationName = 'HpTFs from DEI - University of Padova';
Obj.GLOBAL_ApplicationVersion = SOFAgetVersion('API');
Obj.GLOBAL_AuthorContact = 'geronazzo@dei.unipd.it';
Obj.GLOBAL_References = ['M. Geronazzo, F. Granza, S. Spagnol, F. Avanzini. ', ...
'A Standardized Repository of Head-Related and Headphone Impulse Response Data ', ...
'In 134th Convention of the Audio Engineering Society, May 2013.'];
Obj.GLOBAL_Organization = 'Department of Information Engineering, University of Padova';
Obj.GLOBAL_Comment = '';
% copy the data
% Emitter - Source
Obj.GLOBAL_SourceDescription = [BTDEI.hp.Id ' - ' BTDEI.hp.Producer ' ' BTDEI.hp.Model];
Obj.GLOBAL_SourceManufacturer = BTDEI.hp.Producer;
Obj.GLOBAL_SourceModel = BTDEI.hp.Model;
%Obj.GLOBAL_SourceURI = BTDEI.hp.Uri;
% Receiver - Listener
Obj.GLOBAL_SubjectID = BTDEI.specs.SubjectId;
Obj.GLOBAL_ListenerDescription = BTDEI.sbjType;
Obj.GLOBAL_ReceiverDescription = BTDEI.specs.MicrophonePosition; % qualitative data e.g. blocked ear canal, open ear canal, at the eardrum
Obj.ListenerPosition = [0 0 0];
Obj.ReceiverPosition = [0 0.09 0; 0 -0.09 0];
Obj.SourcePosition = [0 0 0];
Obj.EmitterPosition = [0 0.09 0; 0 -0.09 0];
%% Fill data with data
Obj.Data.SamplingRate = BTDEI.specs.SampleRate; % Sampling rate
% calculate the effective size of the data matrix
M = length(BTDEI.data); % number of repositionings
R = size(BTDEI.data(1).HpIR,2); % number of channels (stereo)
len_vec = zeros(M,1);
for ii=1:M
len_vec(ii)= length(BTDEI.data(ii).HpIR);
end
N = max(len_vec);
Obj.API.M=M;
Obj.API.R=R;
Obj.API.N=N;
% store IR data
Obj.Data.IR = NaN(M,R,N); % data.IR must be [M R N]
for aa=1:M
HpIR = [BTDEI.data(aa).HpIR; zeros((N-length(BTDEI.data(aa).HpIR)),2)];
Obj.Data.IR(aa,1,:)= HpIR(:,1)';
Obj.Data.IR(aa,2,:)= HpIR(:,2)';
end
% update dimensions
Obj = SOFAupdateDimensions(Obj);
end
function Obj=SOFAconvertTUBerlinBRIR2SOFA(irs)
% OBJ=SOFAconvertTUBerlin2SOFA(irs) converts the HRTFs described in irs
% (see TU-Berlin HRTF format) to a SOFA object, using the MultiSpeakerBRIR
% Convention.
%
% SOFA API - demo script
% Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences
% Licensed under the EUPL, Version 1.1 or as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License")
% You may not use this work except in compliance with the License.
% You may obtain a copy of the License at: http://joinup.ec.europa.eu/software/page/eupl
% Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and limitations under the License.
%% Get an empy conventions structure
Obj = SOFAgetConventions('MultiSpeakerBRIR');
%% Fill data with data
Obj.Data.IR = zeros(size(irs.left,2),2,1,size(irs.left,1));
Obj.Data.IR(:,1,:) = shiftdim(shiftdim(irs.left,-2),3); % irs.left is [N M], data.IR must be [M R E N]
Obj.Data.IR(:,2,:) = shiftdim(shiftdim(irs.right,-2),3);
Obj.Data.SamplingRate = irs.fs;
%% Fill with attributes
Obj.GLOBAL_ListenerShortName = 'KEMAR';
Obj.GLOBAL_History='Converted from the TU-Berlin format';
Obj.GLOBAL_Comment = irs.description;
Obj.GLOBAL_License = 'Creative Commons Attribution-NonCommercial-ShareAlike 3.0';
Obj.GLOBAL_ApplicationName = 'BRIR from TU Berlin';
Obj.GLOBAL_ApplicationVersion = '1.0';
Obj.GLOBAL_AuthorContact = 'hagen.wierstorf@tu-berlin.de';
Obj.GLOBAL_References = [''];
Obj.GLOBAL_Origin = 'TU Berlin';
Obj.GLOBAL_Organization = 'Quality and Usability Lab, Technische Universitaet Berlin';
Obj.GLOBAL_DatabaseName = 'TU Berlin';
Obj.GLOBAL_Title = 'BRIR TU Berlin';
Obj.GLOBAL_ListenerDescription = irs.head;
Obj.GLOBAL_ReceiverDescription = 'Large ears (KB0065 + KB0066) with G.R.A.S. 40AO pressure microphones';
Obj.GLOBAL_SourceDescription = 'Genelec 8030A';
Obj.GLOBAL_RoomType = 'reverberant';
Obj.GLOBAL_RoomDescription = '';
%% Fill the mandatory variables
% MultiSpeakerBRIR
% === Source ===
Obj.SourcePosition = [0 0 0]; % center of loudspeaker array
Obj.EmitterPosition = irs.source_position';
Obj.EmitterView = irs.head_position';
Obj.EmitterUp = [0 0 1];
% === Listener ===
% number of measurements
M = length(irs.apparent_elevation);
distance = sqrt(sum((irs.source_position-irs.head_position).^2));
Obj.ListenerPosition = irs.head_position';
[x,y,z] = sph2cart(fixnan(irs.head_azimuth'), ...
repmat(fixnan(irs.head_elevation'),size(irs.head_azimuth')), ...
repmat(distance,size(irs.head_azimuth')));
Obj.ListenerView = [x,y,z];
Obj.ListenerUp = [0 0 1];
% Receiver position for a dummy head (imported from SimpleFreeFieldHRIR)
Obj.ReceiverPosition = [0,-0.09,0; 0,0.09,0];
%% Update dimensions
Obj=SOFAupdateDimensions(Obj);
end
function x = fixnan(x)
if isnan(x), x=0; end
end
% SOFA API demo script
% load HRTF in BT-DEI format and save in SOFA format.
% Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences;
% Licensed under the EUPL, Version 1.1 or as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License")
% You may not use this work except in compliance with the License.
% You may obtain a copy of the License at: http://joinup.ec.europa.eu/software/page/eupl
% Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and limitations under the License.
%% Define parameters
% Headphone index of the files to convert
hp= 'H010';
% Subject index of the files to convert
subject= 'S115';
% Measurement index of the files to convert
setm= 'Set02'; %Set01 Set02 ...
% File name of the BTDEI file
BTDEIfold='COMPENSATED'; %RAW %COMPENSATED %EQUALIZED
% Data compression (0..uncompressed, 9..most compressed)
compression=1; % results in a nice compression within a reasonable processing time
%% load BTDEI file \ load database structure data
f=filesep;
BTDEI_hp_add=fullfile(fileparts(SOFAdbPath),'BTDEI',hp,'headphones_info.mat');
BTDEI_add=fullfile(fileparts(SOFAdbPath),'BTDEI',hp,subject,setm,BTDEIfold,'MAT',[hp '_' subject '_btdei.mat']);
disp(['Loading BT-DEI data']);
try
datasheet = load(BTDEI_hp_add);
BTDEI.hp = datasheet.hp_specs;
switch subject
case 'S115'
BTDEI.sbjType = 'dummy head with large pinna';
case 'S116'
BTDEI.sbjType = 'dummy head without pinna';
case 'S117'
BTDEI.sbjType = 'dummy head without pinna';
otherwise
BTDEI.sbjType = 'human';
end
container = load(BTDEI_add);
BTDEI.specs = container.specs;
BTDEI.data = container.data;
catch e
error(['Convertion - Error message: ' e.message]);
end
BTDEI.type = BTDEIfold;
BTDEI.typeset = setm;
%% convert
Obj = SOFAconvertBTDEI2SOFA(BTDEI);
Obj.GLOBAL_Comment = SOFAappendText(Obj,'GLOBAL_Comment',BTDEIfold);
%% save SOFA file
SOFAfn=fullfile(SOFAdbPath,'sofa_api_mo_test',['BTDEI-hp_' hp '_subj_' subject '-' setm '-' BTDEIfold '.sofa']);
disp(['Saving: ' SOFAfn])
SOFAsave(SOFAfn, Obj, compression);
function [] = NETCDFdisplay(filename)
%NETCDFDISPLAY
% [] = NETCDFdisplay(filename) displays information about specified SOFA file
% SOFA API - demo script
% load headphone IRs from a SOFA file from the ARI headphones database
% SOFA API - function matlab/NETCDFdisplay
% Copyright (C) 2012 Acoustics Research Institute - Austrian Academy of Sciences
% Copyright (C) 2012-2013 Acoustics Research Institute - Austrian Academy of Sciences
% Licensed under the EUPL, Version 1.1 or as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License")
% You may not use this work except in compliance with the License.
% You may obtain a copy of the License at: http://joinup.ec.europa.eu/software/page/eupl
% Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and limitations under the License.
ncdisp(filename);
end %of function
\ No newline at end of file
%% Define parameters
% Subject index of the file to convert
subjectID='NH5';
%% Load SOFA file
SOFAfn=fullfile(SOFAdbPath, 'headphones', 'ari', ['hpir_' lower(subjectID) '.sofa']);
disp(['Loading: ' SOFAfn]);
X=SOFAload(SOFAfn);
%% Plot amplitude spectra
figure;
hold on; box on;
cols=['bgrmky'];
meastime=[0; diff(X.MeasurementDate)];
for ii=1:X.API.M
plot(20*log10(abs(fft(squeeze(X.Data.IR(ii,1,:)),X.Data.SamplingRate))),cols(ii));
if ii>1, leg{ii}=['#' num2str(ii) ':' num2str(meastime(ii)) ' seconds later']; end
end
axis([0 X.Data.SamplingRate/2 -80 20]);
leg{1}='#1, first measurement';
legend(leg);
\ No newline at end of file
% SOFA API - demo script
% Copyright (C) 2012-2014 Acoustics Research Institute - Austrian Academy of Sciences
% Licensed under the EUPL, Version 1.1 or as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "License")
% You may not use this work except in compliance with the License.
% You may obtain a copy of the License at: http://joinup.ec.europa.eu/software/page/eupl
% Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and limitations under the License.
%
% load HRTF and plots CTF and average DTF
%
%% Define parameters
% Subject index of the file to convert
subject=3;
% Data compression (0..uncompressed, 9..most compressed)
compression=1; % results in a nice compression within a reasonable processing time
%% load SOFA file
SOFAfn=fullfile(SOFAdbPath, 'database', 'cipic', ['subject_' sprintf('%03d',subject) '.sofa']);
X=SOFAload(SOFAfn);
[D,C]=SOFAhrtf2dtf(X);
% close all;
f = figure;
set(f, 'Position', [50, 400, 1100, 500]);
subplot(1,2,1);
data=(20*log10(abs(fft(squeeze(C.Data.IR(1,1,:))))));
stepsize=C.Data.SamplingRate/length(data)*2;
plot(1:stepsize:C.Data.SamplingRate,data(1:length(data)/2));
% ax=gca; set(ax,'XScale','log');
hold on; grid on;
subplot(1,2,2);
% plot(20*log10(abs(fft(squeeze(C.Data.IR(1,1,1:length(C.Data.IR)/2))))));
data=(20*log10(abs(fft(squeeze(C.Data.IR(1,2,:))))));
stepsize=C.Data.SamplingRate/length(data)*2;
plot(1:stepsize:C.Data.SamplingRate,data(1:length(data)/2));
% ax=gca; set(ax,'XScale','log');
hold on; grid on;
[D,CC]=SOFAhrtf2dtf(D);
subplot(1,2,1);
data=(20*log10(abs(fft(squeeze(CC.Data.IR(1,1,:))))));
stepsize=CC.Data.SamplingRate/length(data)*2;
plot(1:stepsize:CC.Data.SamplingRate,data(1:length(data)/2),'r');
title('left');
xlabel('f (in Hz)'); ylabel('dB');
legend('CTF','Avg DTF','Location','Best')
subplot(1,2,2);
% plot(20*log10(abs(fft(squeeze(CC.Data.IR(1,1,1:length(C.Data.IR)/2))))),'r');
data=(20*log10(abs(fft(squeeze(CC.Data.IR(1,2,:))))));
stepsize=CC.Data.SamplingRate/length(data)*2;
plot(1:stepsize:CC.Data.SamplingRate,data(1:length(data)/2),'r');
title('right');
xlabel('f (in Hz)'); ylabel('dB');
legend('CTF','Avg DTF','Location','Best');
......@@ -6,14 +6,20 @@
% Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and limitations under the License.
%% load a SOFA file
%% load a SOFA file in SimpleFreeFieldHRIR
SOFAfile=fullfile(SOFAdbPath,'database','ari','dtf_nh2.sofa');
Obj=SOFAload(SOFAfile);
% plot ETC horizontal plane
figure;
SOFAplotHRTF(Obj,'ETCHorizontal',1);
% plot magnitude spectrum in the median plane, channel 2
figure;
SOFAplotHRTF(Obj,'MagMedian',2);
%% load a GeneralTF SOFA file
SOFAfile=fullfile(SOFAdbPath,'database','ari (sim)','hrtf_nh5_ref.sofa');
Obj=SOFAload(SOFAfile);
% plot magnitude spectrum in the median plane, channel 1
figure;
SOFAplotHRTF(Obj,'MagMedian',1);
......@@ -46,4 +46,7 @@ xlabel('Time index');
legend({'Requested', 'Actual'},'Location','Best');
%% Play the sound - use headphones!
if ~exist('dontplay','var'); wavplay(out,Obj.Data.SamplingRate); end
\ No newline at end of file
if ~exist('dontplay','var');
p=audioplayer(out, Obj.Data.SamplingRate);
play(p);
end
\ No newline at end of file
% Script for testing the string array feature of SOFA
%% Test Strings as application-specific variable
% Load some arbritrary HRTFs
hrtf = SOFAload(fullfile(SOFAdbPath, 'database','ari','dtf_nh2.sofa'));
% Add a string array