comparison toolboxes/MIRtoolbox1.3.2/AuditoryToolbox/WhiteVowel.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function [output,aCoeff] = WhiteVowel(data,sr,L,pos)
2 % function [output,aCoeff] = WhiteVowel(data,sr,L,pos)
3 %
4 % Speech is often described as having spectral peaks or formants which
5 % identify the phonetic signal. An interesting experiment, first proposed by
6 % XXX, filters a speech signal to remove all the formant information at one
7 % time during the speech. If there are no formant peaks, how can the speech
8 % be understood? It turns out that processing, much like RASTA, means that
9 % relative changes in spectrum are the most important, thus the speech signal
10 % is understood because the formant transitions carry the information. This
11 % gives speech an important transparency due
12 %
13 % This function takes a speech signal (data) with a given sampling rate (sr).
14 % It then finds the L-order LPC filter that describes the speech at the given
15 % position (pos ms). The entire speech signal is then filtered with the
16 % inverse of the LPC filter, effectively turning the speech spectrum at the
17 % given time white (flat).
18
19 % Chris Pal, Interval, May 1997
20 % (c) 1998 Interval Research Corporation
21
22 fr = 20; fs = 30; preemp = .9378; % LPC defaults
23
24 [row col] = size(data);
25 if col==1 data=data'; end
26
27 nframe = 0;
28 msfr = round(sr/1000*fr);
29 msfs = round(sr/1000*fs);
30 duration = length(data);
31 msoverlap = msfs - msfr;
32 frameNumber = floor(pos/1000*sr/msfr);
33
34 frameStart = round(pos/1000*sr - msfs/2);
35 frameData = data(frameStart:(frameStart+msfs-1));
36 aCoeff = proclpc(frameData, sr, L, fr, fs, preemp);
37 % Calculate the filter response
38 % by evaluating the z-transform
39 spec=lpc_spec(aCoeff);
40 subplot(2,3,1);
41 plot(spec);
42 title('LPC Spectral Slice');
43 ylabel('Original')
44
45 % Now do the actual whitening filter
46 output = filter(aCoeff,1,data)';
47
48 frameData = output(frameStart:(frameStart+msfs-1));
49 bCoeff = proclpc(frameData, sr, L, fr, fs, preemp);
50 spec=lpc_spec(bCoeff);
51 subplot(2,3,4);
52 plot(spec);
53 ylabel('Whitened'); xlabel('FFT Bin');
54
55 % 256-DFT
56 origSpec = 20*log10(abs(specgram(data,512,sr,msfs,msoverlap)));
57 subplot(2,3,2),imagesc(origSpec); axis xy; colormap(1-gray);
58 title('Spectrogram');
59
60 synSpec = 20*log10(abs(specgram(output,512,sr,msfs,msoverlap)));
61 subplot(2,3,5),imagesc(synSpec); axis xy; colormap(1-gray);
62 xlabel('Frame #');
63
64 origloc = origSpec(:,frameNumber); origloc=origloc-max(origloc);origmin=min(origloc);
65 subplot(2,3,3),plot(origloc),title('Spectrogram'),
66 axis([1 length(origloc) origmin 0]);
67
68 filloc = synSpec(:,frameNumber); filloc=filloc-max(filloc);
69 subplot(2,3,6),plot(filloc);ylabel('db');
70 axis([1 length(origloc) origmin 0]);
71 xlabel('FFT Bin');
72
73 function spec=lpc_spec(aCoeff)
74 gain=0;
75 cft=0:(1/255):1;
76 for index=1:size(aCoeff,1)
77 gain = gain + aCoeff(index)*exp(-i*2*pi*cft).^index;
78 end
79 gain = abs(1./gain);
80 spec = 20*log10(gain(1:128))';