function fileName=...
   HITtoXML(LogAttackTime, HarmonicSpectralCentroid, HarmonicSpectralDeviation, HarmonicSpectralSpread, HarmonicSpectralVariation, fileName)

% This function generates the XML file containing the description of the TemporalCentroid
% It returns the name of the genrated XML file
% TCValue contains the value of the Temporal Centroid

% Written by Thibaut Sacreste
% Based on ISO/IEC CD 15938-4
%
% Version 1.0 
% created 18/03/2002

defaultFileName='HarmonicInstrumentTimbre.xml';
Mpeg7_wrapper='Mpeg7_wrapper.xml';

if ~exist('fileName')
   fileName=defaultFileName;
elseif isempty(fileName)
   fileName=defaultFileName;
end       

%--------------------------
%creation of the xml file:
try
   xmlFile=fopen(fileName,'w');  %opens the file in write mode
catch
   error(lasterr);
end    

%-------------------------
%XML generation:

%Mpeg7 wrapper:
try
   mpeg7File=fopen(Mpeg7_wrapper,'r');  %opens the file containing the Mpeg7 wrapper
catch
   error(lasterr);
end    

%copies the wrapper in the new XML file:
while ~feof(mpeg7File)
   line=fgets(mpeg7File);
   fprintf(xmlFile,'%s',line);
end    
fclose(mpeg7File);

tmp(1).tag 	= 'LogAttackTime';
tmp(1).value= num2str(LogAttackTime);
tmp(1).type = 'scalar';

tmp(2).tag = 'HarmonicSpectralCentroid';
tmp(2).value = num2str(HarmonicSpectralCentroid);
tmp(2).type = 'scalar';

tmp(3).tag = 'HarmonicSpectralDeviation';
tmp(3).value = num2str(HarmonicSpectralDeviation);
tmp(3).type = 'scalar';

tmp(4).tag = 'HarmonicSpectralSpread';
tmp(4).value = num2str(HarmonicSpectralSpread);
tmp(4).type = 'scalar';

tmp(5).tag = 'HarmonicSpectralVariation';
tmp(5).value = num2str(HarmonicSpectralVariation);
tmp(5).type = 'scalar';


%Descriptor generation:
%line='<AudioDescriptionScheme xsi:type="mpeg7:HarmonicInstrumentTimbreType">';
line='<DescriptionUnit xsi:type="mpeg7:HarmonicInstrumentTimbreType">';
fprintf(xmlFile,'\t%s\n',line);

for l=1:length(tmp)
   fprintf(xmlFile,'\t\t<%s>\n', 	tmp(l).tag);
   fprintf(xmlFile,'\t\t<%s>', 		tmp(l).type);
   fprintf(xmlFile,'%s', 				tmp(l).value);
   fprintf(xmlFile,'</%s>\n', 			tmp(l).type);
   fprintf(xmlFile,'\t\t</%s>\n', 	tmp(l).tag);
end

%line='</AudioDescriptionScheme>';
line='</DescriptionUnit>';
fprintf(xmlFile,'\t%s\n',line);

line='</Mpeg7>';
fprintf(xmlFile,'%s\n',line);

fclose(xmlFile);

