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
2c627862
Commit
2c627862
authored
Aug 10, 2017
by
rbo
Browse files
ita_write_sofa additional object data
additional object data can be added & receiverView and receiverUp removed
parent
983c3d54
Changes
1
Hide whitespace changes
Inline
Side-by-side
kernel/DataAudio_IO/ita_write/ita_write_sofa.m
View file @
2c627862
...
...
@@ -8,6 +8,7 @@ function result = ita_write_sofa(varargin)
%
Options
(
default
)
:
%
'
dataType
'
(
HRTF
)
:
sets
the
data
type
.
currently
only
HRTF
%
supported
%
userData
:
a
struct
with
userDataFields
%
%
Example
:
...
...
@@ -35,7 +36,7 @@ if nargin == 0 % Return possible argument layout
return;
end
sArgs = struct('pos1_data','itaAudio','pos2_filename','char','dataType','HRTF');
sArgs = struct('pos1_data','itaAudio','pos2_filename','char','dataType','HRTF'
,'userdata',[]
);
[data, filename, sArgs] = ita_parse_arguments(sArgs,varargin);
...
...
@@ -55,9 +56,14 @@ switch(sArgs.dataType)
case 'HRTF'
sofaObj = SOFAgetConventions('SimpleFreeFieldHRIR');
sofaObj = createSofaHRTF(sofaObj,data,userDataFields);
sofaObj = createSofaHRTF(sofaObj,data,userDataFields);
% userdatafields are generated from sofaObj.userdata
sofaObj = ita_sofa_setCoordinates(sofaObj,data,'channelCoordinateType','SourcePosition');
if ~isempty(sArgs.userdata) % user data are replaced by the struct
fNames = fieldnames(sArgs.userdata);
for idxFN = 1:numel(fNames)
sofaObj.(fNames{idxFN}) = sArgs.userdata.(fNames{idxFN});
end
end
% case 'Directivity'
% sofaObj = SOFAgetConventions('GeneralTF');
...
...
@@ -72,11 +78,10 @@ switch(sArgs.dataType)
error('ITA_WRITE_SOFA: Only HRTF Type is defined');
end
sofaObj.GLOBAL_ApplicationName = 'itaToolbox';
sofaObj.GLOBAL_AuthorContact = sprintf('%s (%s)',AuthorStr,EmailStr);
sofaObj.GLOBAL_Comment = data.comment;
sofaObj.GLOBAL_DateCreated = date;
sofaObj.GLOBAL_DataType = 'Directivity';
sofaObj.GLOBAL_ApplicationName = 'ITA-Toolbox';
sofaObj.GLOBAL_AuthorContact = sprintf('%s (%s)',AuthorStr,EmailStr);
sofaObj.GLOBAL_Comment = data.comment;
sofaObj.GLOBAL_DataType = 'Directivity';
SOFAupdateDimensions(sofaObj);
SOFAsave(filename,sofaObj);
...
...
@@ -107,15 +112,17 @@ function sofaObj = createSofaHRTF(sofaObj,data,userDataFields)
end
end
% two channels are needed
if ~isempty(data.objectCoordinates.cart)
sofaObj.ReceiverPosition = data.objectCoordinates.cart;
end
if ~isempty(data.objectUpVector.cart)
sofaObj.ReceiverUp = data.objectUpVector.cart;
end
if ~isempty(data.objectViewVector.cart)
sofaObj.ReceiverView = data.objectViewVector.cart;
end
% if ~isempty(data.objectUpVector.cart) % is not working with one or
% two channels
% sofaObj.ReceiverUp = data.objectUpVector.cart;
% end
% if ~isempty(data.objectViewVector.cart)
% sofaObj.ReceiverView = data.objectViewVector.cart;
% end
end
...
...
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