Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
toolbox
Commits
98e2adf9
Commit
98e2adf9
authored
Apr 12, 2021
by
Hark Braren
Browse files
add userData to allow modification of general sofa parameters in exported file
parent
f1349797
Changes
1
Show whitespace changes
Inline
Side-by-side
applications/Binaural-HRTF/HRTF_class/ita_write_sofa_hrtf.m
View file @
98e2adf9
...
...
@@ -4,6 +4,13 @@ function varargout = ita_write_sofa_hrtf(varargin)
%
%
Syntax
:
%
ita
_
write
_
sofa
_
hrtf
(
hrtfObj
,
fileName
)
%
%
Options
:
%
userData
([])
:
struct
with
user
specific
SOFA
entries
see
%
<
userDataFields
>
below
%
e
.
g
.
userData
=
struct
(
'
GLOBAL
_
AuthorContact
','
Max
Mustermann
:
mmu
@
xyz
.
de
',...
%
'
GLOBAL
_
Comment
','
Example
Comment
'
)
%
See
also
:
%
ita
_
read
_
sofa
_
hrtf
,
ita
_
write
,
itaHRTF
...
...
@@ -20,6 +27,20 @@ function varargout = ita_write_sofa_hrtf(varargin)
%
Author
:
Hark
Braren
--
Email
:
hark
.
braren
@
akustik
.
rwth
-
aachen
.
de
%
Created
:
12
-
Apr
-
2021
userDataFields
=
{
'
GLOBAL
_
AuthorContact
',...
%
Who
created
it
,
automatically
takes
info
from
toolbox
preferences
'
GLOBAL
_
Comment
',...
'
GLOBAL
_
History
',...
'
GLOBAL
_
License
',...
%
e
.
g
.
CC
4.0
BY
-
http
://
creativecommons
.
org
/
licenses
/
by
/
4.0
/
'
GLOBAL
_
ListenerShortName
',...
%
e
.
g
.
KEMAR
'
GLOBAL
_
Organization
',...
%
(
IHTA
)
'
GLOBAL
_
References
',...
%
corresonding
paper
'
GLOBAL
_
DateCreated
',...
'
GLOBAL
_
DateModified
',...
'
GLOBAL
_
Title
',...
'
GLOBAL
_
DatabaseName
',...
%
'
GLOBAL
_
Origin
',...
'
GLOBAL
_
RoomType
',...
%
(
freefield
)
}
;
%%
Initialization
and
Input
Parsing
if
nargin
==
0
%
Return
possible
argument
layout
...
...
@@ -28,8 +49,8 @@ if nargin == 0 % Return possible argument layout
return;
end
sArgs = struct('pos1_data','itaHRTF','pos2_filename','char');
[data, fileName] = ita_parse_arguments(sArgs,varargin);
sArgs = struct('pos1_data','itaHRTF','pos2_filename','char'
,'userData',[]
);
[data, fileName
, sArgs
] = ita_parse_arguments(sArgs,varargin);
%% check if sofa is installed
if ~exist('SOFAstart.m','file')
...
...
@@ -73,35 +94,58 @@ end
%% General Info
Obj.GLOBAL_ApplicationName = 'ITA-Toolbox';
Obj.GLOBAL_Organization = 'Intitute for Hearing Technology and Acoustic, RWTH Aachen University';
Obj.GLOBAL_ApplicationVersion = num2str(ita_toolbox_version_number);
%The following will be overwritten with userdata is supplied
Obj.GLOBAL_DateCreated = date;
Obj.GLOBAL_AuthorContact = [ita_preferences('AuthorStr') ': ' ita_preferences('EmailStr')];
%% HRTF Info
%head position
and orientation
%head position
Obj.ListenerPosition_Type = 'cartesian';
Obj.ListenerPosition_Units = 'metre';
Obj.ListenerPosition = [0 0 0];
% ear position for each measurement [0 +w 0; 0 -w 0] in hrtf.objectCoordinates
Obj.ReceiverPosition_Type = 'cartesian';
Obj.ReceiverPosition_Units = 'metre';
Obj.ReceiverPosition = repmat(data.objectCoordinates.cart,1,1,data.nDirections);
if ~isempty(data.objectCoordinates.cart)
Obj.ReceiverPosition = repmat(data.objectCoordinates.cart,1,1,data.nDirections);
else
Obj.ReceiverPosition = repmat([0 0.09 0; 0 -0.09 0],1,1,data.nDirections); %default per SOFA def
end
%head orientation
Obj.ListenerView_Type = 'cartesian';
Obj.ListenerView_Units = 'metre';
Obj.ListenerView = data.objectViewVector.cart;
Obj.ListenerUp = data.objectUpVector.cart;
if ~isempty(data.objectViewVector.cart)
Obj.ListenerView = data.objectViewVector.cart;
end
if ~isempty(data.objectUpVector.cart)
Obj.ListenerUp = data.objectUpVector.cart;
end
%Loudspeaker positions in head-related coordinates
Obj.SourcePosition_Type = 'spherical';
Obj.SourcePosition_Units = 'degree,degree,metre';
Obj.SourcePosition = sofaSphericalCoordiantas(data.dirCoord);
Obj.SourcePosition = sofaSphericalCoordiantes(data.dirCoord);
%% add Userdata
for iField = 1:numel(userDataFields)
if ismember(userDataFields{iField},fieldnames(sArgs.userData))
Obj.(userDataFields{iField}) = sArgs.userData.(userDataFields{iField});
end
end
%% update and write obj
Obj=SOFAupdateDimensions(Obj);
SOFAsave(fileName,Obj);
end
function sofaCoord = sofaSphericalCoordiant
a
s(coords)
function sofaCoord = sofaSphericalCoordiant
e
s(coords)
%transform from zenith to elevation angle
r = coords.r;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment