Updating DAFFv17 executable and metadata handling in itaHRTF to comply with...

Updating DAFFv17 executable and metadata handling in itaHRTF to comply with current OpenDAFF HEAD revision source code
parent cca50cca
...@@ -379,7 +379,7 @@ classdef itaHRTF < itaAudio ...@@ -379,7 +379,7 @@ classdef itaHRTF < itaAudio
counter= counter+2; counter= counter+2;
end end
tempMetadata=DAFFv17('getMetadata', handleDaff); metadata = DAFFv17('getMetadata', handleDaff);
catch catch
disp( 'Could not read DAFF file right away, falling back to old version and retrying ...' ); disp( 'Could not read DAFF file right away, falling back to old version and retrying ...' );
...@@ -394,7 +394,27 @@ classdef itaHRTF < itaAudio ...@@ -394,7 +394,27 @@ classdef itaHRTF < itaAudio
counter = 1; counter = 1;
data = zeros(props.filterLength,props.numRecords*2,'double' ) ; data = zeros(props.filterLength,props.numRecords*2,'double' ) ;
coordDaff = zeros(props.numRecords,2) ; coordDaff = zeros(props.numRecords,2) ;
tempMetadata=DAFFv15('getMetadata', handleDaff);
tempMetadata = DAFFv15('getMetadata', handleDaff);
% Convert old-style metadata format to v17.
names = fieldnames( tempMetadata );
for k = 1:numel( tempMetadata )
switch class(tempMetadata.(names{k}))
case 'logical'
datatype='bool';
case 'char'
datatype='string';
case 'double'
if rem(tempMetadata.(names{k}),1)==0
datatype='int';
else
datatype='float';
end
end
metadata = daffv17_add_metadata( metadata,cell2mat(names(k)),datatype,tempMetadata.(names{k}) );
end
for iDir = 1:props.numRecords for iDir = 1:props.numRecords
data(:,[counter counter+1]) = DAFFv15( 'getRecordByIndex', handleDaff,iDir )'; data(:,[counter counter+1]) = DAFFv15( 'getRecordByIndex', handleDaff,iDir )';
coordDaff(iDir,:) = DAFFv15( 'getRecordCoords', handleDaff, 'data', iDir )'; coordDaff(iDir,:) = DAFFv15( 'getRecordCoords', handleDaff, 'data', iDir )';
...@@ -402,53 +422,36 @@ classdef itaHRTF < itaAudio ...@@ -402,53 +422,36 @@ classdef itaHRTF < itaAudio
end end
end end
% Proceed (version independent)
names=fieldnames(tempMetadata); phiM = coordDaff(:,1)*pi/180;
for k=1:(numel(names)) %phiM = mod(coordDaff(:,1),360)*pi/180;
switch class(tempMetadata.(names{k})) %if ~isempty(find(0<coordDaff(:,2),1,'first'))
case 'logical' thetaM = coordDaff(:,2)*pi/180;
datatype='bool'; %thetaM = mod(180-(coordDaff(:,2)+90),180)*pi/180;
case 'char' %else
datatype='string'; % thetaM = coordDaff(:,2)*pi/180;
case 'double' %end
if rem(tempMetadata.(names{k}),1)==0 radius = ones(props.numRecords,1);
datatype='int';
else chCoord = itaCoordinates;
datatype='float'; chCoord.sph = ones(size(data,2),3);
end
end chCoord.phi(1:2:2*props.numRecords) = phiM;
metadata=daffv17_add_metadata(metadata,cell2mat(names(k)),datatype,tempMetadata.(names{k})); chCoord.phi(2:2:2*props.numRecords) = phiM;
end chCoord.theta(1:2:2*props.numRecords) = thetaM;
chCoord.theta(2:2:2*props.numRecords) = thetaM;
phiM = coordDaff(:,1)*pi/180;
%phiM = mod(coordDaff(:,1),360)*pi/180; this.mMetadata = metadata;
%if ~isempty(find(0<coordDaff(:,2),1,'first')) this.data = data;
thetaM = coordDaff(:,2)*pi/180; this.mDirCoord = itaCoordinates([radius thetaM phiM],'sph');
%thetaM = mod(180-(coordDaff(:,2)+90),180)*pi/180; this.channelCoordinates = chCoord;
%else this.mEarSide = repmat(['L'; 'R'],props.numRecords, 1);
% thetaM = coordDaff(:,2)*pi/180; this.signalType = 'energy';
%end % channelnames coordinates
radius = ones(props.numRecords,1); this.channelNames = ita_sprintf('%s ( %2.0f, \\theta= %2.0f)',...
this.mEarSide , this.channelCoordinates.theta_deg, this.channelCoordinates.phi_deg);
chCoord = itaCoordinates;
chCoord.sph = ones(size(data,2),3); end
chCoord.phi(1:2:2*props.numRecords) = phiM;
chCoord.phi(2:2:2*props.numRecords) = phiM;
chCoord.theta(1:2:2*props.numRecords) = thetaM;
chCoord.theta(2:2:2*props.numRecords) = thetaM;
this.mMetadata = metadata;
this.data = data;
this.mDirCoord = itaCoordinates([radius thetaM phiM],'sph');
this.channelCoordinates = chCoord;
this.mEarSide = repmat(['L'; 'R'],props.numRecords, 1);
this.signalType = 'energy';
% channelnames coordinates
this.channelNames = ita_sprintf('%s ( %2.0f, \\theta= %2.0f)',...
this.mEarSide , this.channelCoordinates.theta_deg, this.channelCoordinates.phi_deg);
end
function this = set.init(this,var) function this = set.init(this,var)
% TO DO !!!!!!!!!!!!!!!!!!!!!!!!!!! % TO DO !!!!!!!!!!!!!!!!!!!!!!!!!!!
......
...@@ -71,12 +71,29 @@ assert( betarange( 2 ) >= 0.0 ) ...@@ -71,12 +71,29 @@ assert( betarange( 2 ) >= 0.0 )
assert( betarange( 1 ) <= 180.0 ) assert( betarange( 1 ) <= 180.0 )
%% Assemble metadata %% Assemble metadata (if not already present)
keyname = 'Generation script';
if ~any( strcmpi( { metadata(:).name }, keyname ) )
metadata = daffv17_add_metadata( metadata, keyname, 'String', 'writeDAFFFile.m' );
end
keyname = 'Generation toolkit';
if ~any( strcmpi( { metadata(:).name }, keyname ) )
metadata = daffv17_add_metadata( metadata, keyname, 'String', 'ITA-Toolkit' );
end
keyname = 'Generation date';
if ~any( strcmpi( { metadata(:).name }, keyname ) )
metadata = daffv17_add_metadata( metadata, keyname, 'String', date );
end
keyname = 'Web resource';
if ~any( strcmpi( { metadata(:).name }, keyname ) )
metadata = daffv17_add_metadata( metadata, keyname, 'String', 'http://www.ita-toolkit.org' );
end
metadata = daffv17_add_metadata( metadata, 'Generation script', 'String', 'writeDAFFFile.m' );
metadata = daffv17_add_metadata( metadata, 'Generation toolkit', 'String', 'ITA-Toolkit' );
metadata = daffv17_add_metadata( metadata, 'Generation date', 'String', date );
metadata = daffv17_add_metadata( metadata, 'Web resource', 'String', 'http://www.ita-toolkit.org' );
channels=this.nChannels/this.nDirections; channels=this.nChannels/this.nDirections;
if(channels<1) if(channels<1)
warning('Number of channels per record was not detected correctly, assuming 2 channel records'); warning('Number of channels per record was not detected correctly, assuming 2 channel records');
......
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