├── Archives ├── Alphabet_Seb.m ├── Interaction_utilisateur_enregistrement_de_voix_30_11.m ├── MFCC_Extraction.m ├── checkSpectr.m ├── diffBetweenSignals.m ├── displaySignals.m ├── dp.m ├── dp2.m ├── dpfast.m ├── get_url.m ├── gui_guidata_guihandles.m ├── rastamat │ ├── audspec.m │ ├── bark2hz.m │ ├── cep2spec.m │ ├── deltas.m │ ├── dolpc.m │ ├── fft2barkmx.m │ ├── fft2melmx.m │ ├── hz2bark.m │ ├── hz2mel.m │ ├── invaudspec.m │ ├── invmelfcc.m │ ├── invpostaud.m │ ├── invpowspec.m │ ├── ispecgram.m │ ├── lifter.m │ ├── lpc2cep.m │ ├── lpc2spec.m │ ├── mel2hz.m │ ├── melfcc.m │ ├── postaud.m │ ├── powspec.m │ ├── process_options.m │ ├── rastafilt.m │ ├── rastaplp.m │ ├── readhtk.m │ └── spec2cep.m └── wavToSpectr.m ├── MATLAB_CODE_SOURCE ├── B.wav ├── C.wav ├── E.wav ├── F.wav ├── MFCC_Extraction_2.m ├── a.wav ├── cleanSignal.m ├── d.wav ├── diffBetweenSignals_newGen.m ├── dtw │ └── simmx.m ├── endpointdetection.m ├── g.wav ├── h.wav ├── i.wav ├── interface_graphique.m ├── j.wav ├── k.wav ├── l.wav ├── m.wav ├── n.wav ├── o.wav ├── p.wav ├── q.wav ├── r.wav ├── record.m ├── record2data.m ├── s.wav ├── silence-remover │ ├── ShortTimeEnergy.m │ ├── SpectralCentroid.m │ ├── detectVoiced.m │ └── findMaxima.m ├── t.wav ├── u.wav ├── v.wav ├── voicebox │ ├── Contents.m │ ├── activlev.m │ ├── atan2sc.m │ ├── axisenlarge.m │ ├── bark2frq.m │ ├── bitsprec.m │ ├── cblabel.m │ ├── ccwarpf.m │ ├── cent2frq.m │ ├── cep2pow.m │ ├── choosenk.m │ ├── choosrnk.m │ ├── correlogram.m │ ├── distchar.m │ ├── distchpf.m │ ├── disteusq.m │ ├── distisar.m │ ├── distispf.m │ ├── distitar.m │ ├── distitpf.m │ ├── ditherq.m │ ├── dlyapsq.m │ ├── dualdiag.m │ ├── dypsa.m │ ├── enframe.m │ ├── entropy.m │ ├── erb2frq.m │ ├── estnoiseg.m │ ├── estnoisem.m │ ├── ewgrpdel.m │ ├── fig2emf.m │ ├── figbolden.m │ ├── filtbankm.m │ ├── filterbank.m │ ├── finishat.m │ ├── flac.exe │ ├── fopenmkd.m │ ├── frac2bin.m │ ├── fram2wav.m │ ├── frq2bark.m │ ├── frq2cent.m │ ├── frq2erb.m │ ├── frq2mel.m │ ├── frq2midi.m │ ├── fxpefac.m │ ├── fxrapt.m │ ├── gammabank.m │ ├── gausprod.m │ ├── gaussmix.m │ ├── gaussmixd.m │ ├── gaussmixg.m │ ├── gaussmixk.m │ ├── gaussmixp.m │ ├── glotlf.m │ ├── glotros.m │ ├── gmmlpdf.m │ ├── histndim.m │ ├── hostipinfo.m │ ├── huffman.m │ ├── imagehomog.m │ ├── importsii.m │ ├── irdct.m │ ├── irfft.m │ ├── kmeanhar.m │ ├── kmeanlbg.m │ ├── kmeans.m │ ├── ldatrace.m │ ├── lin2pcma.m │ ├── lin2pcmu.m │ ├── lognmpdf.m │ ├── logsum.m │ ├── lpcaa2ao.m │ ├── lpcaa2dl.m │ ├── lpcaa2rf.m │ ├── lpcao2rf.m │ ├── lpcar2am.m │ ├── lpcar2cc.m │ ├── lpcar2db.m │ ├── lpcar2ff.m │ ├── lpcar2fm.m │ ├── lpcar2im.m │ ├── lpcar2ls.m │ ├── lpcar2pf.m │ ├── lpcar2pp.m │ ├── lpcar2ra.m │ ├── lpcar2rf.m │ ├── lpcar2rr.m │ ├── lpcar2zz.m │ ├── lpcauto.m │ ├── lpcbwexp.m │ ├── lpccc2ar.m │ ├── lpccc2cc.m │ ├── lpccc2db.m │ ├── lpccc2pf.m │ ├── lpcconv.m │ ├── lpccovar.m │ ├── lpccw2zz.m │ ├── lpcdb2pf.m │ ├── lpcdl2aa.m │ ├── lpcff2pf.m │ ├── lpcfq2zz.m │ ├── lpcifilt.m │ ├── lpcim2ar.m │ ├── lpcis2rf.m │ ├── lpcla2rf.m │ ├── lpclo2rf.m │ ├── lpcls2ar.m │ ├── lpcpf2cc.m │ ├── lpcpf2rr.m │ ├── lpcpp2cw.m │ ├── lpcpp2pz.m │ ├── lpcpz2zz.m │ ├── lpcra2pf.m │ ├── lpcra2pp.m │ ├── lpcrand.m │ ├── lpcrf2aa.m │ ├── lpcrf2ao.m │ ├── lpcrf2ar.m │ ├── lpcrf2is.m │ ├── lpcrf2la.m │ ├── lpcrf2lo.m │ ├── lpcrf2rr.m │ ├── lpcrr2am.m │ ├── lpcrr2ar.m │ ├── lpcss2zz.m │ ├── lpczz2ar.m │ ├── lpczz2cc.m │ ├── lpczz2ss.m │ ├── m2htmlpwd.m │ ├── maxfilt.m │ ├── maxgauss.m │ ├── meansqtf.m │ ├── mel2frq.m │ ├── melbankm.m │ ├── melcepst.m │ ├── midi2frq.m │ ├── minspane.m │ ├── mintrace.m │ ├── modspect.m │ ├── momfilt.m │ ├── mos2pesq.m │ ├── nearnonz.m │ ├── overlapadd.m │ ├── pcma2lin.m │ ├── pcmu2lin.m │ ├── peak2dquad.m │ ├── permutes.m │ ├── pesq2mos.m │ ├── phon2sone.m │ ├── polygonarea.m │ ├── polygonwind.m │ ├── polygonxline.m │ ├── potsband.m │ ├── pow2cep.m │ ├── psycdigit.m │ ├── psycest.m │ ├── psycestu.m │ ├── psychofunc.m │ ├── qrabs.m │ ├── qrdivide.m │ ├── qrdotdiv.m │ ├── qrdotmult.m │ ├── qrmult.m │ ├── qrpermute.m │ ├── quadpeak.m │ ├── randfilt.m │ ├── randiscr.m │ ├── randvec.m │ ├── rdct.m │ ├── readaif.m │ ├── readau.m │ ├── readcnx.m │ ├── readflac.m │ ├── readhtk.m │ ├── readsfs.m │ ├── readsph.m │ ├── readwav.m │ ├── rectifyhomog.m │ ├── rfft.m │ ├── rhartley.m │ ├── rnsubset.m │ ├── rotation.m │ ├── rotax2qr.m │ ├── roteu2qr.m │ ├── roteu2ro.m │ ├── rotmc2qc.m │ ├── rotmr2qr.m │ ├── rotpl2ro.m │ ├── rotqc2mc.m │ ├── rotqc2qr.m │ ├── rotqr2ax.m │ ├── rotqr2eu.m │ ├── rotqr2mr.m │ ├── rotqr2qc.m │ ├── rotqr2ro.m │ ├── rotqrmean.m │ ├── rotqrvec.m │ ├── rotro2eu.m │ ├── rotro2pl.m │ ├── rotro2qr.m │ ├── rsfft.m │ ├── sapisynth.m │ ├── schmitt.m │ ├── sigalign.m │ ├── sigma.m │ ├── skew3d.m │ ├── snrseg.m │ ├── sone2phon.m │ ├── soundspeed.m │ ├── specsub.m │ ├── specsubm.m │ ├── spgrambw.m │ ├── sphrharm.m │ ├── sprintsi.m │ ├── ssubmmse.m │ ├── stdspectrum.m │ ├── teager.m │ ├── txalign.m │ ├── unixwhich.m │ ├── upolyhedron.m │ ├── usasi.m │ ├── v_colormap.m │ ├── v_findpeaks.m │ ├── v_ppmvu.m │ ├── vadsohn.m │ ├── voicebox.m │ ├── windinfo.m │ ├── windows.m │ ├── winenvar.m │ ├── writehtk.m │ ├── writewav.m │ ├── xticksi.m │ ├── xyzticksi.m │ ├── yticksi.m │ ├── zerocros.m │ ├── zerotrim.m │ └── zoomfft.m ├── w.wav ├── x.wav ├── y.wav └── z.wav ├── README.md └── Sources.txt /Archives/Alphabet_Seb.m: -------------------------------------------------------------------------------- 1 | function [alphabet] = Alphabet_Seb 2 | 3 | alphabet{1,1}= audioread('A_SEB_16Khz.wav'); 4 | 5 | alphabet{1,2}= audioread('B_SEB_16Khz.wav'); 6 | 7 | alphabet{1,3}= audioread('C_SEB_16Khz.wav'); 8 | 9 | alphabet{1,4}= audioread('D_SEB_16Khz.wav'); 10 | 11 | alphabet{1,5}= audioread('E_SEB_16Khz.wav'); 12 | 13 | alphabet{1,6}= audioread('F_SEB_16Khz.wav'); 14 | 15 | alphabet{1,7}= audioread('G_SEB_16Khz.wav'); 16 | 17 | alphabet{1,8}= audioread('U_SEB_16Khz.wav'); 18 | 19 | alphabet{1,9}= audioread('M_SEB_16Khz.wav'); 20 | 21 | alphabet{1,10}= audioread('L_SEB_16Khz.wav'); -------------------------------------------------------------------------------- /Archives/Interaction_utilisateur_enregistrement_de_voix_30_11.m: -------------------------------------------------------------------------------- 1 | %Enregistrer une voix% 2 | 3 | Fs = 11025 4 | rec = audiorecorder(Fs, 16, 2); 5 | 6 | disp('Appuyez sur une touche pour enregistrer un son'); 7 | w = waitforbuttonpress; 8 | 9 | if (w == 0 || w == 1 ) 10 | record(rec); 11 | 12 | end 13 | 14 | disp('Appuyez sur une touche pour terminer l''enregistrement'); 15 | w1 = waitforbuttonpress; 16 | 17 | if (w == 0 || w == 1 ) 18 | record(rec); 19 | 20 | end 21 | 22 | stop(rec) 23 | 24 | play(rec) -------------------------------------------------------------------------------- /Archives/MFCC_Extraction.m: -------------------------------------------------------------------------------- 1 | A = audioread('a.wav'); 2 | AWindowed = A.*hamming(length(A)); 3 | AFft = fft(AWindowed); 4 | ATriangle = AFft.*bartlett(length(AFft)); 5 | ALog = log(ATriangle); 6 | ADct = dct(ALog); 7 | plot(ADct); 8 | disp(ADct); -------------------------------------------------------------------------------- /Archives/checkSpectr.m: -------------------------------------------------------------------------------- 1 | function diff = checkSpectr( spec1 , spec2 ) 2 | % abs( spec ) is already done 3 | M = simmx( spec1 , spec2 ); 4 | 5 | [p,q,D] = dp(1-M); 6 | % p & q the best path 7 | % D the cumulate matrix 8 | 9 | diff = D(size(D,1),size(D,2)) ; 10 | end -------------------------------------------------------------------------------- /Archives/diffBetweenSignals.m: -------------------------------------------------------------------------------- 1 | function [matches] = diffBetweenSignals(word,alphabet) 2 | 3 | delimitations = detectVoiced(word, 8000); 4 | lpcDico = cell(1,length(alphabet)); 5 | 6 | for i=1:length(alphabet) 7 | % lpcDico{i} = lpc(alphabet{i},100); 8 | % wavToSpectr(alphabet{i},8000) 9 | % alphabet{i} 10 | lpcDico{i} = wavToSpectr(alphabet{i},8000); 11 | end 12 | 13 | temp = 9999; 14 | matches = zeros(1,length(delimitations)); 15 | currentLetter = 0; 16 | 17 | for i=1:length(delimitations) 18 | % lpcLetter = lpc(delimitations{i},100); 19 | specLetter = wavToSpectr(delimitations{i}, 8000); 20 | for j=1:length(alphabet) 21 | % tLpcLetter = lpcLetter; 22 | % tLpcDico = lpcDico{j}; 23 | % if length(tLpcLetter) < length(tLpcDico) 24 | % tLpcLetter(length(tLpcDico)) = 0; 25 | % elseif length(tLpcLetter) > length(tLpcDico) 26 | % tLpcDico(length(tLpcLetter)) = 0; 27 | % end 28 | % subplot(length(alphabet),1,j); 29 | % plot([1:101],tLpcLetter,[1:101],tLpcDico); 30 | % diff = sqrt(sum((tLpcLetter-tLpcDico).^2)); 31 | diff = checkSpectr(specLetter, lpcDico{j}) 32 | % temp 33 | if diff < temp 34 | temp = diff; 35 | currentLetter = j; 36 | end 37 | % k = waitforbuttonpress 38 | end 39 | matches(i) = currentLetter; 40 | currentLetter = 0; 41 | temp = 9999; 42 | end 43 | end -------------------------------------------------------------------------------- /Archives/displaySignals.m: -------------------------------------------------------------------------------- 1 | function displaySignals(signals) 2 | for i=1:length(signals) 3 | subplot(length(signals),1,i); 4 | plot(cell2mat(signals(i))); 5 | end 6 | end -------------------------------------------------------------------------------- /Archives/dp.m: -------------------------------------------------------------------------------- 1 | function [p,q,D] = dp(M) 2 | % [p,q] = dp(M) 3 | % Use dynamic programming to find a min-cost path through matrix M. 4 | % Return state sequence in p,q 5 | % 2003-03-15 dpwe@ee.columbia.edu 6 | 7 | % Copyright (c) 2003 Dan Ellis 8 | % released under GPL - see file COPYRIGHT 9 | 10 | [r,c] = size(M); 11 | 12 | % costs 13 | D = zeros(r+1, c+1); 14 | D(1,:) = NaN; 15 | D(:,1) = NaN; 16 | D(1,1) = 0; 17 | D(2:(r+1), 2:(c+1)) = M; 18 | 19 | % traceback 20 | phi = zeros(r,c); 21 | 22 | for i = 1:r; 23 | for j = 1:c; 24 | [dmax, tb] = min([D(i, j), D(i, j+1), D(i+1, j)]); 25 | D(i+1,j+1) = D(i+1,j+1)+dmax; 26 | phi(i,j) = tb; 27 | end 28 | end 29 | 30 | % Traceback from top left 31 | i = r; 32 | j = c; 33 | p = i; 34 | q = j; 35 | while i > 1 & j > 1 36 | tb = phi(i,j); 37 | if (tb == 1) 38 | i = i-1; 39 | j = j-1; 40 | elseif (tb == 2) 41 | i = i-1; 42 | elseif (tb == 3) 43 | j = j-1; 44 | else 45 | error; 46 | end 47 | p = [i,p]; 48 | q = [j,q]; 49 | end 50 | 51 | % Strip off the edges of the D matrix before returning 52 | D = D(2:(r+1),2:(c+1)); -------------------------------------------------------------------------------- /Archives/dp2.m: -------------------------------------------------------------------------------- 1 | function [p,q,D] = dp2(M) 2 | % [p,q] = dp2(M) 3 | % Use dynamic programming to find a min-cost path through matrix M. 4 | % Return state sequence in p,q 5 | % This version has limited slopes [2/1] .. [1/2] 6 | % 2003-03-15 dpwe@ee.columbia.edu 7 | 8 | % Copyright (c) 2003 Dan Ellis 9 | % released under GPL - see file COPYRIGHT 10 | 11 | [r,c] = size(M); 12 | 13 | % costs 14 | D = zeros(r+1, c+1); 15 | D(1,:) = NaN; 16 | D(:,1) = NaN; 17 | D(1,1) = 0; 18 | D(2:(r+1), 2:(c+1)) = M; 19 | 20 | % traceback 21 | phi = zeros(r+1,c+1); 22 | 23 | for i = 2:r+1; 24 | for j = 2:c+1; 25 | % Scale the 'longer' steps to discourage skipping ahead 26 | kk1 = 2; 27 | kk2 = 1; 28 | dd = D(i,j); 29 | [dmax, tb] = min([D(i-1, j-1)+dd, D(max(1,i-2), j-1)+dd*kk1, D(i-1, max(1,j-2))+dd*kk1, D(i-1,j)+kk2*dd, D(i,j-1)+kk2*dd]); 30 | D(i,j) = dmax; 31 | phi(i,j) = tb; 32 | end 33 | end 34 | 35 | % Traceback from top left 36 | i = r+1; 37 | j = c+1; 38 | p = i; 39 | q = j; 40 | while i > 2 & j > 2 41 | tb = phi(i,j); 42 | if (tb == 1) 43 | i = i-1; 44 | j = j-1; 45 | elseif (tb == 2) 46 | i = i-2; 47 | j = j-1; 48 | elseif (tb == 3) 49 | j = j-2; 50 | i = i-1; 51 | elseif (tb == 4) 52 | i = i-1; 53 | j = j; 54 | elseif (tb == 5) 55 | j = j-1; 56 | i = i; 57 | else 58 | error; 59 | end 60 | p = [i,p]; 61 | q = [j,q]; 62 | end 63 | 64 | % Strip off the edges of the D matrix before returning 65 | D = D(2:(r+1),2:(c+1)); 66 | 67 | % map down p and q 68 | p = p-1; 69 | q = q-1; -------------------------------------------------------------------------------- /Archives/get_url.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/Archives/get_url.m -------------------------------------------------------------------------------- /Archives/gui_guidata_guihandles.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/Archives/gui_guidata_guihandles.m -------------------------------------------------------------------------------- /Archives/rastamat/audspec.m: -------------------------------------------------------------------------------- 1 | function [aspectrum,wts] = audspec(pspectrum, sr, nfilts, fbtype, minfreq, maxfreq, sumpower, bwidth) 2 | %[aspectrum,wts] = audspec(pspectrum, sr, nfilts, fbtype, minfreq, maxfreq, sumpower, bwidth) 3 | % 4 | % perform critical band analysis (see PLP) 5 | % takes power spectrogram as input 6 | 7 | if nargin < 2; sr = 16000; end 8 | if nargin < 3; nfilts = ceil(hz2bark(sr/2))+1; end 9 | if nargin < 4; fbtype = 'bark'; end 10 | if nargin < 5; minfreq = 0; end 11 | if nargin < 6; maxfreq = sr/2; end 12 | if nargin < 7; sumpower = 1; end 13 | if nargin < 8; bwidth = 1.0; end 14 | 15 | [nfreqs,nframes] = size(pspectrum); 16 | 17 | nfft = (nfreqs-1)*2; 18 | 19 | if strcmp(fbtype, 'bark') 20 | wts = fft2barkmx(nfft, sr, nfilts, bwidth, minfreq, maxfreq); 21 | elseif strcmp(fbtype, 'mel') 22 | wts = fft2melmx(nfft, sr, nfilts, bwidth, minfreq, maxfreq); 23 | elseif strcmp(fbtype, 'htkmel') 24 | wts = fft2melmx(nfft, sr, nfilts, bwidth, minfreq, maxfreq, 1, 1); 25 | elseif strcmp(fbtype, 'fcmel') 26 | wts = fft2melmx(nfft, sr, nfilts, bwidth, minfreq, maxfreq, 1, 0); 27 | else 28 | disp(['fbtype ', fbtype, ' not recognized']); 29 | error; 30 | end 31 | 32 | wts = wts(:, 1:nfreqs); 33 | 34 | % Integrate FFT bins into Mel bins, in abs or abs^2 domains: 35 | if (sumpower) 36 | aspectrum = wts * pspectrum; 37 | else 38 | aspectrum = (wts * sqrt(pspectrum)).^2; 39 | end 40 | 41 | -------------------------------------------------------------------------------- /Archives/rastamat/bark2hz.m: -------------------------------------------------------------------------------- 1 | function hz=bark2hz(z) 2 | % BARK2HZ Converts frequencies Bark to Hertz (Hz) 3 | % function hz=bark2hz(z) 4 | % Traunmueller-formula for z > 2 Bark 5 | % linear mapping for z <= 2 Bark 6 | % 7 | % Author: Kyrill, Oct. 1996 8 | % Kyrill, March 1997 (linear mapping added) 9 | % 10 | 11 | %hz_gt_2 = 1960 .* (z + 0.53) ./ (26.28 - z); 12 | %hz_le_2 = z .* 102.9; 13 | % 14 | %hz = (z>2) .* hz_gt_2 + (z<=2) .* hz_le_2; 15 | 16 | % Hynek's formula (2003-04-11 dpwe@ee.columbia.edu) 17 | % (taken from rasta/audspec.c) 18 | hz = 600 * sinh(z/6); 19 | -------------------------------------------------------------------------------- /Archives/rastamat/cep2spec.m: -------------------------------------------------------------------------------- 1 | function [spec,idctm] = cep2spec(cep, nfreq, type) 2 | % spec = cep2spec(cep, nfreq, type) 3 | % Reverse the cepstrum to recover a spectrum. 4 | % i.e. converse of spec2cep 5 | % nfreq is how many points to reconstruct in spec 6 | % 2005-05-15 dpwe@ee.columbia.edu 7 | 8 | if nargin < 2; nfreq = 21; end 9 | if nargin < 3; type = 2; end % type of DCT 10 | 11 | [ncep,ncol] = size(cep); 12 | 13 | % Make the DCT matrix 14 | dctm = zeros(ncep, nfreq); 15 | idctm = zeros(nfreq, ncep); 16 | if type == 2 || type == 3 17 | % this is the orthogonal one, so inv matrix is same as fwd matrix 18 | for i = 1:ncep 19 | dctm(i,:) = cos((i-1)*[1:2:(2*nfreq-1)]/(2*nfreq)*pi) * sqrt(2/nfreq); 20 | end 21 | if type == 2 22 | % make it unitary! (but not for HTK type 3) 23 | dctm(1,:) = dctm(1,:)/sqrt(2); 24 | else 25 | dctm(1,:) = dctm(1,:)/2; 26 | end 27 | idctm = dctm'; 28 | elseif type == 4 % type 1 with implicit repetition of first, last bins 29 | % so all we do is reconstruct the middle nfreq rows of an nfreq+2 row idctm 30 | for i = 1:ncep 31 | % 2x to compensate for fact that only getting +ve freq half 32 | idctm(:,i) = 2*cos((i-1)*[1:nfreq]'/(nfreq+1)*pi); 33 | end 34 | % fixup 'non-repeated' basis fns 35 | idctm(:, [1 ncep]) = idctm(:, [1 ncep])/2; 36 | else % dpwe type 1 - idft of cosine terms 37 | for i = 1:ncep 38 | % 2x to compensate for fact that only getting +ve freq half 39 | idctm(:,i) = 2*cos((i-1)*[0:(nfreq-1)]'/(nfreq-1)*pi); 40 | end 41 | % fixup 'non-repeated' basis fns 42 | idctm(:, [1 ncep]) = 0.5* idctm(:, [1 ncep]); 43 | end 44 | 45 | spec = exp(idctm*cep); 46 | -------------------------------------------------------------------------------- /Archives/rastamat/deltas.m: -------------------------------------------------------------------------------- 1 | function d = deltas(x, w) 2 | % D = deltas(X,W) Calculate the deltas (derivatives) of a sequence 3 | % Use a W-point window (W odd, default 9) to calculate deltas using a 4 | % simple linear slope. This mirrors the delta calculation performed 5 | % in feacalc etc. Each row of X is filtered separately. 6 | % 2003-06-30 dpwe@ee.columbia.edu 7 | 8 | if nargin < 2 9 | w = 9; 10 | end 11 | 12 | [nr,nc] = size(x); 13 | 14 | if nc == 0 15 | % empty vector passed in; return empty vector 16 | d = x; 17 | 18 | else 19 | % actually calculate deltas 20 | 21 | % Define window shape 22 | hlen = floor(w/2); 23 | w = 2*hlen + 1; 24 | win = hlen:-1:-hlen; 25 | 26 | % pad data by repeating first and last columns 27 | xx = [repmat(x(:,1),1,hlen),x,repmat(x(:,end),1,hlen)]; 28 | 29 | % Apply the delta filter 30 | d = filter(win, 1, xx, [], 2); % filter along dim 2 (rows) 31 | 32 | % Trim edges 33 | d = d(:,2*hlen + [1:nc]); 34 | 35 | end 36 | -------------------------------------------------------------------------------- /Archives/rastamat/dolpc.m: -------------------------------------------------------------------------------- 1 | function y = dolpc(x,modelorder) 2 | %y = dolpc(x,modelorder) 3 | % 4 | % compute autoregressive model from spectral magnitude samples 5 | % 6 | % rows(x) = critical band 7 | % col(x) = frame 8 | % 9 | % row(y) = lpc a_i coeffs, scaled by gain 10 | % col(y) = frame 11 | % 12 | % modelorder is order of model, defaults to 8 13 | % 2003-04-12 dpwe@ee.columbia.edu after shire@icsi.berkeley.edu 14 | 15 | [nbands,nframes] = size(x); 16 | 17 | if nargin < 2 18 | modelorder = 8; 19 | end 20 | 21 | % Calculate autocorrelation 22 | r = real(ifft([x;x([(nbands-1):-1:2],:)])); 23 | % First half only 24 | r = r(1:nbands,:); 25 | 26 | % Find LPC coeffs by durbin 27 | [y,e] = levinson(r, modelorder); 28 | 29 | % Normalize each poly by gain 30 | y = y'./repmat(e',(modelorder+1),1); 31 | -------------------------------------------------------------------------------- /Archives/rastamat/fft2barkmx.m: -------------------------------------------------------------------------------- 1 | function wts = fft2barkmx(nfft, sr, nfilts, width, minfreq, maxfreq) 2 | % wts = fft2barkmx(nfft, sr, nfilts, width, minfreq, maxfreq) 3 | % Generate a matrix of weights to combine FFT bins into Bark 4 | % bins. nfft defines the source FFT size at sampling rate sr. 5 | % Optional nfilts specifies the number of output bands required 6 | % (else one per bark), and width is the constant width of each 7 | % band in Bark (default 1). 8 | % While wts has nfft columns, the second half are all zero. 9 | % Hence, Bark spectrum is fft2barkmx(nfft,sr)*abs(fft(xincols,nfft)); 10 | % 2004-09-05 dpwe@ee.columbia.edu based on rastamat/audspec.m 11 | 12 | if nargin < 3; nfilts = 0; end 13 | if nargin < 4; width = 1.0; end 14 | if nargin < 5; minfreq = 0; end 15 | if nargin < 6; maxfreq = sr/2; end 16 | 17 | min_bark = hz2bark(minfreq); 18 | nyqbark = hz2bark(maxfreq) - min_bark; 19 | if nfilts == 0 20 | nfilts = ceil(nyqbark)+1; 21 | end 22 | 23 | wts = zeros(nfilts, nfft); 24 | 25 | % bark per filt 26 | step_barks = nyqbark/(nfilts-1); 27 | 28 | % Frequency of each FFT bin in Bark 29 | binbarks = hz2bark([0:nfft/2]*sr/nfft); 30 | 31 | for i = 1:nfilts 32 | f_bark_mid = min_bark + (i-1) * step_barks; 33 | % Linear slopes in log-space (i.e. dB) intersect to trapezoidal window 34 | lof = (binbarks - f_bark_mid - 0.5); 35 | hif = (binbarks - f_bark_mid + 0.5); 36 | wts(i,1:(nfft/2+1)) = 10.^(min(0, min([hif; -2.5*lof])/width)); 37 | end 38 | 39 | function z = hz2bark(f) 40 | % HZ2BARK Converts frequencies Hertz (Hz) to Bark 41 | % taken from rastamat 42 | z = 6 * asinh(f/600); 43 | -------------------------------------------------------------------------------- /Archives/rastamat/hz2bark.m: -------------------------------------------------------------------------------- 1 | function z= hz2bark(f) 2 | % HZ2BARK Converts frequencies Hertz (Hz) to Bark 3 | % function z= hz2bark(f) 4 | % Uses 5 | % Traunmueller-formula for f > 200 Hz 6 | % linear mapping for f <= 200 Hz 7 | % 8 | % Author: Kyrill, Oct. 1996 9 | % Kyrill, March 1997 (linear mapping added) 10 | % 11 | 12 | %z_gt_200 = 26.81 .* f ./ (1960 + f) - 0.53; 13 | %z_le_200 = f ./ 102.9; 14 | % 15 | %z = (f>200) .* z_gt_200 + (f<=200) .* z_le_200; 16 | 17 | % Inverse of Hynek's formula (see bark2hz) 18 | z = 6 * asinh(f/600); 19 | 20 | % Formula used in rasta/rasta.h 21 | %z = 6 * log(f/600 + sqrt(1+ ((f/600).^2))); 22 | % They are the same! -------------------------------------------------------------------------------- /Archives/rastamat/hz2mel.m: -------------------------------------------------------------------------------- 1 | function z = hz2mel(f,htk) 2 | % z = hz2mel(f,htk) 3 | % Convert frequencies f (in Hz) to mel 'scale'. 4 | % Optional htk = 1 uses the mel axis defined in the HTKBook 5 | % otherwise use Slaney's formula 6 | % 2005-04-19 dpwe@ee.columbia.edu 7 | 8 | if nargin < 2 9 | htk = 0; 10 | end 11 | 12 | if htk == 1 13 | z = 2595 * log10(1+f/700); 14 | else 15 | % Mel fn to match Slaney's Auditory Toolbox mfcc.m 16 | 17 | f_0 = 0; % 133.33333; 18 | f_sp = 200/3; % 66.66667; 19 | brkfrq = 1000; 20 | brkpt = (brkfrq - f_0)/f_sp; % starting mel value for log region 21 | logstep = exp(log(6.4)/27); % the magic 1.0711703 which is the ratio needed to get from 1000 Hz to 6400 Hz in 27 steps, and is *almost* the ratio between 1000 Hz and the preceding linear filter center at 933.33333 Hz (actually 1000/933.33333 = 1.07142857142857 and exp(log(6.4)/27) = 1.07117028749447) 22 | 23 | linpts = (f < brkfrq); 24 | 25 | z = 0*f; 26 | 27 | % fill in parts separately 28 | z(linpts) = (f(linpts) - f_0)/f_sp; 29 | z(~linpts) = brkpt+(log(f(~linpts)/brkfrq))./log(logstep); 30 | 31 | end 32 | -------------------------------------------------------------------------------- /Archives/rastamat/invaudspec.m: -------------------------------------------------------------------------------- 1 | function [spec,wts,iwts] = invaudspec(aspectrum, sr, nfft, fbtype, minfreq, maxfreq, sumpower, bwidth) 2 | %pspectrum = invaudspec(aspectrum, sr, nfft, fbtype, minfreq, maxfreq, sumpower, bwidth) 3 | % 4 | % Invert (as best we can) the effects of audspec() 5 | % 6 | % 2004-02-04 dpwe@ee.columbia.edu 7 | 8 | if nargin < 2; sr = 16000; end 9 | if nargin < 3; nfft = 512; end 10 | if nargin < 4; fbtype = 'bark'; end 11 | if nargin < 5; minfreq = 0; end 12 | if nargin < 6; maxfreq = sr/2; end 13 | if nargin < 7; sumpower = 1; end 14 | if nargin < 8; bwidth = 1.0; end 15 | 16 | [nfilts,nframes] = size(aspectrum); 17 | 18 | if strcmp(fbtype, 'bark') 19 | wts = fft2barkmx(nfft, sr, nfilts, bwidth, minfreq, maxfreq); 20 | elseif strcmp(fbtype, 'mel') 21 | wts = fft2melmx(nfft, sr, nfilts, bwidth, minfreq, maxfreq); 22 | elseif strcmp(fbtype, 'htkmel') 23 | wts = fft2melmx(nfft, sr, nfilts, bwidth, minfreq, maxfreq, 1, 1); 24 | elseif strcmp(fbtype, 'fcmel') 25 | wts = fft2melmx(nfft, sr, nfilts, bwidth, minfreq, maxfreq, 1); 26 | else 27 | disp(['fbtype ', fbtype, ' not recognized']); 28 | error; 29 | end 30 | 31 | % Cut off 2nd half 32 | wts = wts(:,1:((nfft/2)+1)); 33 | 34 | % Just transpose, fix up 35 | ww = wts'*wts; 36 | iwts = wts'./(repmat(max(mean(diag(ww))/100, sum(ww))',1,nfilts)); 37 | % Apply weights 38 | if (sumpower) 39 | spec = iwts * aspectrum; 40 | else 41 | spec = (iwts * sqrt(aspectrum)).^2; 42 | end 43 | 44 | -------------------------------------------------------------------------------- /Archives/rastamat/invmelfcc.m: -------------------------------------------------------------------------------- 1 | function [x,aspc,spec] = invmelfcc(cep, sr, varargin) 2 | % [x,aspc,spec] = invmelfcc(cep, sr[, opts ...]) 3 | % Attempt to invert plp cepstra back to a full spectrum 4 | % and even a waveform. Takes all the same options as melfcc. 5 | % x is (noise-excited) time domain waveform; aspc is the 6 | % auditory spectrogram, spec is the |STFT| spectrogram. 7 | % 2005-05-15 dpwe@ee.columbia.edu 8 | 9 | % Parse out the optional arguments 10 | [wintime, hoptime, numcep, lifterexp, sumpower, preemph, dither, ... 11 | minfreq, maxfreq, nbands, bwidth, dcttype, fbtype, usecmp, modelorder, broaden, excitation] = ... 12 | process_options(varargin, 'wintime', 0.025, 'hoptime', 0.010, ... 13 | 'numcep', 13, 'lifterexp', 0.6, 'sumpower', 1, 'preemph', 0.97, ... 14 | 'dither', 0, 'minfreq', 0, 'maxfreq', 4000, ... 15 | 'nbands', 40, 'bwidth', 1.0, 'dcttype', 2, ... 16 | 'fbtype', 'mel', 'usecmp', 0, 'modelorder', 0, 'broaden', ... 17 | 0, 'excitation', []); 18 | 19 | winpts = round(wintime*sr); 20 | nfft = 2^(ceil(log(winpts)/log(2))); 21 | 22 | cep = lifter(cep, lifterexp, 1); % 3rd arg nonzero means undo liftering 23 | 24 | % Need to reconstruct the two extra flanking bands for invpostaud to delete 25 | % (if we're doing usecmp) 26 | pspc = cep2spec(cep, nbands+2*broaden, dcttype); 27 | 28 | if (usecmp) 29 | aspc = invpostaud(pspc, maxfreq, fbtype, broaden); 30 | else 31 | aspc = pspc; 32 | end 33 | 34 | % Undo the auditory spectrum 35 | spec = invaudspec(aspc, sr, nfft, fbtype, minfreq, maxfreq, sumpower, bwidth); 36 | 37 | % Back to waveform (modulate white noise, or specified excitation) 38 | x = invpowspec(spec, sr, wintime, hoptime, excitation); 39 | 40 | if preemph ~= 0 41 | % Undo the original preemphasis 42 | x = filter(1, [1 -preemph], x); 43 | end 44 | -------------------------------------------------------------------------------- /Archives/rastamat/invpostaud.m: -------------------------------------------------------------------------------- 1 | function [x,eql] = invpostaud(y,fmax,fbtype,broaden) 2 | %x = postaud(y,fmax,fbtype) 3 | % 4 | % invert the effects of postaud (loudness equalization and cube 5 | % root compression) 6 | % y = postaud output 7 | % x = reconstructed critical band filters 8 | % rows = critical bands 9 | % cols = frames 10 | 11 | if nargin < 3 12 | fbtype = 'bark'; 13 | end 14 | if nargin < 4 15 | % By default, don't add extra flanking bands 16 | broaden = 0; 17 | end 18 | 19 | [nbands,nframes] = size(y); 20 | 21 | % equal loundness weights stolen from rasta code 22 | %eql = [0.000479 0.005949 0.021117 0.044806 0.073345 0.104417 0.137717 ... 23 | % 0.174255 0.215590 0.263260 0.318302 0.380844 0.449798 0.522813 0.596597]; 24 | 25 | if strcmp(fbtype, 'bark') 26 | bandcfhz = bark2hz(linspace(0, hz2bark(fmax), nbands)); 27 | elseif strcmp(fbtype, 'mel') 28 | bandcfhz = mel2hz(linspace(0, hz2mel(fmax), nbands)); 29 | elseif strcmp(fbtype, 'htkmel') || strcmp(fbtype, 'fcmel') 30 | bandcfhz = mel2hz(linspace(0, hz2mel(fmax,1), nbands),1); 31 | else 32 | disp(['unknown fbtype', fbtype]); 33 | error; 34 | end 35 | 36 | % Remove extremal bands (the ones that got duplicated) 37 | bandcfhz = bandcfhz((1+broaden):(nbands-broaden)); 38 | 39 | % Hynek's magic equal-loudness-curve formula 40 | fsq = bandcfhz.^2; 41 | ftmp = fsq + 1.6e5; 42 | eql = ((fsq./ftmp).^2) .* ((fsq + 1.44e6)./(fsq + 9.61e6)); 43 | 44 | 45 | % cube expand 46 | x = y .^ (1/.33); 47 | 48 | %% squash the zero in the eql curve 49 | if eql(1) == 0 % or maybe always 50 | eql(1) = eql(2); 51 | eql(end) = eql(end-1); 52 | end 53 | 54 | % weight the critical bands 55 | x = x((1+broaden):(nbands-broaden),:)./repmat(eql',1,nframes); 56 | 57 | -------------------------------------------------------------------------------- /Archives/rastamat/invpowspec.m: -------------------------------------------------------------------------------- 1 | function x = invpowspec(y, sr, wintime, steptime, excit) 2 | %x = invpowspec(y, sr, wintime, steptime, excit) 3 | % 4 | % Attempt to go back from specgram-like powerspec to audio waveform 5 | % by scaling specgram of white noise 6 | % 7 | % default values: 8 | % sr = 8000Hz 9 | % wintime = 25ms (200 samps) 10 | % steptime = 10ms (80 samps) 11 | % which means use 256 point fft 12 | % hamming window 13 | % 14 | % excit is input excitation; white noise is used if not specified 15 | 16 | % for sr = 8000 17 | %NFFT = 256; 18 | %NOVERLAP = 120; 19 | %SAMPRATE = 8000; 20 | %WINDOW = hamming(200); 21 | 22 | [nrow, ncol] = size(y); 23 | 24 | if nargin < 2 25 | sr = 8000; 26 | end 27 | if nargin < 3 28 | wintime = 0.025; 29 | end 30 | if nargin < 4 31 | steptime = 0.010; 32 | end 33 | if nargin < 5 34 | r = []; 35 | else 36 | r = excit; 37 | end 38 | 39 | winpts = round(wintime*sr); 40 | steppts = round(steptime*sr); 41 | 42 | NFFT = 2^(ceil(log(winpts)/log(2))); 43 | 44 | if NFFT ~= 2*(nrow-1) 45 | disp('Inferred FFT size doesn''t match specgram'); 46 | end 47 | 48 | NOVERLAP = winpts - steppts; 49 | SAMPRATE = sr; 50 | 51 | % Values coming out of rasta treat samples as integers, 52 | % not range -1..1, hence scale up here to match (approx) 53 | %y = abs(specgram(x*32768,NFFT,SAMPRATE,WINDOW,NOVERLAP)).^2; 54 | 55 | xlen = winpts + steppts*(ncol - 1); 56 | 57 | if length(r) == 0 58 | r = randn(xlen,1); 59 | end 60 | r = r(1:xlen); 61 | 62 | R = specgram(r/32768/12, NFFT, SAMPRATE, winpts, NOVERLAP); 63 | R = R .* sqrt(y);; 64 | x = ispecgram(R, NFFT, SAMPRATE, winpts, NOVERLAP); 65 | -------------------------------------------------------------------------------- /Archives/rastamat/ispecgram.m: -------------------------------------------------------------------------------- 1 | function x = ispecgram(d, ftsize, sr, win, nov) 2 | % X = ispecgram(D, F, SR, WIN, NOV) Inverse specgram 3 | % Overlap-add the inverse of the output of specgram 4 | % ftsize is implied by sizeof d, sr is ignored, nov defaults to ftsize/2 5 | % dpwe 2005may16. after istft 6 | 7 | [nspec,ncol] = size(d); 8 | 9 | if nargin < 2 10 | ftsize = 2*(nspec-1); 11 | end 12 | if nargin < 3 13 | % who cares? 14 | end 15 | if nargin < 4 16 | win = ftsize; % doesn't matter either - assume it added up OK 17 | end 18 | if nargin < 5 19 | nov = ftsize/2; 20 | end 21 | 22 | hop = win - nov; 23 | 24 | if nspec ~= (ftsize/2)+1 25 | error('number of rows should be fftsize/2+1') 26 | end 27 | 28 | xlen = ftsize + (ncol-1) * hop; 29 | x = zeros(xlen,1); 30 | 31 | halff = ftsize/2; % midpoint of win 32 | 33 | % No reconstruction win (for now...) 34 | 35 | for c = 1:ncol 36 | ft = d(:,c); 37 | ft = [ft(1:(ftsize/2+1)); conj(ft([(ftsize/2):-1:2]))]; 38 | 39 | if max(imag(ifft(ft))) > 1e-5 40 | disp('imag oflow'); 41 | end 42 | 43 | px = real(ifft(ft)); % no shift in specgram 44 | 45 | b = (c-1)*hop; 46 | x(b+[1:ftsize]) = x(b+[1:ftsize]) + px; 47 | end; 48 | 49 | x = x * win/ftsize; % scale amplitude 50 | 51 | -------------------------------------------------------------------------------- /Archives/rastamat/lifter.m: -------------------------------------------------------------------------------- 1 | function y = lifter(x, lift, invs) 2 | % y = lifter(x, lift, invs) 3 | % Apply lifter to matrix of cepstra (one per column) 4 | % lift = exponent of x i^n liftering 5 | % or, as a negative integer, the length of HTK-style sin-curve liftering. 6 | % If inverse == 1 (default 0), undo the liftering. 7 | % 2005-05-19 dpwe@ee.columbia.edu 8 | 9 | if nargin < 2; lift = 0.6; end % liftering exponent 10 | if nargin < 3; invs = 0; end % flag to undo liftering 11 | 12 | [ncep, nfrm] = size(x); 13 | 14 | if lift == 0 15 | y = x; 16 | else 17 | 18 | if lift > 0 19 | if lift > 10 20 | disp(['Unlikely lift exponent of ', num2str(lift),' (did you mean -ve?)']); 21 | end 22 | liftwts = [1, ([1:(ncep-1)].^lift)]; 23 | elseif lift < 0 24 | % Hack to support HTK liftering 25 | L = -lift; 26 | if (L ~= round(L)) 27 | disp(['HTK liftering value ', num2str(L),' must be integer']); 28 | end 29 | liftwts = [1, (1+L/2*sin([1:(ncep-1)]*pi/L))]; 30 | end 31 | 32 | if (invs) 33 | liftwts = 1./liftwts; 34 | end 35 | 36 | y = diag(liftwts)*x; 37 | 38 | end 39 | -------------------------------------------------------------------------------- /Archives/rastamat/lpc2cep.m: -------------------------------------------------------------------------------- 1 | function features = lpc2cep(a,nout) 2 | % features = lpc2cep(lpcas,nout) 3 | % Convert the LPC 'a' coefficients in each column of lpcas 4 | % into frames of cepstra. 5 | % nout is number of cepstra to produce, defaults to size(lpcas,1) 6 | % 2003-04-11 dpwe@ee.columbia.edu 7 | 8 | [nin, ncol] = size(a); 9 | 10 | order = nin - 1; 11 | 12 | if nargin < 2 13 | nout = order + 1; 14 | end 15 | 16 | c = zeros(nout, ncol); 17 | 18 | % Code copied from HSigP.c: LPC2Cepstrum 19 | 20 | % First cep is log(Error) from Durbin 21 | c(1,:) = -log(a(1,:)); 22 | 23 | % Renormalize lpc A coeffs 24 | a = a ./ repmat(a(1,:), nin, 1); 25 | 26 | for n = 2:nout 27 | sum = 0; 28 | for m = 2:n 29 | sum = sum + (n - m) * a(m,:) .* c(n - m + 1, :); 30 | end 31 | c(n,:) = -(a(n,:) + sum / (n-1)); 32 | end 33 | 34 | features = c; 35 | 36 | -------------------------------------------------------------------------------- /Archives/rastamat/lpc2spec.m: -------------------------------------------------------------------------------- 1 | function [features,F,M] = lpc2spec(lpcas, nout) 2 | % [features,F,M] = lpc2spec(lpcas,nout) 3 | % Convert LPC coeffs back into spectra 4 | % nout is number of freq channels, default 17 (i.e. for 8 kHz) 5 | % 2003-04-11 dpwe@ee.columbia.edu part of rastamat 6 | 7 | if nargin < 2 8 | nout = 17; 9 | end 10 | 11 | [rows, cols] = size(lpcas); 12 | order = rows - 1; 13 | 14 | gg = lpcas(1,:); 15 | aa = lpcas./repmat(gg,rows,1); 16 | 17 | % Calculate the actual z-plane polyvals: nout points around unit circle 18 | zz = exp((-j*[0:(nout-1)]'*pi/(nout-1))*[0:order]); 19 | 20 | % Actual polyvals, in power (mag^2) 21 | features = ((1./abs(zz*aa)).^2)./repmat(gg,nout,1); 22 | 23 | F = zeros(cols, floor(rows/2)); 24 | M = F; 25 | 26 | for c = 1:cols; 27 | aaa = aa(:,c); 28 | rr = roots(aaa'); 29 | ff = angle(rr'); 30 | % size(ff) 31 | % size(aaa) 32 | zz = exp(j*ff'*[0:(length(aaa)-1)]); 33 | mags = sqrt(((1./abs(zz*aaa)).^2)/gg(c))'; 34 | 35 | [dummy, ix] = sort(ff); 36 | keep = ff(ix) > 0; 37 | ix = ix(keep); 38 | F(c,1:length(ix)) = ff(ix); 39 | M(c,1:length(ix)) = mags(ix); 40 | end 41 | -------------------------------------------------------------------------------- /Archives/rastamat/mel2hz.m: -------------------------------------------------------------------------------- 1 | function f = mel2hz(z, htk) 2 | % f = mel2hz(z, htk) 3 | % Convert 'mel scale' frequencies into Hz 4 | % Optional htk = 1 means use the HTK formula 5 | % else use the formula from Slaney's mfcc.m 6 | % 2005-04-19 dpwe@ee.columbia.edu 7 | 8 | if nargin < 2 9 | htk = 0; 10 | end 11 | 12 | if htk == 1 13 | f = 700*(10.^(z/2595)-1); 14 | else 15 | 16 | f_0 = 0; % 133.33333; 17 | f_sp = 200/3; % 66.66667; 18 | brkfrq = 1000; 19 | brkpt = (brkfrq - f_0)/f_sp; % starting mel value for log region 20 | logstep = exp(log(6.4)/27); % the magic 1.0711703 which is the ratio needed to get from 1000 Hz to 6400 Hz in 27 steps, and is *almost* the ratio between 1000 Hz and the preceding linear filter center at 933.33333 Hz (actually 1000/933.33333 = 1.07142857142857 and exp(log(6.4)/27) = 1.07117028749447) 21 | 22 | linpts = (z < brkpt); 23 | 24 | f = 0*z; 25 | 26 | % fill in parts separately 27 | f(linpts) = f_0 + f_sp*z(linpts); 28 | f(~linpts) = brkfrq*exp(log(logstep)*(z(~linpts)-brkpt)); 29 | 30 | end 31 | -------------------------------------------------------------------------------- /Archives/rastamat/postaud.m: -------------------------------------------------------------------------------- 1 | function [y,eql] = postaud(x,fmax,fbtype,broaden) 2 | %y = postaud(x, fmax, fbtype) 3 | % 4 | % do loudness equalization and cube root compression 5 | % x = critical band filters 6 | % rows = critical bands 7 | % cols = frames 8 | 9 | if nargin < 3 10 | fbtype = 'bark'; 11 | end 12 | if nargin < 4 13 | % By default, don't add extra flanking bands 14 | broaden = 0; 15 | end 16 | 17 | 18 | [nbands,nframes] = size(x); 19 | 20 | % equal loundness weights stolen from rasta code 21 | %eql = [0.000479 0.005949 0.021117 0.044806 0.073345 0.104417 0.137717 ... 22 | % 0.174255 0.215590 0.263260 0.318302 0.380844 0.449798 0.522813 23 | % 0.596597]; 24 | 25 | % Include frequency points at extremes, discard later 26 | nfpts = nbands+2*broaden; 27 | 28 | if strcmp(fbtype, 'bark') 29 | bandcfhz = bark2hz(linspace(0, hz2bark(fmax), nfpts)); 30 | elseif strcmp(fbtype, 'mel') 31 | bandcfhz = mel2hz(linspace(0, hz2mel(fmax), nfpts)); 32 | elseif strcmp(fbtype, 'htkmel') || strcmp(fbtype, 'fcmel') 33 | bandcfhz = mel2hz(linspace(0, hz2mel(fmax,1), nfpts),1); 34 | else 35 | disp(['unknown fbtype', fbtype]); 36 | error; 37 | end 38 | 39 | % Remove extremal bands (the ones that will be duplicated) 40 | bandcfhz = bandcfhz((1+broaden):(nfpts-broaden)); 41 | 42 | % Hynek's magic equal-loudness-curve formula 43 | fsq = bandcfhz.^2; 44 | ftmp = fsq + 1.6e5; 45 | eql = ((fsq./ftmp).^2) .* ((fsq + 1.44e6)./(fsq + 9.61e6)); 46 | 47 | % weight the critical bands 48 | z = repmat(eql',1,nframes).*x; 49 | 50 | % cube root compress 51 | z = z .^ (.33); 52 | 53 | % replicate first and last band (because they are unreliable as calculated) 54 | if (broaden) 55 | y = z([1,1:nbands,nbands],:); 56 | else 57 | y = z([2,2:(nbands-1),nbands-1],:); 58 | end 59 | %y = z([1,1:nbands-2,nbands-2],:); 60 | 61 | -------------------------------------------------------------------------------- /Archives/rastamat/powspec.m: -------------------------------------------------------------------------------- 1 | function [y,e] = powspec(x, sr, wintime, steptime, dither) 2 | %[y,e] = powspec(x, sr, wintime, steptime, sumlin, dither) 3 | % 4 | % compute the powerspectrum and frame energy of the input signal. 5 | % basically outputs a power spectrogram 6 | % 7 | % each column represents a power spectrum for a given frame 8 | % each row represents a frequency 9 | % 10 | % default values: 11 | % sr = 8000Hz 12 | % wintime = 25ms (200 samps) 13 | % steptime = 10ms (80 samps) 14 | % which means use 256 point fft 15 | % hamming window 16 | % 17 | % $Header: /Users/dpwe/matlab/rastamat/RCS/powspec.m,v 1.3 2012/09/03 14:02:01 dpwe Exp dpwe $ 18 | 19 | % for sr = 8000 20 | %NFFT = 256; 21 | %NOVERLAP = 120; 22 | %SAMPRATE = 8000; 23 | %WINDOW = hamming(200); 24 | 25 | if nargin < 2 26 | sr = 8000; 27 | end 28 | if nargin < 3 29 | wintime = 0.025; 30 | end 31 | if nargin < 4 32 | steptime = 0.010; 33 | end 34 | if nargin < 5 35 | dither = 1; 36 | end 37 | 38 | winpts = round(wintime*sr); 39 | steppts = round(steptime*sr); 40 | 41 | NFFT = 2^(ceil(log(winpts)/log(2))); 42 | %WINDOW = hamming(winpts); 43 | %WINDOW = [0,hanning(winpts)']; 44 | WINDOW = [hanning(winpts)']; 45 | % hanning gives much less noisy sidelobes 46 | NOVERLAP = winpts - steppts; 47 | SAMPRATE = sr; 48 | 49 | % Values coming out of rasta treat samples as integers, 50 | % not range -1..1, hence scale up here to match (approx) 51 | y = abs(specgram(x*32768,NFFT,SAMPRATE,WINDOW,NOVERLAP)).^2; 52 | 53 | % imagine we had random dither that had a variance of 1 sample 54 | % step and a white spectrum. That's like (in expectation, anyway) 55 | % adding a constant value to every bin (to avoid digital zero) 56 | if (dither) 57 | y = y + winpts; 58 | end 59 | % ignoring the hamming window, total power would be = #pts 60 | % I think this doesn't quite make sense, but it's what rasta/powspec.c does 61 | 62 | % that's all she wrote 63 | 64 | % 2012-09-03 Calculate log energy - after windowing, by parseval 65 | e = log(sum(y)); 66 | -------------------------------------------------------------------------------- /Archives/rastamat/rastafilt.m: -------------------------------------------------------------------------------- 1 | function y = rastafilt(x) 2 | % y = rastafilt(x) 3 | % 4 | % rows of x = critical bands, cols of x = frame 5 | % same for y but after filtering 6 | % 7 | % default filter is single pole at 0.94 8 | 9 | % rasta filter 10 | numer = [-2:2]; 11 | numer = -numer ./ sum(numer.*numer); 12 | denom = [1 -0.94]; 13 | 14 | % Initialize the state. This avoids a big spike at the beginning 15 | % resulting from the dc offset level in each band. 16 | % (this is effectively what rasta/rasta_filt.c does). 17 | % Because Matlab uses a DF2Trans implementation, we have to 18 | % specify the FIR part to get the state right (but not the IIR part) 19 | %[y,z] = filter(numer, 1, x(:,1:4)'); 20 | % 2010-08-12 filter() chooses the wrong dimension for very short 21 | % signals (thanks to Benjamin K otric1@gmail.com) 22 | [y,z] = filter(numer, 1, x(:,1:4)',[],1); 23 | % .. but don't keep any of these values, just output zero at the beginning 24 | y = 0*y'; 25 | 26 | size(z) 27 | size(x) 28 | 29 | % Apply the full filter to the rest of the signal, append it 30 | y = [y,filter(numer, denom, x(:,5:end)',z,1)']; 31 | %y = [y,filter(numer, denom, x(:,5:end)',z)']; 32 | -------------------------------------------------------------------------------- /Archives/rastamat/rastaplp.m: -------------------------------------------------------------------------------- 1 | function [cepstra, spectra, pspectrum, lpcas, F, M] = rastaplp(samples, sr, dorasta, modelorder) 2 | %[cepstra, spectra, lpcas] = rastaplp(samples, sr, dorasta, modelorder) 3 | % 4 | % cheap version of log rasta with fixed parameters 5 | % 6 | % output is matrix of features, row = feature, col = frame 7 | % 8 | % sr is sampling rate of samples, defaults to 8000 9 | % dorasta defaults to 1; if 0, just calculate PLP 10 | % modelorder is order of PLP model, defaults to 8. 0 -> no PLP 11 | % 12 | % rastaplp(d, sr, 0, 12) is pretty close to the unix command line 13 | % feacalc -dith -delta 0 -ras no -plp 12 -dom cep ... 14 | % except during very quiet areas, where our approach of adding noise 15 | % in the time domain is different from rasta's approach 16 | % 17 | % 2003-04-12 dpwe@ee.columbia.edu after shire@icsi.berkeley.edu's version 18 | 19 | if nargin < 2 20 | sr = 8000; 21 | end 22 | if nargin < 3 23 | dorasta = 1; 24 | end 25 | if nargin < 4 26 | modelorder = 8; 27 | end 28 | 29 | % add miniscule amount of noise 30 | %samples = samples + randn(size(samples))*0.0001; 31 | 32 | % first compute power spectrum 33 | pspectrum = powspec(samples, sr); 34 | 35 | % next group to critical bands 36 | aspectrum = audspec(pspectrum, sr); 37 | nbands = size(aspectrum,1); 38 | 39 | if dorasta ~= 0 40 | 41 | % put in log domain 42 | nl_aspectrum = log(aspectrum); 43 | 44 | % next do rasta filtering 45 | ras_nl_aspectrum = rastafilt(nl_aspectrum); 46 | 47 | % do inverse log 48 | aspectrum = exp(ras_nl_aspectrum); 49 | 50 | end 51 | 52 | % do final auditory compressions 53 | postspectrum = postaud(aspectrum, sr/2); % 2012-09-03 bug: was sr 54 | 55 | if modelorder > 0 56 | 57 | % LPC analysis 58 | lpcas = dolpc(postspectrum, modelorder); 59 | 60 | % convert lpc to cepstra 61 | cepstra = lpc2cep(lpcas, modelorder+1); 62 | 63 | % .. or to spectra 64 | [spectra,F,M] = lpc2spec(lpcas, nbands); 65 | 66 | else 67 | 68 | % No LPC smoothing of spectrum 69 | spectra = postspectrum; 70 | cepstra = spec2cep(spectra); 71 | 72 | end 73 | 74 | cepstra = lifter(cepstra, 0.6); 75 | -------------------------------------------------------------------------------- /Archives/rastamat/spec2cep.m: -------------------------------------------------------------------------------- 1 | function [cep,dctm] = spec2cep(spec, ncep, type) 2 | % [cep,dctm] = spec2cep(spec, ncep, type) 3 | % Calculate cepstra from spectral samples (in columns of spec) 4 | % Return ncep cepstral rows (defaults to 9) 5 | % This one does type II dct, or type I if type is specified as 1 6 | % dctm returns the DCT matrix that spec was multiplied by to give cep. 7 | % 2005-04-19 dpwe@ee.columbia.edu for mfcc_dpwe 8 | 9 | if nargin < 2; ncep = 13; end 10 | if nargin < 3; type = 2; end % type of DCT 11 | 12 | [nrow, ncol] = size(spec); 13 | 14 | % Make the DCT matrix 15 | dctm = zeros(ncep, nrow); 16 | if type == 2 || type == 3 17 | % this is the orthogonal one, the one you want 18 | for i = 1:ncep 19 | dctm(i,:) = cos((i-1)*[1:2:(2*nrow-1)]/(2*nrow)*pi) * sqrt(2/nrow); 20 | end 21 | if type == 2 22 | % make it unitary! (but not for HTK type 3) 23 | dctm(1,:) = dctm(1,:)/sqrt(2); 24 | end 25 | elseif type == 4 % type 1 with implicit repeating of first, last bins 26 | % Deep in the heart of the rasta/feacalc code, there is the logic 27 | % that the first and last auditory bands extend beyond the edge of 28 | % the actual spectra, and they are thus copied from their neighbors. 29 | % Normally, we just ignore those bands and take the 19 in the middle, 30 | % but when feacalc calculates mfccs, it actually takes the cepstrum 31 | % over the spectrum *including* the repeated bins at each end. 32 | % Here, we simulate 'repeating' the bins and an nrow+2-length 33 | % spectrum by adding in extra DCT weight to the first and last 34 | % bins. 35 | for i = 1:ncep 36 | dctm(i,:) = cos((i-1)*[1:nrow]/(nrow+1)*pi) * 2; 37 | % Add in edge points at ends (includes fixup scale) 38 | dctm(i,1) = dctm(i,1) + 1; 39 | dctm(i,nrow) = dctm(i,nrow) + ((-1)^(i-1)); 40 | end 41 | dctm = dctm / (2*(nrow+1)); 42 | else % dpwe type 1 - same as old spec2cep that expanded & used fft 43 | for i = 1:ncep 44 | dctm(i,:) = cos((i-1)*[0:(nrow-1)]/(nrow-1)*pi) * 2 / (2*(nrow-1)); 45 | end 46 | % fixup 'non-repeated' points 47 | dctm(:,[1 nrow]) = dctm(:, [1 nrow])/2; 48 | end 49 | 50 | cep = dctm*log(spec); 51 | 52 | -------------------------------------------------------------------------------- /Archives/wavToSpectr.m: -------------------------------------------------------------------------------- 1 | function spec = wavToSpectr(d , sr ) 2 | % Calculate basic RASTA-PLP cepstra and spectra 3 | [cep, spec] = rastaplp(d, sr,0,15); 4 | spec = abs(spec); 5 | end -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/B.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/B.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/C.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/C.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/E.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/E.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/F.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/F.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/MFCC_Extraction_2.m: -------------------------------------------------------------------------------- 1 | function [moyenne] = MFCC_Extraction_2(A, B, Fs) 2 | A_Mfcc= melcepst(A,Fs); 3 | B_Mfcc= melcepst(B,Fs); 4 | [ARows,ACols] = size(A_Mfcc); 5 | [BRows,BCols] = size(B_Mfcc); 6 | 7 | 8 | %comparer le nombre de lignes de chaque matrice 9 | cmp = ARows - BRows; 10 | if (cmp > 0) 11 | % A est plus grand et B prends la taille de A 12 | temp = zeros(ARows,BCols); 13 | 14 | for i=1:BCols 15 | for j=1:BRows 16 | temp(j,i)=B_Mfcc(j,i); 17 | end 18 | end 19 | B_Mfcc=temp; 20 | 21 | else 22 | % B est plus grand et A doit prendre la taille de B 23 | temp = zeros(BRows,ACols); 24 | for i=1:ACols 25 | for j=1:ARows 26 | temp(j,i)=A_Mfcc(j,i); 27 | end 28 | end 29 | A_Mfcc=temp; 30 | 31 | end 32 | 33 | 34 | 35 | sum=0; 36 | for i=1:BCols 37 | 38 | temp1=A_Mfcc(:,i); 39 | temp2=B_Mfcc(:,i); 40 | %calcule la distance entre chaque point du vecteur temporaire avec DTW 41 | temp3 = simmx(temp1, temp2); 42 | 43 | sum = sum + temp3; 44 | end 45 | moyenne = sum / ACols; 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/a.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/a.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/cleanSignal.m: -------------------------------------------------------------------------------- 1 | function [R] = cleanSignal(S) 2 | B = [1 -0.95]; 3 | R = filter(B,1,S); 4 | end -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/d.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/d.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/diffBetweenSignals_newGen.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/diffBetweenSignals_newGen.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/dtw/simmx.m: -------------------------------------------------------------------------------- 1 | function M = simmx(A,B) 2 | % M = simmx(A,B) 3 | % calculate a sim matrix between specgram-like feature matrices A and B. 4 | % size(M) = [size(A,2) size(B,2)]; A and B have same #rows. 5 | % 2003-03-15 dpwe@ee.columbia.edu 6 | 7 | % Copyright (c) 2003 Dan Ellis 8 | % released under GPL - see file COPYRIGHT 9 | 10 | EA = sqrt(sum(A.^2)); 11 | EB = sqrt(sum(B.^2)); 12 | 13 | %ncA = size(A,2); 14 | %ncB = size(B,2); 15 | %M = zeros(ncA, ncB); 16 | %for i = 1:ncA 17 | % for j = 1:ncB 18 | % % normalized inner product i.e. cos(angle between vectors) 19 | % M(i,j) = (A(:,i)'*B(:,j))/(EA(i)*EB(j)); 20 | % end 21 | %end 22 | 23 | % this is 10x faster 24 | M = (A'*B)./(EA'*EB); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/endpointdetection.m: -------------------------------------------------------------------------------- 1 | function [points] = endpointdetection(inputSignal) 2 | P = inputSignal .^ 2; 3 | size(P) 4 | noiseValue = sum(P)/length(P); 5 | plot(P) 6 | line([0,length(inputSignal)],[noiseValue,noiseValue]); 7 | 8 | points = {}; 9 | increment = 1; 10 | 11 | startDetected = 0; 12 | startP = 0; 13 | endP = 0; 14 | remember = 0; 15 | endCounter = 0; 16 | for i=1:length(P) 17 | i 18 | P(i) 19 | noiseValue 20 | 21 | startDetected 22 | if P(i) > noiseValue && startDetected == 0 23 | startP = i; 24 | startDetected = 1; 25 | elseif P(i) < noiseValue && startDetected == 1 26 | if endP == 0 27 | endP = i; 28 | remember = i; 29 | elseif endCounter < 800 30 | endCounter = endCounter+1; 31 | elseif endCounter >= 800 32 | points{increment} = [startP, endP]; 33 | startP = 0; 34 | endP = 0; 35 | remember = 0; 36 | endCounter = 0; 37 | increment = increment + 1; 38 | startDetected = 0; 39 | end 40 | elseif P(i) > noiseValue && startDetected == 1 41 | endP = 0; 42 | remember = 0; 43 | i = remember; 44 | endCounter = 0; 45 | end 46 | end 47 | end -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/g.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/g.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/h.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/h.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/i.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/i.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/interface_graphique.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/interface_graphique.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/j.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/j.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/k.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/k.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/l.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/l.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/m.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/m.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/n.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/n.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/o.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/o.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/p.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/p.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/q.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/q.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/r.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/r.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/record.m: -------------------------------------------------------------------------------- 1 | function [signalRecorder] = record(Fs, duration) 2 | % Record 3 | signalRecorder = audiorecorder(Fs, 16, 1); 4 | disp('Start speaking') 5 | if duration > -1 6 | recordblocking(signalRecorder, duration); 7 | else 8 | disp('Press button to stop') 9 | record(signalRecorder) 10 | waitforbuttonpress; 11 | stop(signalRecorder) 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/record2data.m: -------------------------------------------------------------------------------- 1 | function [avg] = record2data(duration, n,Fs) 2 | 3 | acc = zeros(duration*Fs,1); 4 | for i=1:n 5 | recordSignal = record(Fs, duration); 6 | voice = getaudiodata(recordSignal); 7 | datas = detectVoiced(voice,Fs); 8 | 9 | if length(datas) == 1 10 | datas = cell2mat(datas); 11 | datas = cleanSignal(datas); 12 | else 13 | avg = voice; 14 | subplot(2,2,4); 15 | plot(voice); 16 | return; 17 | end 18 | 19 | if length(datas) < length(acc) 20 | datas(length(acc)) = 0; 21 | end 22 | acc = acc + datas; 23 | % subplot(n+1,1,i); 24 | % plot(datas); 25 | end 26 | 27 | avg = acc/n; 28 | subplot(2,2,4); 29 | plot(acc); 30 | end -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/s.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/s.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/silence-remover/ShortTimeEnergy.m: -------------------------------------------------------------------------------- 1 | function E = ShortTimeEnergy(signal, windowLength,step); 2 | signal = signal / max(max(signal)); 3 | curPos = 1; 4 | L = length(signal); 5 | numOfFrames = floor((L-windowLength)/step) + 1; 6 | %H = hamming(windowLength); 7 | E = zeros(numOfFrames,1); 8 | for (i=1:numOfFrames) 9 | window = (signal(curPos:curPos+windowLength-1)); 10 | E(i) = (1/(windowLength)) * sum(abs(window.^2)); 11 | curPos = curPos + step; 12 | end 13 | %Max = max(E); 14 | %med = median(E); 15 | %m = mean(E); 16 | %a = length(find(E>2*med))/numOfFrames; 17 | %b = length(find(E<(med/2)))/numOfFrames; 18 | 19 | %S_EnergyM = length(find(E>2*med))/numOfFrames; 20 | %S_EnergyV = length(find(E<(med/2)))/numOfFrames; 21 | %S_EnergyM = std(E); 22 | %S_EnergyV = a; -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/silence-remover/SpectralCentroid.m: -------------------------------------------------------------------------------- 1 | function C = SpectralCentroid(signal,windowLength, step, fs) 2 | 3 | % function C = SpectralCentroid(signal,windowLength, step, fs) 4 | % 5 | % This function computes the spectral centroid feature of an audio signal 6 | % ARGUMENTS: 7 | % - signal: the audio samples 8 | % - windowLength: the length of the window analysis (in number of samples) 9 | % - step: the step of the window analysis (in number of samples) 10 | % - fs: the sampling frequency 11 | % 12 | % RETURNS: 13 | % - C: the sequence of the spectral centroid feature 14 | % 15 | 16 | signal = signal / max(abs(signal)); 17 | curPos = 1; 18 | L = length(signal); 19 | numOfFrames = floor((L-windowLength)/step) + 1; 20 | H = hamming(windowLength); 21 | m = ((fs/(2*windowLength))*[1:windowLength])'; 22 | C = zeros(numOfFrames,1); 23 | for (i=1:numOfFrames) 24 | window = H.*(signal(curPos:curPos+windowLength-1)); 25 | FFT = (abs(fft(window,2*windowLength))); 26 | FFT = FFT(1:windowLength); 27 | FFT = FFT / max(FFT); 28 | C(i) = sum(m.*FFT)/sum(FFT); 29 | if (sum(window.^2)<0.010) 30 | C(i) = 0.0; 31 | end 32 | curPos = curPos + step; 33 | end 34 | C = C / (fs/2); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/t.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/t.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/u.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/u.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/v.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/v.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/atan2sc.m: -------------------------------------------------------------------------------- 1 | function [s,c,r,t]=atan2sc(y,x) 2 | %ATAN2SC sin and cosine of atan(y/x) [S,C,R,T]=(Y,X) 3 | % 4 | % Outputs: 5 | % s sin(t) where tan(t) = y/x 6 | % C cos(t) where tan(t) = y/x 7 | % r sqrt(x^2 + y^2) 8 | % t arctan of y/x 9 | 10 | % Copyright (C) Mike Brookes 2007 11 | % Version: $Id: atan2sc.m 713 2011-10-16 14:45:43Z dmb $ 12 | % 13 | % VOICEBOX is a MATLAB toolbox for speech processing. 14 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 15 | % 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | % This program is free software; you can redistribute it and/or modify 18 | % it under the terms of the GNU General Public License as published by 19 | % the Free Software Foundation; either version 2 of the License, or 20 | % (at your option) any later version. 21 | % 22 | % This program is distributed in the hope that it will be useful, 23 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | % GNU General Public License for more details. 26 | % 27 | % You can obtain a copy of the GNU General Public License from 28 | % http://www.gnu.org/copyleft/gpl.html or by writing to 29 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 30 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 31 | 32 | 33 | t=NaN; 34 | if y == 0 35 | t=(x<0); 36 | c=1-2*t; 37 | s=0; 38 | r=abs(x); 39 | t=t*pi; 40 | elseif x == 0 41 | s=2*(y>=0)-1; 42 | c=0; 43 | r=abs(y); 44 | t=s*0.5*pi; 45 | elseif (abs(y) > abs(x)) 46 | q = x/y; 47 | u = sqrt(1+q^2)*(2*(y>=0)-1); 48 | s = 1/u; 49 | c = s*q; 50 | r = y*u; 51 | else 52 | q = y/x; 53 | u = sqrt(1+q^2)*(2*(x>=0)-1); 54 | c = 1/u; 55 | s = c*q; 56 | r = x*u; 57 | end 58 | if nargout>3 && isnan(t) 59 | t=atan2(s,c); 60 | end -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/bark2frq.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/bark2frq.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/ccwarpf.m: -------------------------------------------------------------------------------- 1 | function m=ccwarpf(f,n,s) 2 | %CCWARPF Warp cepstral coefficients M=(F,N,S) 3 | % f(1) is the original sample freq, f(2) is the new sample freq 4 | % n(1) is the original number of coefficients, n(2) is the new number 5 | % s is a string: s(1),s(2) =l for linear, m for mel frequency, use capitals if c0 included 6 | 7 | 8 | % Copyright (C) Mike Brookes 1998 9 | % Version: $Id: ccwarpf.m 713 2011-10-16 14:45:43Z dmb $ 10 | % 11 | % VOICEBOX is a MATLAB toolbox for speech processing. 12 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 13 | % 14 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15 | % This program is free software; you can redistribute it and/or modify 16 | % it under the terms of the GNU General Public License as published by 17 | % the Free Software Foundation; either version 2 of the License, or 18 | % (at your option) any later version. 19 | % 20 | % This program is distributed in the hope that it will be useful, 21 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | % GNU General Public License for more details. 24 | % 25 | % You can obtain a copy of the GNU General Public License from 26 | % http://www.gnu.org/copyleft/gpl.html or by writing to 27 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 28 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 29 | 30 | if nargin<3 31 | s='ll'; 32 | end 33 | if length(f)<2 34 | f(2)=1; 35 | end 36 | if length(n)<2 37 | n(2)=n(1); 38 | end 39 | z=s<'a'; 40 | s=s+32*z; 41 | if all(s=='l') 42 | k=1:n(2)-z(2); 43 | ff=((1:n(1)).'-z(1))*f(2)/f(1); 44 | fa=2*sin(ff*pi).*ff/pi; 45 | fb=ff.^2; 46 | ka=1-2*rem(k,2); 47 | kb=k.^2; 48 | r1=ones(n(1),1); 49 | c1=ones(1,n(2)-z(2)); 50 | a=fa(:,c1).*ka(r1,:); 51 | b=fb(:,c1)-kb(r1,:); 52 | f0=find(fix(ff)==ff); 53 | if length(f0) 54 | a(f0,:)=ff(f0,c1)==k(ones(length(f0),1),:); 55 | b(f0,:)=1; 56 | end 57 | m=a./b; 58 | if z(2) 59 | m=[[1; 0.5*fa(2:n(1))./fb(2:n(1))] m]; 60 | end 61 | end 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/cent2frq.m: -------------------------------------------------------------------------------- 1 | function [frq,cr] = cent2frq(c) 2 | %FRQ2ERB Convert Hertz to Cents frequency scale [C,CR]=(FRQ) 3 | % frq = frq2mel(c) converts a vector of frequencies in cents 4 | % to the corresponding values in Hertz. 5 | % 100 cents corresponds to one semitone and 440Hz corresponds to 5700 6 | % cents. 7 | % The optional cr output gives the gradient in Hz/cent. 8 | % 9 | % The relationship between cents and frq is given by: 10 | % 11 | % c = 1200 * log2(f/(440*(2^((3/12)-5))) 12 | % 13 | % Reference: 14 | % 15 | % [1] Ellis, A. 16 | % On the Musical Scales of Various Nations 17 | % Journal of the Society of Arts, 1885, 485-527 18 | 19 | % Copyright (C) Mike Brookes 1998 20 | % Version: $Id: cent2frq.m 3123 2013-06-19 19:03:53Z dmb $ 21 | % 22 | % VOICEBOX is a MATLAB toolbox for speech processing. 23 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 24 | % 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | % This program is free software; you can redistribute it and/or modify 27 | % it under the terms of the GNU General Public License as published by 28 | % the Free Software Foundation; either version 2 of the License, or 29 | % (at your option) any later version. 30 | % 31 | % This program is distributed in the hope that it will be useful, 32 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 33 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 34 | % GNU General Public License for more details. 35 | % 36 | % You can obtain a copy of the GNU General Public License from 37 | % http://www.gnu.org/copyleft/gpl.html or by writing to 38 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 39 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 40 | persistent p q 41 | if isempty(p) 42 | p=1200/log(2); 43 | q=5700-p*log(440); 44 | end 45 | % c = 1200*sign(frq).*log2(frq/(440*2^((3/12)-5))); 46 | af=(exp((abs(c)-q)/p)); 47 | frq=sign(c).*af; 48 | cr=af/p; 49 | if ~nargout 50 | plot(c,frq,'-x'); 51 | ylabel(['Frequency (' yticksi 'Hz)']); 52 | xlabel(['Frequency (' xticksi 'Cents)']); 53 | end 54 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/choosrnk.m: -------------------------------------------------------------------------------- 1 | function x=choosrnk(n,k) 2 | %CHOOSRNK All choices of K elements taken from 1:N with replacement. [X]=(N,K) 3 | % The output X is a matrix of size ((N+K-1)!/(K!*(N-1)!),K) where each row 4 | % contains a choice of K elements taken from 1:N with duplications allowed. 5 | % The rows of X are in lexically sorted order. 6 | % 7 | % To choose from the elements of an arbitrary vector V use 8 | % V(CHOOSRNK(LENGTH(V),K)). 9 | 10 | % Copyright (c) 1998 Mike Brookes, mike.brookes@ic.ac.uk 11 | % Version: $Id: choosrnk.m 713 2011-10-16 14:45:43Z dmb $ 12 | % 13 | % VOICEBOX is a MATLAB toolbox for speech processing. 14 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 15 | % 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | % This program is free software; you can redistribute it and/or modify 18 | % it under the terms of the GNU General Public License as published by 19 | % the Free Software Foundation; either version 2 of the License, or 20 | % (at your option) any later version. 21 | % 22 | % This program is distributed in the hope that it will be useful, 23 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | % GNU General Public License for more details. 26 | % 27 | % You can obtain a copy of the GNU General Public License from 28 | % http://www.gnu.org/copyleft/gpl.html or by writing to 29 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 30 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 31 | x=choosenk(n+k-1,k); 32 | x=x-repmat(0:k-1,size(x,1),1); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/ditherq.m: -------------------------------------------------------------------------------- 1 | function [y,zf]=ditherq(x,m,zi) 2 | %DITHERQ add dither and quantize [Y,ZF]=(X,M,ZI) 3 | % Inputs: 4 | % x is the input signal 5 | % m specifies the mode: 6 | % 'w' white dither (default) 7 | % 'h' high-pass dither (filtered by 1 - z^-1) 8 | % 'l' low pass filter (filtered by 1 + z^-1) 9 | % 'n' no dither 10 | 11 | % Copyright (C) Mike Brookes 1997 12 | % Version: $Id: ditherq.m 713 2011-10-16 14:45:43Z dmb $ 13 | % 14 | % VOICEBOX is a MATLAB toolbox for speech processing. 15 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 16 | % 17 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18 | % This program is free software; you can redistribute it and/or modify 19 | % it under the terms of the GNU General Public License as published by 20 | % the Free Software Foundation; either version 2 of the License, or 21 | % (at your option) any later version. 22 | % 23 | % This program is distributed in the hope that it will be useful, 24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 | % GNU General Public License for more details. 27 | % 28 | % You can obtain a copy of the GNU General Public License from 29 | % http://www.gnu.org/copyleft/gpl.html or by writing to 30 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32 | 33 | s=size(x); 34 | n=length(x); 35 | if nargin<3 | ~length(zi) 36 | zi=rand(1); 37 | end 38 | if nargin<2 39 | m='w'; 40 | end 41 | if any(m=='n') 42 | y=round(x); 43 | elseif any(m=='h') | any(m=='l') 44 | v=rand(n+1,1); 45 | v(1)=zi; 46 | zf=v(end); 47 | if any(m=='h') 48 | y=round(x(:)+v(2:end)-v(1:end-1)); 49 | else 50 | y=round(x(:)+v(2:end)+v(1:end-1)-1); 51 | end 52 | else 53 | y=round(x(:)+rand(n,2)*[1;-1]); 54 | zf=rand(1); % output a random number anyway 55 | end 56 | if s(1)==1 57 | y=y.'; 58 | end -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/dypsa.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/dypsa.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/filtbankm.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/filtbankm.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/flac.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/flac.exe -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/frq2bark.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/frq2bark.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/frq2cent.m: -------------------------------------------------------------------------------- 1 | function [c,cr] = frq2cent(frq) 2 | %FRQ2ERB Convert Hertz to Cents frequency scale [C,CR]=(FRQ) 3 | % [c,cr] = frq2mel(frq) converts a vector of frequencies (in Hz) 4 | % to the corresponding values on the logarithmic cents scale. 5 | % 100 cents corresponds to one semitone and 440Hz corresponds to 5700 6 | % cents. 7 | % The optional cr output gives the gradient in Hz/cent. 8 | % 9 | % The relationship between cents and frq is given by: 10 | % 11 | % c = 1200 * log2(f/(440*(2^((3/12)-5))) 12 | % 13 | % Reference: 14 | % 15 | % [1] Ellis, A. 16 | % On the Musical Scales of Various Nations 17 | % Journal of the Society of Arts, 1885, 485-527 18 | 19 | % Copyright (C) Mike Brookes 1998 20 | % Version: $Id: frq2cent.m 3122 2013-06-19 19:02:47Z dmb $ 21 | % 22 | % VOICEBOX is a MATLAB toolbox for speech processing. 23 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 24 | % 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | % This program is free software; you can redistribute it and/or modify 27 | % it under the terms of the GNU General Public License as published by 28 | % the Free Software Foundation; either version 2 of the License, or 29 | % (at your option) any later version. 30 | % 31 | % This program is distributed in the hope that it will be useful, 32 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 33 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 34 | % GNU General Public License for more details. 35 | % 36 | % You can obtain a copy of the GNU General Public License from 37 | % http://www.gnu.org/copyleft/gpl.html or by writing to 38 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 39 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 40 | persistent p q 41 | if isempty(p) 42 | p=1200/log(2); 43 | q=5700-p*log(440); 44 | end 45 | af=abs(frq); 46 | % c = 1200*sign(frq).*log2(frq/(440*2^((3/12)-5))); 47 | c=sign(frq).*(p*log(af)+q); 48 | cr=af/p; 49 | if ~nargout 50 | plot(frq,c,'-x'); 51 | xlabel(['Frequency (' xticksi 'Hz)']); 52 | ylabel(['Frequency (' yticksi 'Cents)']); 53 | end 54 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/frq2mel.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/frq2mel.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/frq2midi.m: -------------------------------------------------------------------------------- 1 | function [n,t]=frq2midi(f) 2 | %FRQ2MIDI Convert frequencies to musical note numbers [N,T]=(F) 3 | % notes are numbered in semitones with middle C being 60 4 | % Note 69 (the A above middle C) has a frequency of 440 Hz. 5 | % These note numbers are used by MIDI. Note numbers are not necessarily 6 | % integers. 7 | % 8 | % t is a text representation of the note in which 9 | % C4# denotes C sharp in octave 4. Octave 4 goes 10 | % from middle C up to the B above middle C. For the white 11 | % notes on the piano, the third character is a space. 12 | % 13 | % Negative frequencies are equivalent to positive frequencies 14 | % except that flats will be used instead of sharps. Thus 15 | % C4# would become D4- 16 | % 17 | % see MIDI2FRQ for the inverse transform 18 | 19 | 20 | 21 | 22 | % Copyright (C) Mike Brookes 1998 23 | % Version: $Id: frq2midi.m 713 2011-10-16 14:45:43Z dmb $ 24 | % 25 | % VOICEBOX is a MATLAB toolbox for speech processing. 26 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 27 | % 28 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 29 | % This program is free software; you can redistribute it and/or modify 30 | % it under the terms of the GNU General Public License as published by 31 | % the Free Software Foundation; either version 2 of the License, or 32 | % (at your option) any later version. 33 | % 34 | % This program is distributed in the hope that it will be useful, 35 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 36 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 37 | % GNU General Public License for more details. 38 | % 39 | % You can obtain a copy of the GNU General Public License from 40 | % http://www.gnu.org/copyleft/gpl.html or by writing to 41 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 42 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 43 | 44 | n=(69+12*log(abs(f)/440)/log(2)); 45 | if nargout > 1 46 | m=round(n(:)); 47 | o=floor(m/12)-1; 48 | m=m-12*o+6*sign(f(:))-5; 49 | a=('CDDEEFGGAABBCCDDEFFGGAAB')'; 50 | b=(' - - - - - # # # # # ')'; 51 | t=setstr([a(m) mod(o,10)+'0' b(m)]); 52 | end 53 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/gammabank.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/gammabank.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/gaussmixg.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/gaussmixg.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/gaussmixk.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/gaussmixk.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/glotros.m: -------------------------------------------------------------------------------- 1 | function u=glotros(d,t,p) 2 | %GLOTROS Rosenberg glottal model U=(D,T,P) 3 | % d is derivative of flow waveform 4 | % t is in fractions of a cycle 5 | % p has parameters 6 | % p(1)=closure time 7 | % p(2)=+ve/-ve slope ratio 8 | 9 | 10 | 11 | % Copyright (C) Mike Brookes 1998 12 | % Version: $Id: glotros.m 713 2011-10-16 14:45:43Z dmb $ 13 | % 14 | % VOICEBOX is a MATLAB toolbox for speech processing. 15 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 16 | % 17 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18 | % This program is free software; you can redistribute it and/or modify 19 | % it under the terms of the GNU General Public License as published by 20 | % the Free Software Foundation; either version 2 of the License, or 21 | % (at your option) any later version. 22 | % 23 | % This program is distributed in the hope that it will be useful, 24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 | % GNU General Public License for more details. 27 | % 28 | % You can obtain a copy of the GNU General Public License from 29 | % http://www.gnu.org/copyleft/gpl.html or by writing to 30 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32 | 33 | if nargin < 2 34 | tt=(0:99)'/100; 35 | else 36 | tt=mod(t,1); 37 | end 38 | u=zeros(size(tt)); 39 | de=[0.6 0.5]'; 40 | if nargin < 3 41 | p=de; 42 | elseif length(p)<2 43 | p=[p(:); de(length(p)+1:2)]; 44 | end 45 | pp=p(1)/(1+p(2)); 46 | ta=tt0; 48 | p(q)=mvnpdf(log(x(q,:)),u,k)./c(q); 49 | 50 | if ~nargout & (length(u)==1) 51 | plot(x,p); 52 | end -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcaa2ao.m: -------------------------------------------------------------------------------- 1 | function ao=lpcaa2ao(aa) 2 | %LPCAA2AO LPC: Convert area function to area ratios AO=(AA) 3 | 4 | 5 | 6 | % Copyright (C) Mike Brookes 1998 7 | % Version: $Id: lpcaa2ao.m 713 2011-10-16 14:45:43Z dmb $ 8 | % 9 | % VOICEBOX is a MATLAB toolbox for speech processing. 10 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html% 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | p1=size(aa,2); 28 | ao=aa(:,1:p1-1)./aa(:,2:p1); 29 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcaa2dl.m: -------------------------------------------------------------------------------- 1 | function dl=lpcaa2dl(aa) 2 | %LPCAA2DL LPC: Convert area coefficients to dct of log area DL=(AA) 3 | 4 | % note: we do not correct for sinc distortion; perhaps we should multiply by 5 | % k=1:p-1;s=[sqrt(0.5)/p 2*sin(pi*k/(2*p))./(pi*k)]; 6 | 7 | 8 | 9 | % Copyright (C) Mike Brookes 1998 10 | % Version: $Id: lpcaa2dl.m 713 2011-10-16 14:45:43Z dmb $ 11 | % 12 | % VOICEBOX is a MATLAB toolbox for speech processing. 13 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 14 | % 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | % This program is free software; you can redistribute it and/or modify 17 | % it under the terms of the GNU General Public License as published by 18 | % the Free Software Foundation; either version 2 of the License, or 19 | % (at your option) any later version. 20 | % 21 | % This program is distributed in the hope that it will be useful, 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | % GNU General Public License for more details. 25 | % 26 | % You can obtain a copy of the GNU General Public License from 27 | % http://www.gnu.org/copyleft/gpl.html or by writing to 28 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30 | 31 | [nf,p2]=size(aa); 32 | dl=rdct(log(aa(:,2:p2-1)./aa(:,p2*ones(1,p2-2))).').'; 33 | 34 | 35 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcaa2rf.m: -------------------------------------------------------------------------------- 1 | function rf=lpcaa2rf(aa) 2 | %LPCAA2RF LPC: Convert vocal tract areas to reflection coefficients RF=(AA) 3 | 4 | % Copyright (C) Mike Brookes 1998 5 | % Version: $Id: lpcaa2rf.m 713 2011-10-16 14:45:43Z dmb $ 6 | % 7 | % VOICEBOX is a MATLAB toolbox for speech processing. 8 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 9 | % 10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11 | % This program is free software; you can redistribute it and/or modify 12 | % it under the terms of the GNU General Public License as published by 13 | % the Free Software Foundation; either version 2 of the License, or 14 | % (at your option) any later version. 15 | % 16 | % This program is distributed in the hope that it will be useful, 17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | % GNU General Public License for more details. 20 | % 21 | % You can obtain a copy of the GNU General Public License from 22 | % http://www.gnu.org/copyleft/gpl.html or by writing to 23 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 24 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 25 | 26 | [nf,p2]=size(aa); 27 | rf = (aa(:,2:p2)-aa(:,1:p2-1))./(aa(:,2:p2)+aa(:,1:p2-1)); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcao2rf.m: -------------------------------------------------------------------------------- 1 | function rf=lpcao2rf(ao) 2 | %LPCAO2RF LPC: Convert area ratios to reflection coefficients RF=(AO) 3 | 4 | 5 | 6 | % Copyright (C) Mike Brookes 1998 7 | % Version: $Id: lpcao2rf.m 713 2011-10-16 14:45:43Z dmb $ 8 | % 9 | % VOICEBOX is a MATLAB toolbox for speech processing. 10 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 11 | % 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | % This program is free software; you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published by 15 | % the Free Software Foundation; either version 2 of the License, or 16 | % (at your option) any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details. 22 | % 23 | % You can obtain a copy of the GNU General Public License from 24 | % http://www.gnu.org/copyleft/gpl.html or by writing to 25 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | 28 | rf = (1-ao)./(1+ao); 29 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcar2cc.m: -------------------------------------------------------------------------------- 1 | function cc=lpcar2cc(ar,np) 2 | %LPCAR2CC LPC: Convert ar filter to complex cepstrum CC=(AR,NP) 3 | % the "real" cepstrum is half the complex cepstrum 4 | % cc() does not include c0 whose value can be calculated 5 | % from the prediction residual energy, e, as ln(e)/2 6 | % for both real and complex cepstrum. 7 | 8 | 9 | 10 | % Copyright (C) Mike Brookes 1998 11 | % Version: $Id: lpcar2cc.m 713 2011-10-16 14:45:43Z dmb $ 12 | % 13 | % VOICEBOX is a MATLAB toolbox for speech processing. 14 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 15 | % 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | % This program is free software; you can redistribute it and/or modify 18 | % it under the terms of the GNU General Public License as published by 19 | % the Free Software Foundation; either version 2 of the License, or 20 | % (at your option) any later version. 21 | % 22 | % This program is distributed in the hope that it will be useful, 23 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | % GNU General Public License for more details. 26 | % 27 | % You can obtain a copy of the GNU General Public License from 28 | % http://www.gnu.org/copyleft/gpl.html or by writing to 29 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 30 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 31 | 32 | [nf,p1]=size(ar); 33 | p=p1-1; 34 | if (nargin<2) np=p; end 35 | cc=zeros(nf,np); 36 | cm=(1:np).^(-1); 37 | if np>p 38 | xm=-(1:p); 39 | nz=np-p; 40 | for k=1:nf 41 | cc(k,:)=filter(1,ar(k,:),[ar(k,2:p1).*xm zeros(1,nz)]).*cm; 42 | end 43 | else 44 | p1=np+1; 45 | xm=-(1:np); 46 | for k=1:nf 47 | cc(k,:)=filter(1,ar(k,:),ar(k,2:p1).*xm).*cm; 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcar2db.m: -------------------------------------------------------------------------------- 1 | function db=lpcar2db(ar,np) 2 | %LPCAR2DB LPC: Convert AR coefs to power spectrum in dB DB=(AR) 3 | 4 | 5 | 6 | % Copyright (C) Mike Brookes 1998 7 | % Version: $Id: lpcar2db.m 713 2011-10-16 14:45:43Z dmb $ 8 | % 9 | % VOICEBOX is a MATLAB toolbox for speech processing. 10 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 11 | % 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | % This program is free software; you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published by 15 | % the Free Software Foundation; either version 2 of the License, or 16 | % (at your option) any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details. 22 | % 23 | % You can obtain a copy of the GNU General Public License from 24 | % http://www.gnu.org/copyleft/gpl.html or by writing to 25 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | 28 | [nf,p1]=size(ar); 29 | if nargin<2 np=p1-1; end 30 | ff=rfft(ar.',2*np+2).'; 31 | db=-10*log10(real(ff.*conj(ff))); 32 | if nargout==0 33 | plot((0:np+1)/(2*np+2),db.'); 34 | ylabel('dB'); 35 | end 36 | 37 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcar2ff.m: -------------------------------------------------------------------------------- 1 | function ff=lpcar2ff(ar,np) 2 | %LPCAR2FF LPC: Convert AR coefs to complex spectrum FF=(AR,NP) 3 | 4 | 5 | 6 | % Copyright (C) Mike Brookes 1998 7 | % Version: $Id: lpcar2ff.m 713 2011-10-16 14:45:43Z dmb $ 8 | % 9 | % VOICEBOX is a MATLAB toolbox for speech processing. 10 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 11 | % 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | % This program is free software; you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published by 15 | % the Free Software Foundation; either version 2 of the License, or 16 | % (at your option) any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details. 22 | % 23 | % You can obtain a copy of the GNU General Public License from 24 | % http://www.gnu.org/copyleft/gpl.html or by writing to 25 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | 28 | [nf,p1]=size(ar); 29 | if nargin<2 np=p1-1; end 30 | ff=(rfft(ar.',2*np+2).').^(-1); 31 | 32 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcar2im.m: -------------------------------------------------------------------------------- 1 | function im=lpcar2im(ar,np) 2 | %LPCAR2IM Convert AR coefs to impulse response IM=(AR,NP) 3 | 4 | 5 | % Copyright (C) Mike Brookes 1997 6 | % Version: $Id: lpcar2im.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | [nf,p1]=size(ar); 28 | if nargin<2 np=p1-1; end 29 | im=zeros(nf,np+1); 30 | x=[1 zeros(1,np)]; 31 | for k=1:nf 32 | im(k,:)=filter(1,ar(k,:),x); 33 | end 34 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcar2ls.m: -------------------------------------------------------------------------------- 1 | function ls=lpcar2ls(ar) 2 | %LPCAR2LS convert ar polynomial to line spectrum pair frequencies LS=(AR) 3 | % output vector elements will be in range 0 to 0.5 4 | % the returned vector will be of length p 5 | 6 | % This routine is nowhere near as efficient as it might be 7 | 8 | 9 | % Copyright (C) Mike Brookes 1997 10 | % Version: $Id: lpcar2ls.m 713 2011-10-16 14:45:43Z dmb $ 11 | % 12 | % VOICEBOX is a MATLAB toolbox for speech processing. 13 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 14 | % 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | % This program is free software; you can redistribute it and/or modify 17 | % it under the terms of the GNU General Public License as published by 18 | % the Free Software Foundation; either version 2 of the License, or 19 | % (at your option) any later version. 20 | % 21 | % This program is distributed in the hope that it will be useful, 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | % GNU General Public License for more details. 25 | % 26 | % You can obtain a copy of the GNU General Public License from 27 | % http://www.gnu.org/copyleft/gpl.html or by writing to 28 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30 | 31 | [nf,p1]=size(ar); 32 | p = p1-1; 33 | p2 = fix(p/2); 34 | d=0.5/pi; 35 | 36 | if rem(p,2) % odd order 37 | for k=1:nf 38 | aa=[ar(k,:) 0]; 39 | r = aa + fliplr(aa); 40 | q = aa - fliplr(aa); 41 | fr = sort(angle(roots(r))); 42 | fq = [sort(angle(roots(deconv(q,[1 0 -1])))); 0]; 43 | f = [fr(p2+2:p+1).' ; fq(p2+1:p).']; 44 | f(p+1) = []; 45 | ls(k,:) = d*f(:).'; 46 | end 47 | else 48 | for k=1:nf 49 | aa=[ar(k,:) 0]; 50 | r = aa + fliplr(aa); 51 | q = aa - fliplr(aa); 52 | fr = sort(angle(roots(deconv(r,[1 1])))); 53 | fq = sort(angle(roots(deconv(q,[1 -1])))); 54 | f = [fr(p2+1:p).' ; fq(p2+1:p).']; 55 | ls(k,:) = d*f(:).'; 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcar2pf.m: -------------------------------------------------------------------------------- 1 | function pf=lpcar2pf(ar,np) 2 | %LPCAR2PF Convert AR coefs to power spectrum PF=(AR,NP) 3 | % the power spectrum will contain np+2 points ranging from Dc to nyquist frequency 4 | % The routine is faster if NP+1 is a power of 2. 5 | 6 | % Copyright (C) Mike Brookes 1998 7 | % Version: $Id: lpcar2pf.m 2460 2012-10-29 22:20:45Z dmb $ 8 | % 9 | % VOICEBOX is a MATLAB toolbox for speech processing. 10 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 11 | % 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | % This program is free software; you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published by 15 | % the Free Software Foundation; either version 2 of the License, or 16 | % (at your option) any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details. 22 | % 23 | % You can obtain a copy of the GNU General Public License from 24 | % http://www.gnu.org/copyleft/gpl.html or by writing to 25 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | 28 | [nf,p1]=size(ar); 29 | if nargin<2 np=p1-1; end 30 | pf=abs(rfft(ar.',2*np+2).').^(-2); 31 | if ~nargout 32 | if nf==1 33 | plot((0:np+1)/(2*np+2),10*log10(pf)); 34 | xlabel('Normalized frequency f/f_s'); 35 | ylabel('LPC Power Spectrum (dB)'); 36 | end 37 | end 38 | 39 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcar2pp.m: -------------------------------------------------------------------------------- 1 | function pp=lpcar2pp(ar) 2 | %LPCAR2PP LPC: Convert ar filter to power spectrum polynomial in cos(w) PP=(AR) 3 | % the pp is a polynomial such that |polyval(ar,e^jw)|^2 = polyval(pp,cos(w)) 4 | 5 | % Copyright (C) Mike Brookes 1998 6 | % Version: $Id: lpcar2pp.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | persistent tp; 28 | [nf,p1]=size(ar); 29 | ra=zeros(nf,p1); 30 | for i=1:p1 31 | ra(:,i)=sum(ar(:,1:p1+1-i).*ar(:,i:p1),2); 32 | end 33 | % we check here if p is the same as before and reuse the tp matrix 34 | if size(tp,1)~=p1 35 | p=p1-1; 36 | % chebyshev polynomials up to order p 37 | tp=zeros(p1,p1); 38 | tp(1,p1)=2; 39 | tp(2,p)=2; 40 | for i=3:p1 41 | tp(i,p+2-i:p)=2*tp(i-1,p+3-i:p1)-tp(i-2,p+2-i:p); 42 | tp(i,p1)=-tp(i-2,p1); 43 | end 44 | tp(1,p1)=1; 45 | end 46 | pp=ra*tp; 47 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcar2ra.m: -------------------------------------------------------------------------------- 1 | function ra=lpcar2ra(ar) 2 | %LPCAR2RA Convert ar filter to inverse filter autocorrelation coefs. RA=(AR) 3 | 4 | 5 | % Copyright (C) Mike Brookes 1997 6 | % Version: $Id: lpcar2ra.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | [nf,p1]=size(ar); 28 | ra=zeros(nf,p1); 29 | for i=1:p1 30 | ra(:,i)=sum(ar(:,1:p1+1-i).*ar(:,i:p1),2); 31 | end 32 | 33 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcar2rf.m: -------------------------------------------------------------------------------- 1 | function rf=lpcar2rf(ar) 2 | %LPCAR2RF Convert autoregressive coefficients to reflection coefficients AR=(RF) 3 | % 4 | % Input: ar(:,p+1) Autoregressive coefficients 5 | % Output: rf(:,p+1) Reflection coefficients with rf(:,1)=1 6 | 7 | 8 | % Copyright (C) Mike Brookes 1997 9 | % Version: $Id: lpcar2rf.m 713 2011-10-16 14:45:43Z dmb $ 10 | % 11 | % VOICEBOX is a MATLAB toolbox for speech processing. 12 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 13 | % 14 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15 | % This program is free software; you can redistribute it and/or modify 16 | % it under the terms of the GNU General Public License as published by 17 | % the Free Software Foundation; either version 2 of the License, or 18 | % (at your option) any later version. 19 | % 20 | % This program is distributed in the hope that it will be useful, 21 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | % GNU General Public License for more details. 24 | % 25 | % You can obtain a copy of the GNU General Public License from 26 | % http://www.gnu.org/copyleft/gpl.html or by writing to 27 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 28 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 29 | 30 | [nf,p1] = size(ar); 31 | if p1==1 32 | rf=ones(nf,1); 33 | else 34 | if any(ar(:,1)~=1) 35 | ar=ar./ar(:,ones(1,p1)); 36 | end 37 | rf = ar; 38 | w=ones(nf,1); 39 | for j = p1-1:-1:2 40 | k = rf(:,j+1); 41 | d = (1-k.^2).^(-1); 42 | wj=ones(1,j-1); 43 | rf(:,2:j) = (rf(:,2:j)-k(:,wj).*rf(:,j:-1:2)).*d(:,wj); 44 | end 45 | end 46 | 47 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcar2rr.m: -------------------------------------------------------------------------------- 1 | function rr=lpcar2rr(ar,p) 2 | %LPCAR2RR Convert autoregressive coefficients to autocorrelation coefficients RR=(AR,P) 3 | % The routine calculated the autocorrelation coefficients of the signal 4 | % that results from feeding unit-variance, zero-mean noise into the all-pole filter 5 | % Input: ar(:,n+1) Autoregressive coefficients including 0'th coefficient 6 | % Output: rr(:,p+1) Autocorrelation coefficients including 0'th order coefficient 7 | % If p is not specified it is taken to be n 8 | 9 | 10 | % Copyright (C) Mike Brookes 1997 11 | % Version: $Id: lpcar2rr.m 713 2011-10-16 14:45:43Z dmb $ 12 | % 13 | % VOICEBOX is a MATLAB toolbox for speech processing. 14 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 15 | % 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | % This program is free software; you can redistribute it and/or modify 18 | % it under the terms of the GNU General Public License as published by 19 | % the Free Software Foundation; either version 2 of the License, or 20 | % (at your option) any later version. 21 | % 22 | % This program is distributed in the hope that it will be useful, 23 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | % GNU General Public License for more details. 26 | % 27 | % You can obtain a copy of the GNU General Public License from 28 | % http://www.gnu.org/copyleft/gpl.html or by writing to 29 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 30 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 31 | 32 | k=ar(:,1).^(-2); 33 | if size(ar,2)==1 34 | rr=k; 35 | else 36 | if nargin>1 37 | rr=lpcrf2rr(lpcar2rf(ar),p).*k(:,ones(1,p+1)); 38 | else 39 | rr=lpcrf2rr(lpcar2rf(ar)).*k(:,ones(1,size(ar,2))); 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcar2zz.m: -------------------------------------------------------------------------------- 1 | function zz=lpcar2zz(ar) 2 | %LPCAR2ZZ Convert ar filter to z-plane poles ZZ=(AR) 3 | 4 | 5 | % Copyright (C) Mike Brookes 1997 6 | % Version: $Id: lpcar2zz.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | [nf,p1]=size(ar); 28 | zz=zeros(nf,p1-1); 29 | for k=1:nf 30 | zz(k,:)=roots(ar(k,:)).'; 31 | end 32 | 33 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcbwexp.m: -------------------------------------------------------------------------------- 1 | function arx=lpcbwexp(ar,bw) 2 | %LPCBWEXP expand formant bandwidths of LPC filter ARX=(AR,BW) 3 | %minimum bandwidth will be BW*fs where fs is the sampling frequency 4 | %the radius of each pole will be multiplied by R=exp(-BW*pi) 5 | % To set the maximum pole radius to R use BW=-log(R)/PI. 6 | 7 | 8 | 9 | % Copyright (C) Mike Brookes 1998 10 | % Version: $Id: lpcbwexp.m 713 2011-10-16 14:45:43Z dmb $ 11 | % 12 | % VOICEBOX is a MATLAB toolbox for speech processing. 13 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 14 | % 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | % This program is free software; you can redistribute it and/or modify 17 | % it under the terms of the GNU General Public License as published by 18 | % the Free Software Foundation; either version 2 of the License, or 19 | % (at your option) any later version. 20 | % 21 | % This program is distributed in the hope that it will be useful, 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | % GNU General Public License for more details. 25 | % 26 | % You can obtain a copy of the GNU General Public License from 27 | % http://www.gnu.org/copyleft/gpl.html or by writing to 28 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30 | 31 | [nf,p1]=size(ar); 32 | k=exp(-pi*(0:p1-1)*bw); 33 | arx=ar.*k(ones(nf,1),:); 34 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpccc2ar.m: -------------------------------------------------------------------------------- 1 | function ar=lpccc2ar(cc) 2 | %LPCCC2AR Convert complex cepstrum to ar coefficients AR=(CC) 3 | % 4 | % MATLAB5 version 5 | 6 | 7 | % Copyright (C) Mike Brookes 1998 8 | % Version: $Id: lpccc2ar.m 713 2011-10-16 14:45:43Z dmb $ 9 | % 10 | % VOICEBOX is a MATLAB toolbox for speech processing. 11 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 12 | % 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | % This program is free software; you can redistribute it and/or modify 15 | % it under the terms of the GNU General Public License as published by 16 | % the Free Software Foundation; either version 2 of the License, or 17 | % (at your option) any later version. 18 | % 19 | % This program is distributed in the hope that it will be useful, 20 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | % GNU General Public License for more details. 23 | % 24 | % You can obtain a copy of the GNU General Public License from 25 | % http://www.gnu.org/copyleft/gpl.html or by writing to 26 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 27 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28 | 29 | [nf,p]=size(cc); 30 | rp=-(1:p); 31 | cc = cc .* rp(ones(nf,1),:); 32 | if p<2 33 | ar = [ones(nf,1) cc(:,1)]; 34 | else 35 | ar=zeros(nf,p+1); 36 | ar(:,1:3) = [ones(nf,1) cc(:,1) (cc(:,2)+cc(:,1).^2)/2]; 37 | for k=3:p 38 | ar(:,k+1) = (cc(:,k) + sum(cc(:,1:k-1).*ar(:,k:-1:2),2))/k; 39 | end 40 | end 41 | 42 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpccc2cc.m: -------------------------------------------------------------------------------- 1 | function c=lpccc2cc(cc,np) 2 | %LPCCC2PF Extrapolate complex cepstrum C=(CC) 3 | 4 | % Copyright (C) Mike Brookes 1998 5 | % Version: $Id: lpccc2cc.m 713 2011-10-16 14:45:43Z dmb $ 6 | % 7 | % VOICEBOX is a MATLAB toolbox for speech processing. 8 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 9 | % 10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11 | % This program is free software; you can redistribute it and/or modify 12 | % it under the terms of the GNU General Public License as published by 13 | % the Free Software Foundation; either version 2 of the License, or 14 | % (at your option) any later version. 15 | % 16 | % This program is distributed in the hope that it will be useful, 17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | % GNU General Public License for more details. 20 | % 21 | % You can obtain a copy of the GNU General Public License from 22 | % http://www.gnu.org/copyleft/gpl.html or by writing to 23 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 24 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 25 | 26 | p=size(cc,2); 27 | if nargin<2 np=p; end 28 | if np<=p 29 | c=cc(:,1:np); 30 | else 31 | c=lpcar2cc(lpccc2ar(cc),np); 32 | end 33 | 34 | 35 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpccc2db.m: -------------------------------------------------------------------------------- 1 | function db=lpccc2db(cc,np,nc) 2 | %LPCCC2DBf Convert complex cepstrum to dB power spectrum DB=(CC,NP,NC) 3 | % cc = complex cepstrum coefs 4 | % np+2 = number of frequency values 0 to nyquist (default: np=size(cc,2)) 5 | % nc = number of cepstral coefs to use (default: nc=np); 6 | % for high speed make np one less than a power of 2 7 | 8 | 9 | % Copyright (C) Mike Brookes 1998 10 | % Version: $Id: lpccc2db.m 713 2011-10-16 14:45:43Z dmb $ 11 | % 12 | % VOICEBOX is a MATLAB toolbox for speech processing. 13 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 14 | % 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | % This program is free software; you can redistribute it and/or modify 17 | % it under the terms of the GNU General Public License as published by 18 | % the Free Software Foundation; either version 2 of the License, or 19 | % (at your option) any later version. 20 | % 21 | % This program is distributed in the hope that it will be useful, 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | % GNU General Public License for more details. 25 | % 26 | % You can obtain a copy of the GNU General Public License from 27 | % http://www.gnu.org/copyleft/gpl.html or by writing to 28 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30 | 31 | [nf,mc]=size(cc); 32 | if nargin<2 np=mc+2; end 33 | if nargin<3 nc=np; end 34 | k=10/log(10); 35 | if nc==mc 36 | db=k*rsfft([zeros(nf,1) cc].',2*np+2).'; 37 | else 38 | db=k*rsfft([zeros(nf,1) lpccc2cc(cc,nc)].',2*np+2).'; 39 | end 40 | if nargout==0 41 | plot((0:np+1)/(2*np+2),db.'); 42 | ylabel('dB'); 43 | end 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpccc2pf.m: -------------------------------------------------------------------------------- 1 | function pf=lpccc2pf(cc,np,nc) 2 | %LPCCC2PF Convert complex cepstrum to power spectrum PF=(CC,NP,NC) 3 | % cc = complex cepstrum coefs 4 | % np+2 = number of frequency values 0 to nyquist (default: np=size(cc,2)) 5 | % nc = number of cepstral coefs to use (default: nc=np); 6 | % for high speed make np one less than a power of 2 7 | 8 | 9 | % Copyright (C) Mike Brookes 1998 10 | % Version: $Id: lpccc2pf.m 713 2011-10-16 14:45:43Z dmb $ 11 | % 12 | % VOICEBOX is a MATLAB toolbox for speech processing. 13 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 14 | % 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | % This program is free software; you can redistribute it and/or modify 17 | % it under the terms of the GNU General Public License as published by 18 | % the Free Software Foundation; either version 2 of the License, or 19 | % (at your option) any later version. 20 | % 21 | % This program is distributed in the hope that it will be useful, 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | % GNU General Public License for more details. 25 | % 26 | % You can obtain a copy of the GNU General Public License from 27 | % http://www.gnu.org/copyleft/gpl.html or by writing to 28 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30 | 31 | [nf,mc]=size(cc); 32 | if nargin<2 np=mc+2; end 33 | if nargin<3 nc=np; end 34 | if nc==mc 35 | pf=exp(rsfft([zeros(nf,1) cc].',2*np+2).'); 36 | else 37 | pf=exp(rsfft([zeros(nf,1) lpccc2cc(cc,nc)].',2*np+2).'); 38 | end 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpccw2zz.m: -------------------------------------------------------------------------------- 1 | function zz=lpccw2zz(cw) 2 | %LPCPZ2ZZ LPC: Power spectrum roots to LPC poles ZZ=(CW) 3 | % pz are the roots of the power spectrum polynomial pp(cos(w)) 4 | 5 | % Copyright (C) Mike Brookes 1998 6 | % Version: $Id: lpccw2zz.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | zs=sqrt(cw.^2-1); 28 | zz=cw-sign(real(conj(cw).*zs)).*zs; 29 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcdb2pf.m: -------------------------------------------------------------------------------- 1 | function pf=lpcdb2pf(db) 2 | %LPCDB2PF Convert decibel power spectrum to power spectrum PF=(DB) 3 | 4 | 5 | % Copyright (C) Mike Brookes 1997 6 | % Version: $Id: lpcdb2pf.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | pf=exp(db*log(10)/10); 28 | 29 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcdl2aa.m: -------------------------------------------------------------------------------- 1 | function aa=lpcdl2aa(dl) 2 | %LPCDL2AA dct of log area to area coefficients AA=(DL) 3 | 4 | % we do not correct for sinc errors 5 | 6 | 7 | % Copyright (C) Mike Brookes 1997 8 | % Version: $Id: lpcdl2aa.m 713 2011-10-16 14:45:43Z dmb $ 9 | % 10 | % VOICEBOX is a MATLAB toolbox for speech processing. 11 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 12 | % 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | % This program is free software; you can redistribute it and/or modify 15 | % it under the terms of the GNU General Public License as published by 16 | % the Free Software Foundation; either version 2 of the License, or 17 | % (at your option) any later version. 18 | % 19 | % This program is distributed in the hope that it will be useful, 20 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | % GNU General Public License for more details. 23 | % 24 | % You can obtain a copy of the GNU General Public License from 25 | % http://www.gnu.org/copyleft/gpl.html or by writing to 26 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 27 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28 | 29 | [nf,p]=size(dl); 30 | aa=[zeros(nf,1) exp(irdct(dl.').') ones(nf,1)]; 31 | 32 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcff2pf.m: -------------------------------------------------------------------------------- 1 | function pf=lpcff2pf(ff) 2 | %LPCFF2PF Convert complex spectrum to power spectrum PF=(FF) 3 | 4 | 5 | % Copyright (C) Mike Brookes 1997 6 | % Version: $Id: lpcff2pf.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | pf=abs(ff).^2; 28 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcfq2zz.m: -------------------------------------------------------------------------------- 1 | function zz=lpcfq2zz(f,q) 2 | %LPCFQ2ZZ Convert frequencies and q factors to z-plane poles ZZ=(F,Q) 3 | %all input values are in normalized Hz 4 | % roots are at exp(2*pi*f*(-1/(2q) +- j) 5 | % if f has more columns than q, remaining columns are real roots at -f 6 | 7 | % Copyright (C) Mike Brookes 1998 8 | % Version: $Id: lpcfq2zz.m 713 2011-10-16 14:45:43Z dmb $ 9 | % 10 | % VOICEBOX is a MATLAB toolbox for speech processing. 11 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 12 | % 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | % This program is free software; you can redistribute it and/or modify 15 | % it under the terms of the GNU General Public License as published by 16 | % the Free Software Foundation; either version 2 of the License, or 17 | % (at your option) any later version. 18 | % 19 | % This program is distributed in the hope that it will be useful, 20 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | % GNU General Public License for more details. 23 | % 24 | % You can obtain a copy of the GNU General Public License from 25 | % http://www.gnu.org/copyleft/gpl.html or by writing to 26 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 27 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28 | 29 | [nf,pf]=size(f); 30 | if nargin < 2 31 | pq=0; 32 | else 33 | pq=size(q,2); 34 | end; 35 | zz=zeros(nf,pf+pq); 36 | if pq 37 | ii=1:pq; 38 | zz(:,2*ii-1)=exp(pi*f(:,ii).*(2i-q.^(-1))); 39 | zz(:,2*ii)=conj(zz(:,2*ii-1)); 40 | end 41 | if pf>pq 42 | ii=1+pq:pf; 43 | zz(:,ii+pq)= exp(-2*pi*f(:,ii)); 44 | end 45 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcim2ar.m: -------------------------------------------------------------------------------- 1 | function ar=lpcim2ar(im) 2 | %LPCIM2AR Convert impulse response to AR coefs AR=(IM) 3 | 4 | 5 | % Copyright (C) Mike Brookes 1997 6 | % Version: $Id: lpcim2ar.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | [nf,p1]=size(im); 28 | ar=zeros(nf,p1); 29 | wz=[1 zeros(1,p1-1)]; 30 | for k=1:nf 31 | ar(k,:)=wz/toeplitz(wz,im(k,:)/im(k,1)); 32 | end 33 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcis2rf.m: -------------------------------------------------------------------------------- 1 | function rf=lpcis2rf(is) 2 | %LPCRF2IS Convert inverse sines to reflection coefficients RF=(IS) 3 | 4 | 5 | % Copyright (C) Mike Brookes 1997 6 | % Version: $Id: lpcis2rf.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | rf=sin(is*pi/2); 28 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcla2rf.m: -------------------------------------------------------------------------------- 1 | function rf=lpcla2rf(la) 2 | %LPCLA2RF Convert log areas to reflection coefficients RF=(LA) 3 | 4 | 5 | % Copyright (C) Mike Brookes 1997 6 | % Version: $Id: lpcla2rf.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | [nf,p2]=size(la); 28 | rf=-tanh((la(:,1:p2-1)-la(:,2:p2))/2); 29 | 30 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpclo2rf.m: -------------------------------------------------------------------------------- 1 | function rf=lpclo2rf(lo) 2 | %LPCLO2RF Convert log area ratios to reflection coefficients RF=(LO) 3 | 4 | 5 | % Copyright (C) Mike Brookes 1997 6 | % Version: $Id: lpclo2rf.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | rf=-tanh(lo/2); 28 | 29 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcls2ar.m: -------------------------------------------------------------------------------- 1 | function ar=lpcls2ar(ls) 2 | %LPCLS2AR convert line spectrum pair frequencies to ar polynomial AR=(LS) 3 | % input vector elements should be in the range 0 to 0.5 4 | 5 | 6 | % Copyright (C) Mike Brookes 1997 7 | % Version: $Id: lpcls2ar.m 713 2011-10-16 14:45:43Z dmb $ 8 | % 9 | % VOICEBOX is a MATLAB toolbox for speech processing. 10 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 11 | % 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | % This program is free software; you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published by 15 | % the Free Software Foundation; either version 2 of the License, or 16 | % (at your option) any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details. 22 | % 23 | % You can obtain a copy of the GNU General Public License from 24 | % http://www.gnu.org/copyleft/gpl.html or by writing to 25 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | 28 | [nf,p]=size(ls); 29 | p1=p+1; 30 | p2 = p1*2; 31 | ar=zeros(nf,p1); 32 | for k=1:nf 33 | le=exp(ls(k,:)*pi*2i); 34 | lf=[1 le -1 conj(fliplr(le))]; 35 | y=real(poly(lf(1:2:p2))); 36 | x=real(poly(lf(2:2:p2))); 37 | ar(k,:)=(x(1:p1)+y(1:p1))/2; 38 | end 39 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcpf2cc.m: -------------------------------------------------------------------------------- 1 | function cc=lpcpf2cc(pf,np) 2 | %LPCPF2CC Convert power spectrum to complex cepstrum CC=(PF,NP) 3 | % Note this conversion is not exact unless the pf() spectrum is much > np 4 | 5 | % Copyright (C) Mike Brookes 1998 6 | % Version: $Id: lpcpf2cc.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | if nargin<2 np=size(pf,2)-2; end 28 | cc=irfft(log(pf.')).'; 29 | cc(:,1)=[]; 30 | [nf,p]=size(cc); 31 | if np>p 32 | cc=[cc zeros(nf,np-p)]; 33 | else 34 | cc(:,np+1:p)=[]; 35 | end 36 | 37 | 38 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcpf2rr.m: -------------------------------------------------------------------------------- 1 | function rr=lpcpf2rr(pf,p) 2 | %LPCPF2RR convert power spectrum to autocorrelation coefs RR=(PF,P) 3 | % Note that these will only be accurate if the power spectrum is much longer than p 4 | 5 | 6 | % Copyright (C) Mike Brookes 1997 7 | % Version: $Id: lpcpf2rr.m 2460 2012-10-29 22:20:45Z dmb $ 8 | % 9 | % VOICEBOX is a MATLAB toolbox for speech processing. 10 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 11 | % 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | % This program is free software; you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published by 15 | % the Free Software Foundation; either version 2 of the License, or 16 | % (at your option) any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details. 22 | % 23 | % You can obtain a copy of the GNU General Public License from 24 | % http://www.gnu.org/copyleft/gpl.html or by writing to 25 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | 28 | [nf,p2]=size(pf); 29 | if nargin<2 p=p2-2; end; 30 | ir=irfft(pf,[],2); 31 | if p>p2-2 32 | rr=[ir(:,1:p2-1) zeros(nf,p+2-p2)]; 33 | else 34 | rr=ir(:,1:p+1); 35 | end 36 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcpp2cw.m: -------------------------------------------------------------------------------- 1 | function cw=lpcpp2cw(pp) 2 | %LPCPP2PZ LPC: Convert power spectrum polynomial in cos(w) to power spectrum zeros CW=(RP) 3 | % pp is a polynomial such that |polyval(ra,e^jw)| = polyval(pp,cos(w)) 4 | 5 | % Copyright (C) Mike Brookes 1998 6 | % Version: $Id: lpcpp2cw.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | [nf,p1]=size(pp); 28 | cw=zeros(nf,p1-1); 29 | for k=1:nf 30 | cw(k,:)=roots(pp(k,:)).'; 31 | end 32 | 33 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcpp2pz.m: -------------------------------------------------------------------------------- 1 | function pz=lpcpp2pz(pp) 2 | %LPCPP2PZ LPC: Convert power spectrum polynomial in cos(w) to power spectrum zeros PZ=(RP) 3 | % pp is a polynomial such that |polyval(ra,e^jw)| = polyval(pp,cos(w)) 4 | 5 | % Copyright (C) Mike Brookes 1998 6 | % Version: $Id: lpcpp2pz.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | pz=roots(pp); 28 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcpz2zz.m: -------------------------------------------------------------------------------- 1 | function zz=lpcpz2zz(pz) 2 | %LPCPZ2ZZ LPC: Power spectrum roots to LPC poles ZZ=(PZ) 3 | % pz are the roots of the power spectrum polynomial pp(cos(w)) 4 | 5 | % Copyright (C) Mike Brookes 1998 6 | % Version: $Id: lpcpz2zz.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | zs=sqrt(pz.^2-1); 28 | zz=pz-sign(real(conj(pz).*zs)).*zs; 29 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcra2pf.m: -------------------------------------------------------------------------------- 1 | function pf=lpcra2pf(ra,np) 2 | %LPCAR2PF Convert AR coefs to power spectrum PF=(RA,NP) 3 | % The routine is faster if NP+1 is a power of 2 4 | % For RA(:,p+1) the default value of np is p and the output is PF(:,p+2) 5 | 6 | 7 | % Copyright (C) Mike Brookes 1997 8 | % Version: $Id: lpcra2pf.m 713 2011-10-16 14:45:43Z dmb $ 9 | % 10 | % VOICEBOX is a MATLAB toolbox for speech processing. 11 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 12 | % 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | % This program is free software; you can redistribute it and/or modify 15 | % it under the terms of the GNU General Public License as published by 16 | % the Free Software Foundation; either version 2 of the License, or 17 | % (at your option) any later version. 18 | % 19 | % This program is distributed in the hope that it will be useful, 20 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | % GNU General Public License for more details. 23 | % 24 | % You can obtain a copy of the GNU General Public License from 25 | % http://www.gnu.org/copyleft/gpl.html or by writing to 26 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 27 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28 | 29 | [nf,p1]=size(ra); 30 | if nargin<2 np=p1-1; end 31 | pp=2*np+2; 32 | if pp>=2*p1 33 | pf=abs(rfft([ra zeros(nf,pp-2*p1+1) ra(:,p1:-1:2)].').').^(-1); 34 | else 35 | pf=abs(rfft([ra(:,1:np+2) ra(:,np+1:-1:2)].').').^(-1); 36 | end 37 | 38 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcra2pp.m: -------------------------------------------------------------------------------- 1 | function pp=lpcra2pp(ra) 2 | %LPCAR2PP LPC: Convert ar filter autocorrelation to power spectrum polynomial in cos(w) PP=(RA) 3 | % pp is a polynomial such that |polyval(ra,e^jw)| = polyval(pp,cos(w)) 4 | 5 | % Copyright (C) Mike Brookes 1998 6 | % Version: $Id: lpcra2pp.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | persistent tp; 28 | [nf,p1]=size(ra); 29 | % we check here if p is the same as before and reuse the tp matrix 30 | if size(tp,1)~=p1 31 | p=p1-1; 32 | % chebyshev polynomials up to order p 33 | tp=zeros(p1,p1); 34 | tp(1,p1)=2; 35 | tp(2,p)=2; 36 | for i=3:p1 37 | tp(i,p+2-i:p)=2*tp(i-1,p+3-i:p1)-tp(i-2,p+2-i:p); 38 | tp(i,p1)=-tp(i-2,p1); 39 | end 40 | tp(1,p1)=1; 41 | end 42 | pp=ra*tp; 43 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcrand.m: -------------------------------------------------------------------------------- 1 | function ar=lpcrand(p,n,bw) 2 | % generate n random stable polynomials of order p with a minimum pole 3 | % bandwidth of bw*fs where fs is the sampling fequency. 4 | % To limit the pole radius to r set bw=-log(r)/pi 5 | % bw may be a vector specifying a different max bandwidth for each row 6 | 7 | % Copyright (C) Mike Brookes 1997 8 | % Version: $Id: lpcrand.m 713 2011-10-16 14:45:43Z dmb $ 9 | % 10 | % VOICEBOX is a MATLAB toolbox for speech processing. 11 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 12 | % 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | % This program is free software; you can redistribute it and/or modify 15 | % it under the terms of the GNU General Public License as published by 16 | % the Free Software Foundation; either version 2 of the License, or 17 | % (at your option) any later version. 18 | % 19 | % This program is distributed in the hope that it will be useful, 20 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | % GNU General Public License for more details. 23 | % 24 | % You can obtain a copy of the GNU General Public License from 25 | % http://www.gnu.org/copyleft/gpl.html or by writing to 26 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 27 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28 | 29 | if nargin < 3 30 | bw=0; 31 | if nargin < 2 32 | n=1; 33 | end 34 | end 35 | if p 36 | if ~bw 37 | ar=lpcrf2ar(2*rand(n,p+1)-1); 38 | else 39 | k=exp(-pi*bw(:)*(0:p)); 40 | if size(k,1)==1 41 | ar=lpcrf2ar(2*rand(n,p+1)-1).*k(ones(n,1),:); 42 | else 43 | ar=lpcrf2ar(2*rand(n,p+1)-1).*k; 44 | end 45 | end 46 | else 47 | ar=ones(n,1); 48 | end 49 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcrf2aa.m: -------------------------------------------------------------------------------- 1 | function aa=lpcrf2aa(rf) 2 | %LPCRF2AA Convert reflection coefficients to area function AA=(RF) 3 | %The areas are normalised so that aa(p+2)=1: the effective area of the free air beyond the lips. 4 | % aa(1) is the area of the glottis. This will be zero if rf(:,1)=1. 5 | 6 | 7 | % Copyright (C) Mike Brookes 1997 8 | % Version: $Id: lpcrf2aa.m 713 2011-10-16 14:45:43Z dmb $ 9 | % 10 | % VOICEBOX is a MATLAB toolbox for speech processing. 11 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 12 | % 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | % This program is free software; you can redistribute it and/or modify 15 | % it under the terms of the GNU General Public License as published by 16 | % the Free Software Foundation; either version 2 of the License, or 17 | % (at your option) any later version. 18 | % 19 | % This program is distributed in the hope that it will be useful, 20 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | % GNU General Public License for more details. 23 | % 24 | % You can obtain a copy of the GNU General Public License from 25 | % http://www.gnu.org/copyleft/gpl.html or by writing to 26 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 27 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28 | 29 | aa = fliplr(cumprod([ones(1,size(rf,1)); fliplr((1-rf)./(1+rf)).']).'); 30 | 31 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcrf2ao.m: -------------------------------------------------------------------------------- 1 | function ao=lpcrf2ao(rf) 2 | %LPCRF2AO Convert reflection coefficients to area ratios AO=(RF) 3 | % ao(k) is the ratio between the k'th and the (k+1)'th segment 4 | 5 | 6 | % Copyright (C) Mike Brookes 1997 7 | % Version: $Id: lpcrf2ao.m 713 2011-10-16 14:45:43Z dmb $ 8 | % 9 | % VOICEBOX is a MATLAB toolbox for speech processing. 10 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 11 | % 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | % This program is free software; you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published by 15 | % the Free Software Foundation; either version 2 of the License, or 16 | % (at your option) any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details. 22 | % 23 | % You can obtain a copy of the GNU General Public License from 24 | % http://www.gnu.org/copyleft/gpl.html or by writing to 25 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | 28 | ao =(1-rf)./(1+rf); 29 | 30 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcrf2is.m: -------------------------------------------------------------------------------- 1 | function is=lpcrf2is(rf) 2 | %LPCRF2IS Convert reflection coefficients to inverse sines IS=(RF) 3 | 4 | 5 | % Copyright (C) Mike Brookes 1997 6 | % Version: $Id: lpcrf2is.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | is=asin(rf)*2/pi; 28 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcrf2la.m: -------------------------------------------------------------------------------- 1 | function la=lpcrf2la(rf) 2 | %LPCRF2LA Convert reflection coefficients to log areas LA=(RF) 3 | % areas are normalised to give la(p+2)=0, the log area of the free space beyond lips 4 | 5 | 6 | % Copyright (C) Mike Brookes 1997 7 | % Version: $Id: lpcrf2la.m 713 2011-10-16 14:45:43Z dmb $ 8 | % 9 | % VOICEBOX is a MATLAB toolbox for speech processing. 10 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 11 | % 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | % This program is free software; you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published by 15 | % the Free Software Foundation; either version 2 of the License, or 16 | % (at your option) any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details. 22 | % 23 | % You can obtain a copy of the GNU General Public License from 24 | % http://www.gnu.org/copyleft/gpl.html or by writing to 25 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | 28 | r=max(min(rf,1-1E-6),1E-6-1); 29 | lo=log((1-r)./(1+r)); 30 | la=fliplr([zeros(size(rf,1),1) cumsum(fliplr(log((1-r)./(1+r))).').']); 31 | 32 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcrf2lo.m: -------------------------------------------------------------------------------- 1 | function lo=lpcrf2lo(rf) 2 | %LPCRF2LO Convert reflection coefficients to log area ratios LO=(RF) 3 | %the output values are limited to about +-14.5 4 | 5 | 6 | % Copyright (C) Mike Brookes 1997 7 | % Version: $Id: lpcrf2lo.m 713 2011-10-16 14:45:43Z dmb $ 8 | % 9 | % VOICEBOX is a MATLAB toolbox for speech processing. 10 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 11 | % 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | % This program is free software; you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published by 15 | % the Free Software Foundation; either version 2 of the License, or 16 | % (at your option) any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details. 22 | % 23 | % You can obtain a copy of the GNU General Public License from 24 | % http://www.gnu.org/copyleft/gpl.html or by writing to 25 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | 28 | r=max(min(rf,1-1E-6),1E-6-1); 29 | lo=log((1-r)./(1+r)); 30 | 31 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcrr2ar.m: -------------------------------------------------------------------------------- 1 | function [ar,e]=lpcrr2ar(rr); 2 | %LPCRR2AR convert autocorrelation coefs to ar coefs [AR,E]=(RR) 3 | %E is the residual energy 4 | 5 | % could test e each time and remove rows when it gets small 6 | 7 | 8 | % Copyright (C) Mike Brookes 1997 9 | % Version: $Id: lpcrr2ar.m 713 2011-10-16 14:45:43Z dmb $ 10 | % 11 | % VOICEBOX is a MATLAB toolbox for speech processing. 12 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 13 | % 14 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15 | % This program is free software; you can redistribute it and/or modify 16 | % it under the terms of the GNU General Public License as published by 17 | % the Free Software Foundation; either version 2 of the License, or 18 | % (at your option) any later version. 19 | % 20 | % This program is distributed in the hope that it will be useful, 21 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | % GNU General Public License for more details. 24 | % 25 | % You can obtain a copy of the GNU General Public License from 26 | % http://www.gnu.org/copyleft/gpl.html or by writing to 27 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 28 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 29 | 30 | [nf,p1]=size(rr); 31 | p=p1-1; 32 | ar=ones(nf,p1); 33 | ar(:,2) = -rr(:,2)./rr(:,1); 34 | e = rr(:,1).*(ar(:,2).^2-1); 35 | for n = 2:p 36 | k = (rr(:,n+1)+sum(rr(:,n:-1:2).*ar(:,2:n),2)) ./ e; 37 | ar(:,2:n) = ar(:,2:n)+k(:,ones(1,n-1)).*ar(:,n:-1:2); 38 | ar(:,n+1) = k; 39 | e = e.*(1-k.^2); 40 | end 41 | e=-e; 42 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpcss2zz.m: -------------------------------------------------------------------------------- 1 | function zz=lpcss2zz(ss) 2 | %LPCSS2ZZ Convert s-place poles to z-plane poles ZZ=(SS) 3 | %the s-plane is in units of Normalized Hz and so the imaginary part 4 | % of each ss() value is in the range +-0.5 5 | % 6 | % If you multiply ss by the sample frequency, a formant with 7 | % frequency f and bandwidth b will give an s-plane pole-pair 8 | % of approximately -b/2 +- j f 9 | 10 | 11 | % Copyright (C) Mike Brookes 1997 12 | % Version: $Id: lpcss2zz.m 713 2011-10-16 14:45:43Z dmb $ 13 | % 14 | % VOICEBOX is a MATLAB toolbox for speech processing. 15 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 16 | % 17 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18 | % This program is free software; you can redistribute it and/or modify 19 | % it under the terms of the GNU General Public License as published by 20 | % the Free Software Foundation; either version 2 of the License, or 21 | % (at your option) any later version. 22 | % 23 | % This program is distributed in the hope that it will be useful, 24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 | % GNU General Public License for more details. 27 | % 28 | % You can obtain a copy of the GNU General Public License from 29 | % http://www.gnu.org/copyleft/gpl.html or by writing to 30 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32 | 33 | zz=exp(2*pi*ss); 34 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpczz2ar.m: -------------------------------------------------------------------------------- 1 | function ar=lpczz2ar(zz) 2 | %LPCZZ2AR Convert z-place poles to ar coefficients AR=(ZZ) 3 | % The complex poles must occur in complex conjugate pairs 4 | % but the order is unimportant. 5 | 6 | 7 | % Copyright (C) Mike Brookes 1997 8 | % Version: $Id: lpczz2ar.m 713 2011-10-16 14:45:43Z dmb $ 9 | % 10 | % VOICEBOX is a MATLAB toolbox for speech processing. 11 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 12 | % 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | % This program is free software; you can redistribute it and/or modify 15 | % it under the terms of the GNU General Public License as published by 16 | % the Free Software Foundation; either version 2 of the License, or 17 | % (at your option) any later version. 18 | % 19 | % This program is distributed in the hope that it will be useful, 20 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | % GNU General Public License for more details. 23 | % 24 | % You can obtain a copy of the GNU General Public License from 25 | % http://www.gnu.org/copyleft/gpl.html or by writing to 26 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 27 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28 | 29 | [nf,p]=size(zz); 30 | ar=zeros(nf,p+1); 31 | for k=1:nf 32 | ar(k,:)=real(poly(zz(k,:))); 33 | end 34 | 35 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpczz2cc.m: -------------------------------------------------------------------------------- 1 | function cc=lpczz2cc(zz,np) 2 | %LPCZZ2CC Convert poles to "complex" cepstrum CC=(ZZ,NP) 3 | 4 | 5 | % Copyright (C) Mike Brookes 1997 6 | % Version: $Id: lpczz2cc.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | [nf,p]=size(zz); 28 | if (nargin < 2) np=p; end 29 | cc=zeros(nf,np); 30 | yy=zz.'; 31 | if p<2 % special case 'cos sum() is weird 32 | cc(:,1)=real(zz); 33 | for k=2:np 34 | yy=yy.*zz.'; 35 | cc(:,k)=real(yy).'/k; 36 | end 37 | else 38 | cc(:,1)=sum(real(yy)).'; 39 | for k=2:np 40 | yy=yy.*zz.'; 41 | cc(:,k)=sum(real(yy)).'/k; 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/lpczz2ss.m: -------------------------------------------------------------------------------- 1 | function ss=lpczz2ss(zz) 2 | %LPCZZ2SS Convert z-place poles to s-plane poles SS=(ZZ) 3 | %the s-plane is in units of Normalized Hz and so the imaginary part 4 | % of each ss() value is in the range +-0.5 5 | % 6 | % If you multiply ss by the sample frequency, a formant with 7 | % frequency f and bandwidth b will give an s-plane pole-pair 8 | % of approximately -b/2 +- j f 9 | 10 | 11 | % Copyright (C) Mike Brookes 1997 12 | % Version: $Id: lpczz2ss.m 713 2011-10-16 14:45:43Z dmb $ 13 | % 14 | % VOICEBOX is a MATLAB toolbox for speech processing. 15 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 16 | % 17 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18 | % This program is free software; you can redistribute it and/or modify 19 | % it under the terms of the GNU General Public License as published by 20 | % the Free Software Foundation; either version 2 of the License, or 21 | % (at your option) any later version. 22 | % 23 | % This program is distributed in the hope that it will be useful, 24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 | % GNU General Public License for more details. 27 | % 28 | % You can obtain a copy of the GNU General Public License from 29 | % http://www.gnu.org/copyleft/gpl.html or by writing to 30 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32 | 33 | ss=log(max(zz,1e-8))*0.5/pi; 34 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/m2htmlpwd.m: -------------------------------------------------------------------------------- 1 | %M2HTMLPWD - create html documentation of files in current directory 2 | % 3 | % M2HTML must be on the matlab path 4 | % available from http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=4039&objectType=FILE 5 | 6 | % Copyright (C) Mike Brookes 1998 7 | % Version: $Id: m2htmlpwd.m 713 2011-10-16 14:45:43Z dmb $ 8 | % 9 | % VOICEBOX is a MATLAB toolbox for speech processing. 10 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 11 | % 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | % This program is free software; you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published by 15 | % the Free Software Foundation; either version 2 of the License, or 16 | % (at your option) any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details. 22 | % 23 | % You can obtain a copy of the GNU General Public License from 24 | % http://www.gnu.org/copyleft/gpl.html or by writing to 25 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | 28 | pd=pwd; 29 | tl=pd(max([find(pd=='\') find(pd=='/')])+1:end); 30 | cd('..'); 31 | m2html('mfiles',tl,'htmldir',[tl '\doc']); 32 | cd(pd); 33 | winopen(['doc\' tl '\index.html']); 34 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/maxgauss.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/maxgauss.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/mel2frq.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/mel2frq.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/melbankm.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/melbankm.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/mintrace.m: -------------------------------------------------------------------------------- 1 | function p=mintrace(x) 2 | %MINTRACE find row permutation to minimize the trace p=(x) 3 | %Inputs: x(n,n) is a square real-valued matrix 4 | % 5 | %Outputs: p(n,1) is the row permutation that minimizes the trace 6 | % so that trace(x(p,:)) is as small as possible 7 | 8 | % Copyright (C) Mike Brookes 2012-2013 9 | % Version: $Id: mintrace.m 2718 2013-02-23 09:34:45Z dmb $ 10 | % 11 | % VOICEBOX is a MATLAB toolbox for speech processing. 12 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 13 | % 14 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15 | % This program is free software; you can redistribute it and/or modify 16 | % it under the terms of the GNU General Public License as published by 17 | % the Free Software Foundation; either version 2 of the License, or 18 | % (at your option) any later version. 19 | % 20 | % This program is distributed in the hope that it will be useful, 21 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | % GNU General Public License for more details. 24 | % 25 | % You can obtain a copy of the GNU General Public License from 26 | % http://www.gnu.org/copyleft/gpl.html or by writing to 27 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 28 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 29 | n=size(x,1); % input x must be square 30 | p=permutes(n); % try all permutations 31 | c=0:n:n^2-1; % convert olumns to single indexing 32 | [v,i]=min(sum(x(p+c(ones(length(p),1),:)),2)); 33 | p=p(i,:)'; 34 | 35 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/modspect.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/modspect.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/pcmu2lin.m: -------------------------------------------------------------------------------- 1 | function x=pcmu2lin(p,s) 2 | %PCMU2LIN Convert Mu-law PCM to linear X=(P,S) 3 | % lin = pcmu2lin(pcmu) where pcmu contains a vector 4 | % of mu-law values in the range 0 to 255. 5 | % No checking is performed to see that numbers are in this range. 6 | % 7 | % Output values are divided by the scale factor s: 8 | % 9 | % s Output Range 10 | % 11 | % 1 +-8031 (integer values) 12 | % 4004.2 +-2.005649 (default) 13 | % 8031 +-1 14 | % 8159 +-0.9843118 (+-1 nominal full scale) 15 | % 16 | % The default scaling factor 4004.189931 is equal to 17 | % sqrt((2207^2 + 5215^2)/2) this follows ITU standard G.711. 18 | % The sine wave with PCM-Mu values [158 139 139 158 30 11 11 30] 19 | % has a mean square value of unity corresponding to 0 dBm0. 20 | 21 | 22 | 23 | % Copyright (C) Mike Brookes 1998 24 | % Version: $Id: pcmu2lin.m 713 2011-10-16 14:45:43Z dmb $ 25 | % 26 | % VOICEBOX is a MATLAB toolbox for speech processing. 27 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 28 | % 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30 | % This program is free software; you can redistribute it and/or modify 31 | % it under the terms of the GNU General Public License as published by 32 | % the Free Software Foundation; either version 2 of the License, or 33 | % (at your option) any later version. 34 | % 35 | % This program is distributed in the hope that it will be useful, 36 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 37 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 38 | % GNU General Public License for more details. 39 | % 40 | % You can obtain a copy of the GNU General Public License from 41 | % http://www.gnu.org/copyleft/gpl.html or by writing to 42 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 43 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 44 | 45 | if nargin<2 46 | t=9.98953613E-4; 47 | else 48 | t=4/s; 49 | end 50 | 51 | m=15-rem(p,16); 52 | q=floor(p/128); 53 | e=(127-p-m+128*q)/16; 54 | x=(q-0.5).*(pow2(m+16.5,e)-16.5)*t; 55 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/peak2dquad.m: -------------------------------------------------------------------------------- 1 | function [v,xy,t,m]=peak2dquad(z) 2 | %PEAK2DQUAD find quadratically-interpolated peak in a 2D array 3 | % 4 | % Note: This routine has been superceeded by quadpeak 5 | % 6 | % Inputs: Z(m,n) is the input array 7 | % 8 | % Outputs: V is the peak value 9 | % XY(2,1) is the position of the peak (in fractional subscript values) 10 | % T is -1, 0, +1 for maximum, saddle point or minimum 11 | % M defines the fitted quadratic: z = [x y 1]*M*[x y 1]' 12 | 13 | % Copyright (C) Mike Brookes 2008 14 | % Version: $Id: peak2dquad.m 713 2011-10-16 14:45:43Z dmb $ 15 | % 16 | % VOICEBOX is a MATLAB toolbox for speech processing. 17 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 18 | % 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | % This program is free software; you can redistribute it and/or modify 21 | % it under the terms of the GNU General Public License as published by 22 | % the Free Software Foundation; either version 2 of the License, or 23 | % (at your option) any later version. 24 | % 25 | % This program is distributed in the hope that it will be useful, 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | % GNU General Public License for more details. 29 | % 30 | % You can obtain a copy of the GNU General Public License from 31 | % http://www.gnu.org/copyleft/gpl.html or by writing to 32 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 33 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34 | 35 | [v,xy,t,m]=quadpeak(z); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/permutes.m: -------------------------------------------------------------------------------- 1 | function [p,s]=permutes(n) 2 | %PERMUTES All N! permutations of 1:N + signatures [P,S]=(N) 3 | % The output P is a matrix of size (N!,N) where each row 4 | % contains a permutation of the numbers 1:N. The rows are in 5 | % lexically sorted order. 6 | % 7 | % To permute the elements of an arbitrary vector V use 8 | % V(PERMUTES(LENGTH(V))). 9 | 10 | % PERMUTES(N) is the same as SORTROWS(PERMS(1:N)) but much faster. 11 | 12 | % Thanks to Peter J Acklam for several improvements. 13 | 14 | % Copyright (c) 1998 Mike Brookes, mike.brookes@ic.ac.uk 15 | % Version: $Id: permutes.m 713 2011-10-16 14:45:43Z dmb $ 16 | % 17 | % VOICEBOX is a MATLAB toolbox for speech processing. 18 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 19 | % 20 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21 | % This program is free software; you can redistribute it and/or modify 22 | % it under the terms of the GNU General Public License as published by 23 | % the Free Software Foundation; either version 2 of the License, or 24 | % (at your option) any later version. 25 | % 26 | % This program is distributed in the hope that it will be useful, 27 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29 | % GNU General Public License for more details. 30 | % 31 | % You can obtain a copy of the GNU General Public License from 32 | % http://www.gnu.org/copyleft/gpl.html or by writing to 33 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 35 | 36 | p=1; 37 | m=1; 38 | if n>1 39 | for a=2:n 40 | q=zeros(a*m,a); 41 | r=2:a+1; 42 | ix=1:m; 43 | for b=1:a 44 | q(ix,1)=b; 45 | q(ix,2:a)=r(p); 46 | r(b)=b; 47 | ix=ix+m; 48 | end 49 | m=m*a; 50 | p=q; 51 | end 52 | end 53 | if nargout>1 s=1-2*rem(fix((1:m)'/2),2); end 54 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/phon2sone.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/phon2sone.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/polygonarea.m: -------------------------------------------------------------------------------- 1 | function a=polygonarea(p) 2 | %POLYGONAREA Calculate the area of a polygon 3 | % 4 | % Inputs: 5 | % P(n,2) is the polygon vertices 6 | % 7 | % Outputs: 8 | % A is teh area of teh polygon 9 | % 10 | % The area is positive if the vertices go anti-clockwise around the polygon. 11 | % 12 | 13 | % Copyright (C) Mike Brookes 2009 14 | % Version: $Id: polygonarea.m 713 2011-10-16 14:45:43Z dmb $ 15 | % 16 | % VOICEBOX is a MATLAB toolbox for speech processing. 17 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 18 | % 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | % This program is free software; you can redistribute it and/or modify 21 | % it under the terms of the GNU General Public License as published by 22 | % the Free Software Foundation; either version 2 of the License, or 23 | % (at your option) any later version. 24 | % 25 | % This program is distributed in the hope that it will be useful, 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | % GNU General Public License for more details. 29 | % 30 | % You can obtain a copy of the GNU General Public License from 31 | % http://www.gnu.org/copyleft/gpl.html or by writing to 32 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 33 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34 | p(end+1,:)=p(1,:); % append an extra point 35 | a=0.5*sum((p(1:end-1,1)-p(2:end,1)).*(p(1:end-1,2)+p(2:end,2)),1); 36 | if ~nargout 37 | plot(p(:,1),p(:,2),'b-'); 38 | mnx=[1.05 -0.05;-0.05 1.05]*[min(p);max(p)]; 39 | set(gca,'xlim',mnx(:,1)','ylim',mnx(:,2)'); 40 | title(sprintf('Area = %.2g',a)); 41 | end 42 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/potsband.m: -------------------------------------------------------------------------------- 1 | function [b,a]=potsband(fs) 2 | %POTSBAND Design filter for 300-3400 telephone bandwidth [B,A]=(FS) 3 | % 4 | %Input: FS=sample frequency in Hz 5 | % 6 | %Output: B/A is a discrete time bandpass filter with a passband gain of 1 7 | % 8 | %The filter meets the specifications of G.151 for any sample frequency 9 | %and has a gain of -3dB at the passband edges. 10 | 11 | 12 | % Copyright (C) Mike Brookes 1998 13 | % Version: $Id: potsband.m 713 2011-10-16 14:45:43Z dmb $ 14 | % 15 | % VOICEBOX is a MATLAB toolbox for speech processing. 16 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 17 | % 18 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19 | % This program is free software; you can redistribute it and/or modify 20 | % it under the terms of the GNU General Public License as published by 21 | % the Free Software Foundation; either version 2 of the License, or 22 | % (at your option) any later version. 23 | % 24 | % This program is distributed in the hope that it will be useful, 25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | % GNU General Public License for more details. 28 | % 29 | % You can obtain a copy of the GNU General Public License from 30 | % http://www.gnu.org/copyleft/gpl.html or by writing to 31 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 32 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33 | 34 | szp=[0.19892796195357i; -0.48623571568937+0.86535995266875i]; 35 | szp=[[0; -0.97247143137874] szp conj(szp)]; 36 | % s-plane zeros and poles of high pass 3'rd order chebychev2 filter with -3dB at w=1 37 | zl=2./(1-szp*tan(300*pi/fs))-1; 38 | al=real(poly(zl(2,:))); 39 | bl=real(poly(zl(1,:))); 40 | sw=[1;-1;1;-1]; 41 | bl=bl*(al*sw)/(bl*sw); 42 | zh=2./(szp/tan(3400*pi/fs)-1)+1; 43 | ah=real(poly(zh(2,:))); 44 | bh=real(poly(zh(1,:))); 45 | bh=bh*sum(ah)/sum(bh); 46 | b=conv(bh,bl); 47 | a=conv(ah,al); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/qrabs.m: -------------------------------------------------------------------------------- 1 | function [m,q]=qrabs(q1) 2 | %QRABS absolute value and normalization of a real quaternions [m,q]=[q1] 3 | % 4 | % Inputs: q1(4n,...) A real quaternion array. Each quaternion is a column 5 | % vector of the form [r, i, j, k]' 6 | % 7 | % Outputs: m(n,...) Array of quaternion magnitudes: m=sqrt(q'*q) 8 | % q(4n,...) Normalized version of q1 with unit magnitude 9 | % a zero quaternion is normalized to [1 0 0 0]' 10 | 11 | % Copyright (C) Mike Brookes 2000-2012 12 | % Version: $Id: qrabs.m 1645 2012-03-16 17:00:15Z dmb $ 13 | % 14 | % VOICEBOX is a MATLAB toolbox for speech processing. 15 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 16 | % 17 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18 | % This program is free software; you can redistribute it and/or modify 19 | % it under the terms of the GNU General Public License as published by 20 | % the Free Software Foundation; either version 2 of the License, or 21 | % (at your option) any later version. 22 | % 23 | % This program is distributed in the hope that it will be useful, 24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 | % GNU General Public License for more details. 27 | % 28 | % You can obtain a copy of the GNU General Public License from 29 | % http://www.gnu.org/copyleft/gpl.html or by writing to 30 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32 | q1=randn(8,3); 33 | q1(9:12)=0; 34 | s=size(q1); 35 | q=reshape(q1,4,[]); 36 | m=sqrt(sum(q.^2,1)); 37 | q(:,m>0)=q(:,m>0)./m(ones(4,1),m>0); 38 | q(1,m<=0)=1; 39 | q=reshape(q,s); 40 | s(1)=s(1)/4; 41 | m=reshape(m,s); 42 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/qrdivide.m: -------------------------------------------------------------------------------- 1 | function q=qrdivide(q1,q2) 2 | %QRDIVIDE divdes two real quaternions q=[q1,q2] 3 | % 4 | % Inputs: 5 | % 6 | % q1(4,1), q2(4,1) Two real quaternions in the form [r, i, j, k]' where i^2=j^2=k^2=ijk=-1 7 | % 8 | % Outputs: 9 | % 10 | % q(4,1) Quotient of q1/q2 such that q1=q*q2. 11 | % Note that q*q2 ~= q2*q since quaternion multiplication does not commute. 12 | 13 | % Copyright (C) Mike Brookes 2000-2008 14 | % Version: $Id: qrdivide.m 713 2011-10-16 14:45:43Z dmb $ 15 | % 16 | % VOICEBOX is a MATLAB toolbox for speech processing. 17 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 18 | % 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | % This program is free software; you can redistribute it and/or modify 21 | % it under the terms of the GNU General Public License as published by 22 | % the Free Software Foundation; either version 2 of the License, or 23 | % (at your option) any later version. 24 | % 25 | % This program is distributed in the hope that it will be useful, 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | % GNU General Public License for more details. 29 | % 30 | % You can obtain a copy of the GNU General Public License from 31 | % http://www.gnu.org/copyleft/gpl.html or by writing to 32 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 33 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34 | persistent a b c d 35 | if isempty(a) 36 | a=[5 8 9 10 15 13]; 37 | b=[6 7 11 12 14 16]; 38 | c=[1 2 3 4 6 7 11 12 16 14]; 39 | d=[1 2 3 4 5 8 9 10 13 15]; 40 | end 41 | if nargin<2 42 | % just take the inverse of the only input argument 43 | q=q1/(q1'*q1); 44 | q(2:4)=-q(2:4); 45 | else 46 | % invert q2 and do a multiply 47 | q=q2/(q2'*q2); 48 | q(2:4)=-q(2:4); 49 | t=q1*q.'; 50 | s=zeros(4,4); 51 | s(a)=-t(b); 52 | s(c)=t(d); 53 | q=sum(s,2); 54 | end 55 | 56 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/qrdotdiv.m: -------------------------------------------------------------------------------- 1 | function q=qrdotdiv(x,y) 2 | %QRDOTDIV divides two real quaternions arrays elementwise q=[x,y] 3 | % 4 | % Inputs: x(4n,...) 5 | % y(4n,...) Two real quaternion arrays of equal size 6 | % 7 | % Outputs: q(4n,...) The Hadamard quaotient (i.e. ./) of the input arrays 8 | % If y is omitted then q = x^(-1) 9 | % 10 | % Copyright (C) Mike Brookes 2000-2012 11 | % Version: $Id: qrdotdiv.m 1689 2012-03-22 21:45:41Z dmb $ 12 | % 13 | % VOICEBOX is a MATLAB toolbox for speech processing. 14 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 15 | % 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | % This program is free software; you can redistribute it and/or modify 18 | % it under the terms of the GNU General Public License as published by 19 | % the Free Software Foundation; either version 2 of the License, or 20 | % (at your option) any later version. 21 | % 22 | % This program is distributed in the hope that it will be useful, 23 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | % GNU General Public License for more details. 26 | % 27 | % You can obtain a copy of the GNU General Public License from 28 | % http://www.gnu.org/copyleft/gpl.html or by writing to 29 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 30 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 31 | persistent a b c 32 | if isempty(a) 33 | a=[1 2 3 4 2 1 4 3 3 4 1 2 4 3 2 1]; 34 | b=[1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4]; 35 | c=[6 8 10 11 15 16]; 36 | end 37 | s=size(x); 38 | x=reshape(x,4,[]); 39 | if nargin<2 % one argument - just invert x 40 | m=sum(x.^2,1); 41 | x=x./m(ones(4,1),:); 42 | x(2:4,:)=-x(2:4,:); 43 | q=reshape(x,s); 44 | else % multiply by conjugate of y and then divide by |y|^2 45 | y=reshape(y,4,[]); 46 | m=sum(y.^2,1); 47 | q=x(a,:).*y(b,:); 48 | q(c,:)=-q(c,:); 49 | q=reshape(sum(reshape(q,4,[]),1),s)./m(ones(4,1),:);; 50 | end 51 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/qrdotmult.m: -------------------------------------------------------------------------------- 1 | function q=qrdotmult(q1,q2) 2 | %QRDOTMULT multiplies together two real quaternions arrays q=[q1,q2] 3 | % 4 | % Inputs: q1(4n,...) 5 | % q2(4n,...) Two real quaternion arrays of equal size 6 | % 7 | % Outputs: q(4n,...) The Hadamard product (i.e. .*) of the input arrays 8 | % 9 | % Copyright (C) Mike Brookes 2000-2012 10 | % Version: $Id: qrdotmult.m 1618 2012-03-15 09:14:33Z dmb $ 11 | % 12 | % VOICEBOX is a MATLAB toolbox for speech processing. 13 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 14 | % 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | % This program is free software; you can redistribute it and/or modify 17 | % it under the terms of the GNU General Public License as published by 18 | % the Free Software Foundation; either version 2 of the License, or 19 | % (at your option) any later version. 20 | % 21 | % This program is distributed in the hope that it will be useful, 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | % GNU General Public License for more details. 25 | % 26 | % You can obtain a copy of the GNU General Public License from 27 | % http://www.gnu.org/copyleft/gpl.html or by writing to 28 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30 | persistent a b c 31 | if isempty(a) 32 | a=[1 2 3 4 2 1 4 3 3 4 1 2 4 3 2 1]; 33 | b=[1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4]; 34 | c=[2 3 4 7 12 14]; 35 | end 36 | s=size(q1); 37 | qa=reshape(q1,4,[]); 38 | qb=reshape(q2,4,[]); 39 | q=qa(a,:).*qb(b,:); 40 | q(c,:)=-q(c,:); 41 | q=reshape(sum(reshape(q,4,[]),1),s); 42 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/qrmult.m: -------------------------------------------------------------------------------- 1 | function q=qrmult(q1,q2) 2 | %QRMULT multiplies together two real quaternions matrices q=[q1,q2] 3 | % 4 | % Inputs: q1(4m,n) Two real quaternions arrays. Either array can 5 | % q2(4n,r) also be a scalar quaternion. 6 | % 7 | % Outputs: q(4m,r) Matrix product of q1 and q2 8 | 9 | % Copyright (C) Mike Brookes 2000-2012 10 | % Version: $Id: qrmult.m 1617 2012-03-15 09:14:01Z dmb $ 11 | % 12 | % VOICEBOX is a MATLAB toolbox for speech processing. 13 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 14 | % 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | % This program is free software; you can redistribute it and/or modify 17 | % it under the terms of the GNU General Public License as published by 18 | % the Free Software Foundation; either version 2 of the License, or 19 | % (at your option) any later version. 20 | % 21 | % This program is distributed in the hope that it will be useful, 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | % GNU General Public License for more details. 25 | % 26 | % You can obtain a copy of the GNU General Public License from 27 | % http://www.gnu.org/copyleft/gpl.html or by writing to 28 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30 | s1=size(q1); 31 | s2=size(q2); 32 | if isequal(s1,[4 1]) 33 | q=qrdotmult(repmat(q1,s2(1)/4,s2(2)),q2); 34 | elseif isequal(s2,[4 1]) 35 | q=qrdotmult(q1,repmat(q2,s1(1)/4,s1(2))); 36 | else 37 | q=rotqr2mr(q1)*q2; 38 | end 39 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/qrpermute.m: -------------------------------------------------------------------------------- 1 | function y=qrpermute(x,p) 2 | %QRPERMUTE transpose or permute a quaternion array y=[x,p] 3 | % 4 | % Inputs: x(4m,...) Real quaternions array 5 | % p new order of dimensions [default [2 1 ...] 6 | % 7 | % Outputs: y(4n,...) output real quaternion array 8 | 9 | % Copyright (C) Mike Brookes 2012 10 | % Version: $Id: qrpermute.m 1619 2012-03-15 09:31:31Z dmb $ 11 | % 12 | % VOICEBOX is a MATLAB toolbox for speech processing. 13 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 14 | % 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | % This program is free software; you can redistribute it and/or modify 17 | % it under the terms of the GNU General Public License as published by 18 | % the Free Software Foundation; either version 2 of the License, or 19 | % (at your option) any later version. 20 | % 21 | % This program is distributed in the hope that it will be useful, 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | % GNU General Public License for more details. 25 | % 26 | % You can obtain a copy of the GNU General Public License from 27 | % http://www.gnu.org/copyleft/gpl.html or by writing to 28 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30 | s=size(x); 31 | if nargin<2 32 | p=[2 1 3:length(s)]; 33 | end 34 | s(1)=s(1)/4; 35 | t=s(p); 36 | t(1)=4*t(1); 37 | y=reshape(permute(reshape(x,[4 s]),[1 p+1]),t); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/readwav.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/readwav.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/rectifyhomog.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/rectifyhomog.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/rfft.m: -------------------------------------------------------------------------------- 1 | function y=rfft(x,n,d) 2 | %RFFT Calculate the DFT of real data Y=(X,N,D) 3 | % Data is truncated/padded to length N if specified. 4 | % N even: (N+2)/2 points are returned with 5 | % the first and last being real 6 | % N odd: (N+1)/2 points are returned with the 7 | % first being real 8 | % In all cases fix(1+N/2) points are returned 9 | % D is the dimension along which to do the DFT 10 | 11 | 12 | 13 | % Copyright (C) Mike Brookes 1998 14 | % Version: $Id: rfft.m 713 2011-10-16 14:45:43Z dmb $ 15 | % 16 | % VOICEBOX is a MATLAB toolbox for speech processing. 17 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 18 | % 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | % This program is free software; you can redistribute it and/or modify 21 | % it under the terms of the GNU General Public License as published by 22 | % the Free Software Foundation; either version 2 of the License, or 23 | % (at your option) any later version. 24 | % 25 | % This program is distributed in the hope that it will be useful, 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | % GNU General Public License for more details. 29 | % 30 | % You can obtain a copy of the GNU General Public License from 31 | % http://www.gnu.org/copyleft/gpl.html or by writing to 32 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 33 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34 | 35 | s=size(x); 36 | if prod(s)==1 37 | y=x 38 | else 39 | if nargin <3 || isempty(d) 40 | d=find(s>1,1); 41 | if nargin<2 42 | n=s(d); 43 | end 44 | end 45 | if isempty(n) 46 | n=s(d); 47 | end 48 | y=fft(x,n,d); 49 | y=reshape(y,prod(s(1:d-1)),n,prod(s(d+1:end))); 50 | s(d)=1+fix(n/2); 51 | y(:,s(d)+1:end,:)=[]; 52 | y=reshape(y,s); 53 | end 54 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/rhartley.m: -------------------------------------------------------------------------------- 1 | function y=rhartley(x,n) 2 | %RHARTLEY Calculate the Hartley transform of real data Y=(X,N) 3 | % Data is truncated/padded to length N if specified. 4 | % The inverse transformation is x=hartley(y,n)/n 5 | 6 | % Copyright (C) Mike Brookes 1998 7 | % Version: $Id: rhartley.m 713 2011-10-16 14:45:43Z dmb $ 8 | % 9 | % VOICEBOX is a MATLAB toolbox for speech processing. 10 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 11 | % 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | % This program is free software; you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published by 15 | % the Free Software Foundation; either version 2 of the License, or 16 | % (at your option) any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details. 22 | % 23 | % You can obtain a copy of the GNU General Public License from 24 | % http://www.gnu.org/copyleft/gpl.html or by writing to 25 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | 28 | if nargin < 2 29 | y=fft(real(x)); 30 | else 31 | y=fft(real(x),n); 32 | end 33 | y=real(y)-imag(y); 34 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/rnsubset.m: -------------------------------------------------------------------------------- 1 | function m = rnsubset(k,n) 2 | %RNSUBSET choose k distinct random integers from 1:n M=(K,N) 3 | % 4 | % Inputs: 5 | % 6 | % K is number of disinct integers required from the range 1:N 7 | % N specifies the range - we must have K<=N 8 | % 9 | % Outputs: 10 | % 11 | % M(1,K) contains the output numbers 12 | 13 | % Copyright (C) Mike Brookes 2006 14 | % Version: $Id: rnsubset.m 713 2011-10-16 14:45:43Z dmb $ 15 | % 16 | % VOICEBOX is a MATLAB toolbox for speech processing. 17 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 18 | % 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | % This program is free software; you can redistribute it and/or modify 21 | % it under the terms of the GNU General Public License as published by 22 | % the Free Software Foundation; either version 2 of the License, or 23 | % (at your option) any later version. 24 | % 25 | % This program is distributed in the hope that it will be useful, 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | % GNU General Public License for more details. 29 | % 30 | % You can obtain a copy of the GNU General Public License from 31 | % http://www.gnu.org/copyleft/gpl.html or by writing to 32 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 33 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34 | if k>n 35 | error('rnsubset: k must be <= n'); 36 | end 37 | % We use two algorithms according to the values of k and n 38 | [f,e]=log2(n); 39 | if k>0.03*n*(e-1) 40 | [v,m]=sort(rand(1,n)); % for large k, just do a random permutation 41 | else 42 | v=ceil(rand(1,k).*(n:-1:n-k+1)); 43 | m=1:n; 44 | for i=1:k 45 | j=v(i)+i-1; 46 | x=m(i); 47 | m(i)=m(j); 48 | m(j)=x; 49 | end 50 | end 51 | m=m(1:k); 52 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/rotax2qr.m: -------------------------------------------------------------------------------- 1 | function q=rotax2qr(a,t) 2 | %ROTQR2AX converts a rotation axis and angle to the corresponding real quaternion 3 | % Inputs: 4 | % 5 | % A(3,1) Vector in the direction of the rotation axis. 6 | % T Rotation angle in radians 7 | % 8 | % Output: 9 | % 10 | % Q(4,1) normalized real-valued quaternion 11 | % 12 | % In the quaternion representation of a rotation, and q(1) = cos(t/2) 13 | % where t is the angle of rotation and q(2:4)/sin(t/2) is a unit vector 14 | % lying along the axis of rotation. 15 | % A positive rotation about [0 0 1] takes the X axis towards the Y axis. 16 | % 17 | % Copyright (C) Mike Brookes 2007-2012 18 | % Version: $Id: rotax2qr.m 2177 2012-07-13 14:23:47Z dmb $ 19 | % 20 | % VOICEBOX is a MATLAB toolbox for speech processing. 21 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 22 | % 23 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 24 | % This program is free software; you can redistribute it and/or modify 25 | % it under the terms of the GNU General Public License as published by 26 | % the Free Software Foundation; either version 2 of the License, or 27 | % (at your option) any later version. 28 | % 29 | % This program is distributed in the hope that it will be useful, 30 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 31 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 32 | % GNU General Public License for more details. 33 | % 34 | % You can obtain a copy of the GNU General Public License from 35 | % http://www.gnu.org/copyleft/gpl.html or by writing to 36 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 37 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 38 | if all(a==0) 39 | a=[1;0;0]; 40 | end 41 | m=sqrt(a(:)'*a(:)); 42 | q=[cos(0.5*t); sin(0.5*t)*a(:)/m]; 43 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/rotmc2qc.m: -------------------------------------------------------------------------------- 1 | function qc=rotmc2qc(mc) 2 | %ROTMC2QC converts a matrix of complex quaternion matrices to a matrix of complex quaternion vectors 3 | % Inputs: 4 | % 5 | % MC(2m,2n) mxn matrix of real quaternion matrices (each 2x2) 6 | % 7 | % Outputs: 8 | % 9 | % QC(2m,n) mxn matrix of real quaternion vectors (each 2x1) 10 | % 11 | % In matrix form, quaternions can be multiplied and added using normal matrix 12 | % arithmetic. Each element of an mxn matrix of quaternions is itself a 2x2 block 13 | % so the total dimension of MC is 2m x 2n. 14 | 15 | % 16 | % Copyright (C) Mike Brookes 2000-2006 17 | % Version: $Id: rotmc2qc.m 713 2011-10-16 14:45:43Z dmb $ 18 | % 19 | % VOICEBOX is a MATLAB toolbox for speech processing. 20 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 21 | % 22 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 23 | % This program is free software; you can redistribute it and/or modify 24 | % it under the terms of the GNU General Public License as published by 25 | % the Free Software Foundation; either version 2 of the License, or 26 | % (at your option) any later version. 27 | % 28 | % This program is distributed in the hope that it will be useful, 29 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 | % GNU General Public License for more details. 32 | % 33 | % You can obtain a copy of the GNU General Public License from 34 | % http://www.gnu.org/copyleft/gpl.html or by writing to 35 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 36 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 37 | qc=mc(:,1:2:end); 38 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/rotmr2qr.m: -------------------------------------------------------------------------------- 1 | function qr=rotmr2qr(mr) 2 | %ROTMR2QR converts a matrix of real quaternion matrices to quaternion vectors 3 | % Inputs: 4 | % 5 | % MR(4m,4n) mxn matrix of real quaternion matrices (each 4x4) 6 | % 7 | % Outputs: 8 | % 9 | % QR(4m,n) mxn matrix of real quaternion vectors (each 4x1) 10 | % 11 | % In matrix form, quaternions can be multiplied and added using normal matrix 12 | % arithmetic. Each element of an mxn matrix of quaternions is itself a 4x4 block 13 | % so the total dimension of MR is 4m x 4n. 14 | 15 | % 16 | % Copyright (C) Mike Brookes 2000-2006 17 | % Version: $Id: rotmr2qr.m 713 2011-10-16 14:45:43Z dmb $ 18 | % 19 | % VOICEBOX is a MATLAB toolbox for speech processing. 20 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 21 | % 22 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 23 | % This program is free software; you can redistribute it and/or modify 24 | % it under the terms of the GNU General Public License as published by 25 | % the Free Software Foundation; either version 2 of the License, or 26 | % (at your option) any later version. 27 | % 28 | % This program is distributed in the hope that it will be useful, 29 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 | % GNU General Public License for more details. 32 | % 33 | % You can obtain a copy of the GNU General Public License from 34 | % http://www.gnu.org/copyleft/gpl.html or by writing to 35 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 36 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 37 | qr=mr(:,1:4:end); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/rotqc2mc.m: -------------------------------------------------------------------------------- 1 | function mc=rotqc2mc(qc) 2 | %ROTQC2MC converts a matrix of complex quaternion vectors to quaternion matrices 3 | % Inputs: 4 | % 5 | % QC(2m,n,...) array of complex quaternion vectors (each 2x1) 6 | % 7 | % Outputs: 8 | % 9 | % MC(2m,2n,...) array of complex quaternion matrices (each 2x2) 10 | % 11 | % Each quarternion, r+ai+bj+ck is a 2x1 complex vector in the input array of the 12 | % form [ r+bi ; a+ci ]. In the output array, this becomes a 2x2 complex matrix 13 | % of the form [ r+bi -a+ci ; a+ci r-bi ]. 14 | % 15 | % In matrix form, quaternions can be multiplied and added using normal matrix 16 | % arithmetic. The complex matrix form has 4 complex elements while the real 17 | % matrix form has 16 real elements. 18 | 19 | % 20 | % Copyright (C) Mike Brookes 2000-2012 21 | % Version: $Id: rotqc2mc.m 1616 2012-03-15 09:13:31Z dmb $ 22 | % 23 | % VOICEBOX is a MATLAB toolbox for speech processing. 24 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 25 | % 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | % This program is free software; you can redistribute it and/or modify 28 | % it under the terms of the GNU General Public License as published by 29 | % the Free Software Foundation; either version 2 of the License, or 30 | % (at your option) any later version. 31 | % 32 | % This program is distributed in the hope that it will be useful, 33 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 34 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 35 | % GNU General Public License for more details. 36 | % 37 | % You can obtain a copy of the GNU General Public License from 38 | % http://www.gnu.org/copyleft/gpl.html or by writing to 39 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 40 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 41 | s=size(qc); 42 | m=s(1); 43 | qa=reshape(qc,m,[]); 44 | n=2*size(qa,2); 45 | mc=zeros(m,n); 46 | ix=1:2:m; 47 | jx=2:2:n; 48 | mc(:,jx-1)=qa; 49 | mc(ix,jx)=-conj(qa(ix+1,:)); 50 | mc(ix+1,jx)=conj(qa(ix,:)); 51 | s(2)=2*s(2); 52 | mc=reshape(mc,s); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/rotqc2qr.m: -------------------------------------------------------------------------------- 1 | function qr=rotqc2qr(qc) 2 | %ROTQC2QR converts a matrix of complex quaternion row vectors into real form 3 | % 4 | % Inputs: 5 | % 6 | % QC(2m,n) mxn matrix of complex-valued quaternions 7 | % 8 | % Outputs: 9 | % 10 | % QR(4m,n) mxn matrix of real-valued quaternions 11 | % 12 | % The complex-valued quaternion [r+j*b a+j*c] becomes [r a b c] 13 | 14 | % 15 | % Copyright (C) Mike Brookes 2000-2006 16 | % Version: $Id: rotqc2qr.m 713 2011-10-16 14:45:43Z dmb $ 17 | % 18 | % VOICEBOX is a MATLAB toolbox for speech processing. 19 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 20 | % 21 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22 | % This program is free software; you can redistribute it and/or modify 23 | % it under the terms of the GNU General Public License as published by 24 | % the Free Software Foundation; either version 2 of the License, or 25 | % (at your option) any later version. 26 | % 27 | % This program is distributed in the hope that it will be useful, 28 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30 | % GNU General Public License for more details. 31 | % 32 | % You can obtain a copy of the GNU General Public License from 33 | % http://www.gnu.org/copyleft/gpl.html or by writing to 34 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 35 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 36 | [m,n]=size(qc); 37 | i=(1:2:2*m)-mod(0:m-1,2); 38 | qr=zeros(2*m,n); 39 | qr(i,:)=real(qc); 40 | qr(i+2,:)=imag(qc); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/rotqr2ax.m: -------------------------------------------------------------------------------- 1 | function [a,t]=rotqr2ax(q) 2 | %ROTQR2AX converts a real quaternion to the corresponding rotation axis and angle 3 | % Inputs: 4 | % 5 | % Q(4,1) real-valued quaternion (with magnitude = 1) 6 | % 7 | % Outputs: 8 | % 9 | % A(3,1) Unit vector in the direction of the rotation axis. 10 | % T Rotation angle in radians (in range 0 to 2pi) 11 | % 12 | % In the quaternion representation of a rotation, and q(1) = cos(t/2) 13 | % where t is the angle of rotation in the range 0 to 2pi 14 | % and q(2:4)/sin(t/2) is a unit vector lying along the axis of rotation 15 | % a positive rotation about [0 0 1] takes the X axis towards the Y axis. 16 | % 17 | % Copyright (C) Mike Brookes 2007 18 | % Version: $Id: rotqr2ax.m 713 2011-10-16 14:45:43Z dmb $ 19 | % 20 | % VOICEBOX is a MATLAB toolbox for speech processing. 21 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 22 | % 23 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 24 | % This program is free software; you can redistribute it and/or modify 25 | % it under the terms of the GNU General Public License as published by 26 | % the Free Software Foundation; either version 2 of the License, or 27 | % (at your option) any later version. 28 | % 29 | % This program is distributed in the hope that it will be useful, 30 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 31 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 32 | % GNU General Public License for more details. 33 | % 34 | % You can obtain a copy of the GNU General Public License from 35 | % http://www.gnu.org/copyleft/gpl.html or by writing to 36 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 37 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 38 | a=q(2:4); 39 | m=sqrt(a'*a); 40 | t=2*atan2(m,q(1)); % avoids problems if unnormalized 41 | if m>0 42 | a=a/m; 43 | else 44 | a=[0 0 1]'; 45 | end 46 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/rotqr2qc.m: -------------------------------------------------------------------------------- 1 | function qc=rotqr2qc(qr) 2 | %ROTQR2QC converts a matrix of real quaternion vectors into complex form 3 | % 4 | % Inputs: 5 | % 6 | % QR(4m,...) array of real-valued quaternions 7 | % 8 | % Outputs: 9 | % 10 | % QC(2m,...) array of complex-valued quaternions 11 | % 12 | % The real-valued quaternion [r a b c]' becomes [r+j*b a+j*c]' 13 | 14 | % 15 | % Copyright (C) Mike Brookes 2000-2012 16 | % Version: $Id: rotqr2qc.m 1616 2012-03-15 09:13:31Z dmb $ 17 | % 18 | % VOICEBOX is a MATLAB toolbox for speech processing. 19 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 20 | % 21 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22 | % This program is free software; you can redistribute it and/or modify 23 | % it under the terms of the GNU General Public License as published by 24 | % the Free Software Foundation; either version 2 of the License, or 25 | % (at your option) any later version. 26 | % 27 | % This program is distributed in the hope that it will be useful, 28 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30 | % GNU General Public License for more details. 31 | % 32 | % You can obtain a copy of the GNU General Public License from 33 | % http://www.gnu.org/copyleft/gpl.html or by writing to 34 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 35 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 36 | persistent a b 37 | if isempty(a) 38 | a=[1 3 2 4]; 39 | b=[1 1i]; 40 | end 41 | s=size(qr); 42 | qq=reshape(qr,4,[]); 43 | s(1)=s(1)/2; 44 | qc=reshape(b*reshape(qq(a,:),2,[]),s); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/rotqrvec.m: -------------------------------------------------------------------------------- 1 | function y=rotqrvec(q,x) 2 | %ROTQRVEC applies a quaternion rotation ot a vector array y=[q,x] 3 | % 4 | % Inputs: q(4,1) quaternion rotation (possibly unnormalized) 5 | % x(3n,...) array of 3D column vectors 6 | % 7 | % Outputs: y(3n,...) array of 3D column vectors 8 | 9 | % Copyright (C) Mike Brookes 2011-2012 10 | % Version: $Id: rotqrvec.m 1640 2012-03-16 07:43:08Z dmb $ 11 | % 12 | % VOICEBOX is a MATLAB toolbox for speech processing. 13 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 14 | % 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | % This program is free software; you can redistribute it and/or modify 17 | % it under the terms of the GNU General Public License as published by 18 | % the Free Software Foundation; either version 2 of the License, or 19 | % (at your option) any later version. 20 | % 21 | % This program is distributed in the hope that it will be useful, 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | % GNU General Public License for more details. 25 | % 26 | % You can obtain a copy of the GNU General Public License from 27 | % http://www.gnu.org/copyleft/gpl.html or by writing to 28 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30 | s=size(x); 31 | y=reshape(rotqr2ro(q)*reshape(x,3,[]),s); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/sone2phon.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/sone2phon.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/spgrambw.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/spgrambw.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/sprintsi.m: -------------------------------------------------------------------------------- 1 | function s=sprintsi(x,d,w) 2 | %SPRINTSI Print X with SI multiplier S=(X,D,W) 3 | % D is number of decimal places (+ve) or significant digits (-ve) [default=-3] 4 | % |W| is total width including multiplier 5 | % if W<=0 then trailing 0's will be eliminated 6 | % 7 | % Example: sprintsi(2345,-2) gives '2.3 k' 8 | 9 | % Copyright (C) Mike Brookes 1998 10 | % Version: $Id: sprintsi.m 713 2011-10-16 14:45:43Z dmb $ 11 | % 12 | % VOICEBOX is a MATLAB toolbox for speech processing. 13 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 14 | % 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | % This program is free software; you can redistribute it and/or modify 17 | % it under the terms of the GNU General Public License as published by 18 | % the Free Software Foundation; either version 2 of the License, or 19 | % (at your option) any later version. 20 | % 21 | % This program is distributed in the hope that it will be useful, 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | % GNU General Public License for more details. 25 | % 26 | % You can obtain a copy of the GNU General Public License from 27 | % http://www.gnu.org/copyleft/gpl.html or by writing to 28 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30 | 31 | if nargin<3 w=0; end; 32 | if nargin<2 d=-3; end; 33 | f='afpnum kMGT'; 34 | e=max(-18,min(12,floor(log10(abs(x))))); 35 | k=floor(e/3); 36 | dp=max([0 d 3*k-d-e-1]); 37 | if w<=0 & dp 38 | w=abs(w); 39 | dp=max(find([1 mod(mod(round(x*10^(dp-3*k)),10^dp),10.^(dp:-1:1))]))-1; 40 | end 41 | if(k) 42 | s=sprintf(sprintf('%%%d.%df %c',w-2,dp,f(k+7)),x*1e-3^k); 43 | else 44 | s=sprintf(sprintf('%%%d.%df ',w-1,dp),x*1e-3^k); 45 | end 46 | -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/ssubmmse.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/ssubmmse.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/stdspectrum.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/stdspectrum.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/teager.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/teager.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/upolyhedron.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/upolyhedron.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/usasi.m: -------------------------------------------------------------------------------- 1 | function x=usasi(n,fs) 2 | %USASI generates N samples of USASI noise at sample frequency FS X=(N,FS) 3 | 4 | % This routine is based on the USASI noise defined in [1] which was later 5 | % reissued as [2]. USASI noise is intended to simulate the long-term average 6 | % of typical audio program material. The routine does not currently implement 7 | % the pulsation at 2.5Hz 12.5% duty cycle that is recommended by the standard. 8 | % Also it should probably be scaled to a well-defined power. 9 | % 10 | % [1] NRSC AM Reemphasis, Deemphasize, and Broadcast Audio Transmission Bandwidth Specifications, 11 | % EIA-549 Standard, Electronics Industries Association , July 1988. 12 | % [2] NRSC AM Reemphasis, Deemphasize, and Broadcast Audio Transmission Bandwidth Specifications, 13 | % NRSC-1-A Standard, Sept 2007, Online: http://www.nrscstandards.org/SG/NRSC-1-A.pdf 14 | 15 | % Copyright (C) Mike Brookes 1997 16 | % Version: $Id: usasi.m 713 2011-10-16 14:45:43Z dmb $ 17 | % 18 | % VOICEBOX is a MATLAB toolbox for speech processing. 19 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 20 | % 21 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22 | % This program is free software; you can redistribute it and/or modify 23 | % it under the terms of the GNU General Public License as published by 24 | % the Free Software Foundation; either version 2 of the License, or 25 | % (at your option) any later version. 26 | % 27 | % This program is distributed in the hope that it will be useful, 28 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30 | % GNU General Public License for more details. 31 | % 32 | % You can obtain a copy of the GNU General Public License from 33 | % http://www.gnu.org/copyleft/gpl.html or by writing to 34 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 35 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 36 | 37 | if nargin<2 fs=8000; end 38 | b=[1 0 -1]; 39 | a=poly(exp(-[100 320]*2*pi/fs)); 40 | 41 | x=randfilt(b,a,n); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/vadsohn.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/vadsohn.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/windinfo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/windinfo.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/windows.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/windows.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/winenvar.m: -------------------------------------------------------------------------------- 1 | function d=winenvar(n) 2 | %WINENVAR get windows environment variable [D]=(N) 3 | % 4 | % Inputs: N name of environment variable (e.g. 'temp') 5 | % 6 | % Outputs: D value of variable or [] is non-existant 7 | % 8 | % Notes: (1) This is WINDOWS specific and needs to be fixed to work on UNIX 9 | % (2) The search is case insensitive (like most of WINDOWS). 10 | % 11 | % Examples: (1) Open a temporary text file: 12 | % d=winenar('temp'); fid=fopen(fullfile(d,'temp.txt'),'wt'); 13 | 14 | % Copyright (c) 2005 Mike Brookes, mike.brookes@ic.ac.uk 15 | % Version: $Id: winenvar.m 713 2011-10-16 14:45:43Z dmb $ 16 | % 17 | % VOICEBOX is a MATLAB toolbox for speech processing. 18 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 19 | % 20 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21 | % This program is free software; you can redistribute it and/or modify 22 | % it under the terms of the GNU General Public License as published by 23 | % the Free Software Foundation; either version 2 of the License, or 24 | % (at your option) any later version. 25 | % 26 | % This program is distributed in the hope that it will be useful, 27 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29 | % GNU General Public License for more details. 30 | % 31 | % You can obtain a copy of the GNU General Public License from 32 | % http://www.gnu.org/copyleft/gpl.html or by writing to 33 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 35 | p=['%',n,'%']; 36 | [s,d]=system(['echo ',p]); 37 | while d(end)<=' '; 38 | d(end)=[]; 39 | end 40 | if strcmp(d,p) 41 | d=[]; 42 | end -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/xticksi.m: -------------------------------------------------------------------------------- 1 | function s=xticksi(ah) 2 | %XTIXKSI labels the x-axis of a plot using SI multipliers S=(AH) 3 | % 4 | % Inputs: AH axis handle [default: current axes] 5 | % 6 | % Outputs: S optional global SI multiplier (see usage below) 7 | % 8 | % Usage: (1) plot(...); 9 | % xticksi; 10 | % 11 | % (2) plot(...); 12 | % xlabel(['Frequency (' xticksi 'Hz)']); 13 | % 14 | % The first form will label the tick marks on the x-axis of the current plot 15 | % using SI multipliers where appropriate. This is particularly useful for log 16 | % plots which MATLAB does not label very well. 17 | % The second form will, if possible, use a single SI multiplier for all the tick 18 | % marks; this global multiplier can be incorporated into the axis label as shown. 19 | 20 | % Copyright (C) Mike Brookes 2009 21 | % Version: $Id: xticksi.m 713 2011-10-16 14:45:43Z dmb $ 22 | % 23 | % VOICEBOX is a MATLAB toolbox for speech processing. 24 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 25 | % 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | % This program is free software; you can redistribute it and/or modify 28 | % it under the terms of the GNU General Public License as published by 29 | % the Free Software Foundation; either version 2 of the License, or 30 | % (at your option) any later version. 31 | % 32 | % This program is distributed in the hope that it will be useful, 33 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 34 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 35 | % GNU General Public License for more details. 36 | % 37 | % You can obtain a copy of the GNU General Public License from 38 | % http://www.gnu.org/copyleft/gpl.html or by writing to 39 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 40 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 41 | if ~nargin 42 | ah=gca; 43 | end 44 | if nargout 45 | s=xyzticksi(1,ah); 46 | else 47 | xyzticksi(1,ah); 48 | end -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/xyzticksi.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/xyzticksi.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/yticksi.m: -------------------------------------------------------------------------------- 1 | function s=yticksi(ah) 2 | %YTIXKSI labels the y-axis of a plot using SI multipliers S=(AH) 3 | % 4 | % Inputs: AH axis handle [default: current axes] 5 | % 6 | % Outputs: S optional global SI multiplier (see usage below) 7 | % 8 | % Usage: (1) plot(...); 9 | % yticksi; 10 | % 11 | % (2) plot(...); 12 | % ylabel(['Frequency (' yticksi 'Hz)']); 13 | % 14 | % The first form will label the tick marks on the y-axis of the current plot 15 | % using SI multipliers where appropriate. This is particularly useful for log 16 | % plots which MATLAB does not label very well. 17 | % The second form will, if possible, use a single SI multiplier for all the tick 18 | % marks; this global multiplier can be incorporated into the axis label as shown. 19 | 20 | % Copyright (C) Mike Brookes 2009 21 | % Version: $Id: yticksi.m 713 2011-10-16 14:45:43Z dmb $ 22 | % 23 | % VOICEBOX is a MATLAB toolbox for speech processing. 24 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 25 | % 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | % This program is free software; you can redistribute it and/or modify 28 | % it under the terms of the GNU General Public License as published by 29 | % the Free Software Foundation; either version 2 of the License, or 30 | % (at your option) any later version. 31 | % 32 | % This program is distributed in the hope that it will be useful, 33 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 34 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 35 | % GNU General Public License for more details. 36 | % 37 | % You can obtain a copy of the GNU General Public License from 38 | % http://www.gnu.org/copyleft/gpl.html or by writing to 39 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 40 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 41 | if ~nargin 42 | ah=gca; 43 | end 44 | if nargout 45 | s=xyzticksi(2,ah); 46 | else 47 | xyzticksi(2,ah); 48 | end -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/zerotrim.m: -------------------------------------------------------------------------------- 1 | function z=zerotrim(x) 2 | %ZEROTRIM Remove zero trailing rows and columns Z=(X) 3 | % returns a null matrix if x is all zero. 4 | 5 | % Copyright (C) Mike Brookes 1998 6 | % Version: $Id: zerotrim.m 713 2011-10-16 14:45:43Z dmb $ 7 | % 8 | % VOICEBOX is a MATLAB toolbox for speech processing. 9 | % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | % This program is free software; you can redistribute it and/or modify 13 | % it under the terms of the GNU General Public License as published by 14 | % the Free Software Foundation; either version 2 of the License, or 15 | % (at your option) any later version. 16 | % 17 | % This program is distributed in the hope that it will be useful, 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | % GNU General Public License for more details. 21 | % 22 | % You can obtain a copy of the GNU General Public License from 23 | % http://www.gnu.org/copyleft/gpl.html or by writing to 24 | % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | c=max(find(any(x,1))); 28 | r=max(find(any(x,2))); 29 | z=x(1:r,1:c); -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/voicebox/zoomfft.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/voicebox/zoomfft.m -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/w.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/w.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/x.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/x.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/y.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/y.wav -------------------------------------------------------------------------------- /MATLAB_CODE_SOURCE/z.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YouriT/matlab-speech/743a8b7ab59136daa267a5cc941421e166f4fcfa/MATLAB_CODE_SOURCE/z.wav -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | === README 2 | 3 | cd path/to/working/directory 4 | addpath('silence-remover') 5 | 6 | ``` 7 | % arguments Fs and duration of the record 8 | recordSignal = record(8000, 5) 9 | 10 | % get datas from the record 11 | signal = getaudiodata(recordSignal) 12 | 13 | % signalDatas & Fs 14 | onlyVoiceSignal = detectVoiced(signal, 8000) 15 | 16 | % echo voice signal only 17 | audioOut = audioplayer(cell2mat(onlyVoiceSignal), 8000) 18 | play(audioOut) 19 | ``` -------------------------------------------------------------------------------- /Sources.txt: -------------------------------------------------------------------------------- 1 | http://stackoverflow.com/questions/14429885/audio-feature-extraction-using-fft-psd-and-stft-and-finding-the-most-powerful-f 2 | 3 | http://stackoverflow.com/questions/15158942/how-to-use-mfcc-feature-to-train-a-svm-classifier-for-voice-recognition 4 | 5 | http://stackoverflow.com/questions/3790445/1d-multiple-peak-detection 6 | 7 | http://stackoverflow.com/questions/13698345/filter-message-from-noisy-voice-signal 8 | 9 | http://stackoverflow.com/questions/17327666/matlab-code-that-records-voice-and-fourier-transforms-it-encounters-audiplayer-e 10 | 11 | http://stackoverflow.com/questions/7407298/voice-recognition-matlab 12 | 13 | http://stackoverflow.com/questions/4227420/matlab-missing-fundamental-from-an-fft/4231322#4231322 --------------------------------------------------------------------------------