view toolboxes/bioakustik_tools/conversion/found_time_make_txt.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
line wrap: on
line source
%makes textfiles for already found wavs 

clear
global globalvars;
addpath('..\vogelst\k-band250905')
sourcedir='F:\Aufnahmen';
%sourcedir='F:\Ample';
%sourcedir='M:\PrograMathe\matlab\work\hiwi\vogelst\testmaterial\online2';

segmentsdir='F:\viele_einzelne_strophen\blaumeise\typ1';

%segmentsdir='F:\viele_einzelne_strophen\fringila_coelebs_buchfink\tst';
%segmentsdir='M:\PrograMathe\matlab\work\hiwi\vogelst\testmaterial\online';



%---------------------------------------------z-------------zugehörige dateien suchen 
allpaths=genpath(sourcedir);
data_names=dir(strcat(segmentsdir,'\*.wav'));
psourcedirs = explode(';',allpaths);
for i = 1:length(data_names)
    ldata_names{i} = data_names(i).name;
end

names_done = [];
relsource_files = {};
for i = 1:length(psourcedirs)
    actdir = dir(strcat(psourcedirs{i},'\*.wav'));
    ldata_names = ldata_names(setdiff(1:length(ldata_names),names_done));
    for j = 1:length(ldata_names)
        for k = 1:length(actdir)
            if(strncmp(actdir(k).name,ldata_names{j},length(ldata_names{j})-(7+2*6+1+3))) && ...
                    strncmp(substr(ldata_names{j},-(7+4),1),'-',1)
                names_done = [names_done j];
                relsource_files= cat(1,relsource_files,{[strcat(psourcedirs{i},'\',actdir(k).name)] [strcat(segmentsdir,'\',ldata_names{j})]});
            end
        end
    end
end


for i=1:size(relsource_files,1)
     newfilename=char(relsource_files(i,2));
     position(i,2)= hhmmss_to_s(substr(newfilename,-(7+3),6));
     position(i,1)= hhmmss_to_s(substr(newfilename,-(7+3+7),6));
     
        filetoopen=strcat(newfilename,'.txt');
        ftoex=dir(filetoopen);
        if(length(ftoex)==0)
           FID = fopen(filetoopen,'w');
           fprintf(FID,'%s','annotations for ');
           fprintf(FID,'%s',newfilename);
           fprintf(FID,'\n');
           fprintf(FID,'%s','sourcefile available at');
           fprintf(FID,'\n');
           fprintf(FID,'%s',char(relsource_files(i,1)));
           fprintf(FID,'\n');
           fprintf(FID,'%s','time of occurrence in hhmmss format:');
           fprintf(FID,'\n');
           fprintf(FID,'%s',s_to_hhmmss(position(i,1)));
           fprintf(FID,'%s','-');
           fprintf(FID,'%s',s_to_hhmmss(position(i,2)));
           fprintf(FID,'\n');
           fprintf(FID,'%s','in seconds:');
           fprintf(FID,'\n');
           fprintf(FID,'%s',sprintf('%d',position(i,1)));
           fprintf(FID,'\n');
           fprintf(FID,'%s',sprintf('%d',position(i,2)));
           fprintf(FID,'\n');
           fprintf(FID,'%s','comments:');

           fclose(FID);
        end
end