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
|
tomwalters@0
|
16 dominant_scale_factor=1;
|
tomwalters@0
|
17
|
tomwalters@0
|
18 graphix=0;
|
tomwalters@0
|
19
|
tomwalters@0
|
20 nr_ch=getnrchannels(fr);
|
tomwalters@0
|
21 cfs=getcf(fr);
|
tomwalters@0
|
22 end_time=getmaximumtime(fr);
|
tomwalters@0
|
23 sr=getsr(fr);
|
tomwalters@0
|
24 geslen=getlength(fr);
|
tomwalters@0
|
25 starttime=getminimumtime(fr);
|
tomwalters@0
|
26
|
tomwalters@0
|
27 for i=1:nr_ch
|
tomwalters@0
|
28 ch_fre=cfs(i);
|
tomwalters@0
|
29 ch=getsinglechannel(fr,i);
|
tomwalters@0
|
30
|
tomwalters@0
|
31 % firstfre=-1/ch_fre*1; % up to the second
|
tomwalters@0
|
32 % firstbin=time2bin(ch,firstfre);
|
tomwalters@0
|
33 % firsttime=firstbin/sr-geslen;
|
tomwalters@0
|
34
|
tomwalters@0
|
35 % set all values below the first harmonic to 0
|
tomwalters@0
|
36 firsttime=-1/ch_fre*1; % up to the second
|
tomwalters@0
|
37 if graphix clf;plot(ch);hold on;end
|
tomwalters@0
|
38 ch=setvalues(ch,0,time2bin(ch,firsttime));
|
tomwalters@0
|
39 if graphix plot(ch,'r');end
|
tomwalters@0
|
40
|
tomwalters@0
|
41 % scale all values between the first and second from 0 to 1
|
tomwalters@0
|
42 secondtime=-1/ch_fre*2;
|
tomwalters@0
|
43 dur=abs(secondtime)-abs(firsttime);
|
tomwalters@0
|
44 nr_points=time2bin(ch,firsttime)-time2bin(ch,secondtime);
|
tomwalters@0
|
45 msig=linspace(1,0,nr_points);
|
tomwalters@0
|
46 ch=mult(ch,msig,secondtime,nr_points/sr);
|
tomwalters@0
|
47 if graphix plot(ch,'g');end
|
tomwalters@0
|
48
|
tomwalters@0
|
49 % scale all values between the second and third from 1 to dominant_scale_factor
|
tomwalters@0
|
50 thirdtime=-1/ch_fre*3;
|
tomwalters@0
|
51 dur=abs(thirdtime)-abs(secondtime);
|
tomwalters@0
|
52 nr_points=time2bin(ch,secondtime)-time2bin(ch,thirdtime);
|
tomwalters@0
|
53 msig=linspace(dominant_scale_factor,1,nr_points);
|
tomwalters@0
|
54 ch=mult(ch,msig,thirdtime,nr_points/sr);
|
tomwalters@0
|
55 if graphix plot(ch,'k');end
|
tomwalters@0
|
56
|
tomwalters@0
|
57 % scale all values between the third and six by dominant_scale_factor
|
tomwalters@0
|
58 sixtime=-1/ch_fre*6;
|
tomwalters@0
|
59 dur=abs(sixtime)-abs(thirdtime);
|
tomwalters@0
|
60 nr_points=time2bin(ch,thirdtime)-time2bin(ch,sixtime);
|
tomwalters@0
|
61 msig=ones(1,nr_points)*dominant_scale_factor;
|
tomwalters@0
|
62 if sixtime < starttime
|
tomwalters@0
|
63 sixtime=starttime;
|
tomwalters@0
|
64 nr_points=time2bin(ch,thirdtime)-time2bin(ch,sixtime);
|
tomwalters@0
|
65 msig=ones(1,nr_points)*dominant_scale_factor;
|
tomwalters@0
|
66 end
|
tomwalters@0
|
67 ch=mult(ch,msig,sixtime,nr_points/sr);
|
tomwalters@0
|
68 if graphix plot(ch,'y');end
|
tomwalters@0
|
69
|
tomwalters@0
|
70 % scale all values between the six and seven from dominant_scale_factor to 1
|
tomwalters@0
|
71 seventime=-1/ch_fre*7;
|
tomwalters@0
|
72 dur=abs(seventime)-abs(sixtime);
|
tomwalters@0
|
73 nr_points=time2bin(ch,sixtime)-time2bin(ch,seventime);
|
tomwalters@0
|
74 msig=linspace(1,dominant_scale_factor,nr_points);
|
tomwalters@0
|
75 if seventime < starttime
|
tomwalters@0
|
76 seventime=starttime;
|
tomwalters@0
|
77 nr_points=time2bin(ch,sixtime)-time2bin(ch,seventime);
|
tomwalters@0
|
78 msig=linspace(1,dominant_scale_factor,nr_points);
|
tomwalters@0
|
79 end
|
tomwalters@0
|
80 if nr_points > 0
|
tomwalters@0
|
81 ch=mult(ch,msig,seventime,nr_points/sr);
|
tomwalters@0
|
82 end
|
tomwalters@0
|
83 if graphix plot(ch,'c');end
|
tomwalters@0
|
84
|
tomwalters@0
|
85
|
tomwalters@0
|
86 % scale the amplitude of higher cf-channels down
|
tomwalters@0
|
87 cutoff=2000;
|
tomwalters@0
|
88 db_per_octave=6;
|
tomwalters@0
|
89 scaler=getfiltervalue(ch_fre,cutoff,db_per_octave);
|
tomwalters@0
|
90 ch=ch*scaler;
|
tomwalters@0
|
91
|
tomwalters@0
|
92
|
tomwalters@0
|
93
|
tomwalters@0
|
94
|
tomwalters@0
|
95
|
tomwalters@0
|
96 fr=setsinglechannel(fr,i,ch);
|
tomwalters@0
|
97
|
tomwalters@0
|
98 end
|
tomwalters@0
|
99
|
tomwalters@0
|
100
|
tomwalters@0
|
101
|