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
counter= counter+2;
end
tempMetadata=DAFFv17('getMetadata', handleDaff);
metadata = DAFFv17('getMetadata', handleDaff);
catch
disp( 'Could not read DAFF file right away, falling back to old version and retrying ...' );
......@@ -394,7 +394,27 @@ classdef itaHRTF < itaAudio
counter = 1;
data = zeros(props.filterLength,props.numRecords*2,'double' ) ;
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
data(:,[counter counter+1]) = DAFFv15( 'getRecordByIndex', handleDaff,iDir )';
coordDaff(iDir,:) = DAFFv15( 'getRecordCoords', handleDaff, 'data', iDir )';
......@@ -402,53 +422,36 @@ classdef itaHRTF < itaAudio
end
end
% Proceed (version independent)
names=fieldnames(tempMetadata);
for k=1:(numel(names))
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
phiM = coordDaff(:,1)*pi/180;
%phiM = mod(coordDaff(:,1),360)*pi/180;
%if ~isempty(find(0<coordDaff(:,2),1,'first'))
thetaM = coordDaff(:,2)*pi/180;
%thetaM = mod(180-(coordDaff(:,2)+90),180)*pi/180;
%else
% thetaM = coordDaff(:,2)*pi/180;
%end
radius = ones(props.numRecords,1);
chCoord = itaCoordinates;
chCoord.sph = ones(size(data,2),3);
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
phiM = coordDaff(:,1)*pi/180;
%phiM = mod(coordDaff(:,1),360)*pi/180;
%if ~isempty(find(0<coordDaff(:,2),1,'first'))
thetaM = coordDaff(:,2)*pi/180;
%thetaM = mod(180-(coordDaff(:,2)+90),180)*pi/180;
%else
% thetaM = coordDaff(:,2)*pi/180;
%end
radius = ones(props.numRecords,1);
chCoord = itaCoordinates;
chCoord.sph = ones(size(data,2),3);
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)
% TO DO !!!!!!!!!!!!!!!!!!!!!!!!!!!
......
......@@ -71,12 +71,29 @@ assert( betarange( 2 ) >= 0.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;
if(channels<1)
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