function write_hnm_jan(FileName,ta,PitchOrig,Pitch,NbHarm,Gain, k,amp, phase, ceps) % % % attention ! Jan's version - writes two pitches - the original % one and the desired one % % function write_hnm(FileName,ta,PitchOrig,Pitch,NbHarm,Gain, k,amp, phase, ceps) % % FileName : The file name of the analysis HNM without the % default extensions % % USAGE : write_hnm(FileName,ta,PitchOrig,Pitch,NbHarm,Gain, k,amp, phase, ceps) % needs the dsc file ! % % this function has to modify the .ta file, so that the pointers % correspond to the added pitch. % % Defaults values % MAXHARM = 200; % the maximum number of harmonics EXT_RES_JAN = '_hnma.res_jan'; EXT_TA = '_hnma.ta'; EXT_TA_JAN = '_hnma.ta_jan'; EXT_DSC = '_hnma.dsc'; fpdsc = fopen([FileName EXT_DSC], 'rt'); Size = fscanf(fpdsc, '%d %ld %d\n'); % jan: the same... fclose (fpdsc); NumFr = Size(2); CepsSize = Size(3); SizeLPC = Size(5)+1; disp ([' NumFr ' num2str(NumFr) ' CepsSize ' num2str(CepsSize) ... ' SizeLPC ' num2str(SizeLPC)]); %size (par) %%% correct the ta file (pointers in the file). fpta = fopen([FileName EXT_TA], 'rb'); pointers = fread (fpta, 'long'); fclose (fpta); % each frame has one float (4 bytes) more than before. correction_pointers = 0:4:((length(pointers)-1)*4); pointers = pointers + correction_pointers'; %%% write to a file with extension ta_jan. fpta = fopen([FileName EXT_TA_JAN], 'wb'); fwrite (fpta, pointers, 'long'); fclose (fpta); fpres = fopen([FileName EXT_RES_JAN], 'wb'); for i=1:NumFr fwrite (fpres, ta(i), 'float'); fwrite (fpres, PitchOrig(i), 'float'); fwrite (fpres, Pitch(i), 'float'); fwrite (fpres, NbHarm(i) - 1, 'float'); % invesre from lect_hnm fwrite (fpres, Gain(i), 'float'); fwrite (fpres, k(i,:), 'float'); fwrite (fpres, amp(i,1:NbHarm(i)), 'float'); fwrite (fpres, phase(i,1:NbHarm(i)), 'float'); fwrite (fpres, ceps(i,:), 'float'); % pause end fclose (fpres);