annotate aim-mat/tools/@frame/extractpitchregion.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 74dedb26614d
children
rev   line source
tomwalters@0 1 % method of class @frame
tomwalters@0 2 %
tomwalters@0 3 % INPUT VALUES:
tomwalters@0 4 %
tomwalters@0 5 % RETURN VALUE:
tomwalters@0 6 %
tomwalters@0 7 %
tomwalters@0 8 % (c) 2003, University of Cambridge, Medical Research Council
tomwalters@0 9 % Stefan Bleeck (stefan@bleeck.de)
tomwalters@0 10 % http://www.mrc-cbu.cam.ac.uk/cnbh/aimmanual
tomwalters@0 11 % $Date: 2003/01/17 16:57:46 $
tomwalters@0 12 % $Revision: 1.3 $
tomwalters@0 13
tomwalters@0 14 function fr=extractpitchregion(fr)
tomwalters@0 15 % throws out the region to a certain periodicity in the auditory image
tomwalters@0 16
tomwalters@0 17
tomwalters@0 18 global graphix;global starttime;
tomwalters@0 19 graphix=0;
tomwalters@0 20
tomwalters@0 21 % 0 von comps(0-2)
tomwalters@0 22 % und dann langsam auf 1 bis comp(3)
tomwalters@0 23
tomwalters@0 24 zerotime=1;
tomwalters@0 25 attacktill=2;
tomwalters@0 26 attacktodominant=4;
tomwalters@0 27 dominanttime=7;
tomwalters@0 28 decaytime=8;
tomwalters@0 29
tomwalters@0 30 % zerotime=1.5;
tomwalters@0 31 % attacktill=2.5;
tomwalters@0 32 % attacktodominant=4;
tomwalters@0 33 % dominanttime=7;
tomwalters@0 34 % decaytime=8;
tomwalters@0 35
tomwalters@0 36 dominant_scale_factor=1;
tomwalters@0 37
tomwalters@0 38
tomwalters@0 39 nr_ch=getnrchannels(fr);
tomwalters@0 40 cfs=getcf(fr);
tomwalters@0 41 end_time=getmaximumtime(fr);
tomwalters@0 42 sr=getsr(fr);
tomwalters@0 43 geslen=getlength(fr);
tomwalters@0 44 starttime=getminimumtime(fr);
tomwalters@0 45
tomwalters@0 46
tomwalters@0 47 for i=1:nr_ch
tomwalters@0 48 ch_fre=cfs(i);
tomwalters@0 49 ch=getsinglechannel(fr,i);
tomwalters@0 50 firsttime=-1/ch_fre*zerotime; % up to the second
tomwalters@0 51 secondtime=-1/ch_fre*attacktill;
tomwalters@0 52 thirdtime=-1/ch_fre*attacktodominant;
tomwalters@0 53 sixtime=-1/ch_fre*dominanttime;
tomwalters@0 54 seventime=-1/ch_fre*decaytime;
tomwalters@0 55
tomwalters@0 56 ch=scalefun(ch,0,firsttime,0,0,'r');
tomwalters@0 57 ch=scalefun(ch,firsttime,secondtime,0,1,'g');
tomwalters@0 58 ch=scalefun(ch,secondtime,thirdtime,1,dominant_scale_factor,'k');
tomwalters@0 59 ch=scalefun(ch,thirdtime,sixtime,dominant_scale_factor,dominant_scale_factor,'y');
tomwalters@0 60 ch=scalefun(ch,sixtime,seventime,dominant_scale_factor,1,'c');
tomwalters@0 61
tomwalters@0 62 % scale the amplitude of higher cf-channels down
tomwalters@0 63 % cutoff=2000;
tomwalters@0 64 % db_per_octave=6;
tomwalters@0 65 % scaler=getfiltervaluelowpass(ch_fre,cutoff,db_per_octave);
tomwalters@0 66 % ch=ch*scaler;
tomwalters@0 67 %
tomwalters@0 68 % fr=setsinglechannel(fr,i,ch);
tomwalters@0 69 end
tomwalters@0 70
tomwalters@0 71
tomwalters@0 72 function fun=scalefun(fun,fromtime,totime,scaler2,scaler1,col)
tomwalters@0 73 global starttime;global graphix;
tomwalters@0 74 dur=abs(totime)-abs(fromtime);
tomwalters@0 75 nr_points=time2bin(fun,fromtime)-time2bin(fun,totime);
tomwalters@0 76 msig=linspace(scaler1,scaler2,nr_points);
tomwalters@0 77 if fromtime < starttime
tomwalters@0 78 return
tomwalters@0 79 end
tomwalters@0 80 if totime < starttime
tomwalters@0 81 scaler1=scaler2+(scaler2-scaler1)/(fromtime-totime)*(starttime-totime);
tomwalters@0 82 totime=starttime;
tomwalters@0 83 nr_points=time2bin(fun,fromtime)-time2bin(fun,totime);
tomwalters@0 84 msig=linspace(scaler1,scaler2,nr_points);
tomwalters@0 85 end
tomwalters@0 86 if nr_points > 0
tomwalters@0 87 fun=mult(fun,msig,totime,nr_points/getsr(fun));
tomwalters@0 88 end
tomwalters@0 89 if graphix
tomwalters@0 90 plot(fun,col);hold on;
tomwalters@0 91 end
tomwalters@0 92
tomwalters@0 93 return
tomwalters@0 94
tomwalters@0 95