annotate 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
rev   line source
wolffd@0 1 %makes textfiles for already found wavs
wolffd@0 2
wolffd@0 3 clear
wolffd@0 4 global globalvars;
wolffd@0 5 addpath('..\vogelst\k-band250905')
wolffd@0 6 sourcedir='F:\Aufnahmen';
wolffd@0 7 %sourcedir='F:\Ample';
wolffd@0 8 %sourcedir='M:\PrograMathe\matlab\work\hiwi\vogelst\testmaterial\online2';
wolffd@0 9
wolffd@0 10 segmentsdir='F:\viele_einzelne_strophen\blaumeise\typ1';
wolffd@0 11
wolffd@0 12 %segmentsdir='F:\viele_einzelne_strophen\fringila_coelebs_buchfink\tst';
wolffd@0 13 %segmentsdir='M:\PrograMathe\matlab\work\hiwi\vogelst\testmaterial\online';
wolffd@0 14
wolffd@0 15
wolffd@0 16
wolffd@0 17 %---------------------------------------------z-------------zugehörige dateien suchen
wolffd@0 18 allpaths=genpath(sourcedir);
wolffd@0 19 data_names=dir(strcat(segmentsdir,'\*.wav'));
wolffd@0 20 psourcedirs = explode(';',allpaths);
wolffd@0 21 for i = 1:length(data_names)
wolffd@0 22 ldata_names{i} = data_names(i).name;
wolffd@0 23 end
wolffd@0 24
wolffd@0 25 names_done = [];
wolffd@0 26 relsource_files = {};
wolffd@0 27 for i = 1:length(psourcedirs)
wolffd@0 28 actdir = dir(strcat(psourcedirs{i},'\*.wav'));
wolffd@0 29 ldata_names = ldata_names(setdiff(1:length(ldata_names),names_done));
wolffd@0 30 for j = 1:length(ldata_names)
wolffd@0 31 for k = 1:length(actdir)
wolffd@0 32 if(strncmp(actdir(k).name,ldata_names{j},length(ldata_names{j})-(7+2*6+1+3))) && ...
wolffd@0 33 strncmp(substr(ldata_names{j},-(7+4),1),'-',1)
wolffd@0 34 names_done = [names_done j];
wolffd@0 35 relsource_files= cat(1,relsource_files,{[strcat(psourcedirs{i},'\',actdir(k).name)] [strcat(segmentsdir,'\',ldata_names{j})]});
wolffd@0 36 end
wolffd@0 37 end
wolffd@0 38 end
wolffd@0 39 end
wolffd@0 40
wolffd@0 41
wolffd@0 42 for i=1:size(relsource_files,1)
wolffd@0 43 newfilename=char(relsource_files(i,2));
wolffd@0 44 position(i,2)= hhmmss_to_s(substr(newfilename,-(7+3),6));
wolffd@0 45 position(i,1)= hhmmss_to_s(substr(newfilename,-(7+3+7),6));
wolffd@0 46
wolffd@0 47 filetoopen=strcat(newfilename,'.txt');
wolffd@0 48 ftoex=dir(filetoopen);
wolffd@0 49 if(length(ftoex)==0)
wolffd@0 50 FID = fopen(filetoopen,'w');
wolffd@0 51 fprintf(FID,'%s','annotations for ');
wolffd@0 52 fprintf(FID,'%s',newfilename);
wolffd@0 53 fprintf(FID,'\n');
wolffd@0 54 fprintf(FID,'%s','sourcefile available at');
wolffd@0 55 fprintf(FID,'\n');
wolffd@0 56 fprintf(FID,'%s',char(relsource_files(i,1)));
wolffd@0 57 fprintf(FID,'\n');
wolffd@0 58 fprintf(FID,'%s','time of occurrence in hhmmss format:');
wolffd@0 59 fprintf(FID,'\n');
wolffd@0 60 fprintf(FID,'%s',s_to_hhmmss(position(i,1)));
wolffd@0 61 fprintf(FID,'%s','-');
wolffd@0 62 fprintf(FID,'%s',s_to_hhmmss(position(i,2)));
wolffd@0 63 fprintf(FID,'\n');
wolffd@0 64 fprintf(FID,'%s','in seconds:');
wolffd@0 65 fprintf(FID,'\n');
wolffd@0 66 fprintf(FID,'%s',sprintf('%d',position(i,1)));
wolffd@0 67 fprintf(FID,'\n');
wolffd@0 68 fprintf(FID,'%s',sprintf('%d',position(i,2)));
wolffd@0 69 fprintf(FID,'\n');
wolffd@0 70 fprintf(FID,'%s','comments:');
wolffd@0 71
wolffd@0 72 fclose(FID);
wolffd@0 73 end
wolffd@0 74 end
wolffd@0 75