annotate src/matlab/chromagram_P.m @ 0:c52bc3e8d3ad
tip
user: boblsturm
branch 'default'
added README.md
added assets/.DS_Store
added assets/playButton.jpg
added assets/stopButton.png
added assets/swapButton.jpg
added data/.DS_Store
added data/fiveoctaves.mp3
added data/glock2.wav
added data/sinScale.mp3
added data/speech_female.mp3
added data/sweep.wav
added nimfks.m.lnk
added src/.DS_Store
added src/matlab/.DS_Store
added src/matlab/AnalysisCache.m
added src/matlab/CSS.m
added src/matlab/DataHash.m
added src/matlab/ExistsInCache.m
added src/matlab/KLDivCost.m
added src/matlab/LoadFromCache.m
added src/matlab/SA_B_NMF.m
added src/matlab/SaveInCache.m
added src/matlab/Sound.m
added src/matlab/SynthesisCache.m
added src/matlab/chromagram_E.m
added src/matlab/chromagram_IF.m
added src/matlab/chromagram_P.m
added src/matlab/chromsynth.m
added src/matlab/computeSTFTFeat.m
added src/matlab/controller.m
added src/matlab/decibelSliderReleaseCallback.m
added src/matlab/drawClickCallBack.m
added src/matlab/fft2chromamx.m
added src/matlab/hz2octs.m
added src/matlab/ifgram.m
added src/matlab/ifptrack.m
added src/matlab/istft.m
added src/matlab/nimfks.fig
added src/matlab/nimfks.m
added src/matlab/nmfFn.m
added src/matlab/nmf_beta.m
added src/matlab/nmf_divergence.m
added src/matlab/nmf_euclidean.m
added src/matlab/prune_corpus.m
added src/matlab/rot_kernel.m
added src/matlab/templateAdditionResynth.m
added src/matlab/templateDelCb.m
added src/matlab/templateScrollCb.m
author |
boblsturm |
date |
Sun, 18 Jun 2017 06:26:13 -0400 |
parents |
|
children |
|
rev |
line source |
boblsturm@0
|
1 function Y = chromagram_P(d,sr,fftlen,nbin,f_ctr,f_sd)
|
boblsturm@0
|
2 % Y = chromagram_E(d,sr,fftlen,nbin)
|
boblsturm@0
|
3 % Calculate a "chromagram" of the sound in d (at sampling rate sr)
|
boblsturm@0
|
4 % Use windows of fftlen points, hopped by ffthop points
|
boblsturm@0
|
5 % Divide the octave into nbin steps
|
boblsturm@0
|
6 % Weight with center frequency f_ctr (in Hz) and gaussian SD f_sd (in octaves)
|
boblsturm@0
|
7 % 2006-09-26 dpwe@ee.columbia.edu
|
boblsturm@0
|
8
|
boblsturm@0
|
9 if nargin < 3; fftlen = 2048; end
|
boblsturm@0
|
10 if nargin < 4; nbin = 12; end
|
boblsturm@0
|
11 if nargin < 5; f_ctr = 1000; end
|
boblsturm@0
|
12 if nargin < 6; f_sd = 1; end
|
boblsturm@0
|
13
|
boblsturm@0
|
14 fftwin = fftlen/2;
|
boblsturm@0
|
15 ffthop = fftlen/4; % always for this
|
boblsturm@0
|
16
|
boblsturm@0
|
17 D = abs(specgram(d,fftlen,sr,fftwin,(fftwin-ffthop)));
|
boblsturm@0
|
18
|
boblsturm@0
|
19 [nr,nc] = size(D);
|
boblsturm@0
|
20
|
boblsturm@0
|
21 A0 = 27.5; % Hz
|
boblsturm@0
|
22 A440 = 440; % Hz
|
boblsturm@0
|
23
|
boblsturm@0
|
24 f_ctr_log = log(f_ctr/A0) / log(2);
|
boblsturm@0
|
25
|
boblsturm@0
|
26 CM = fft2chromamx(fftlen, nbin, sr, A440, f_ctr_log, f_sd);
|
boblsturm@0
|
27 % Chop extra dims
|
boblsturm@0
|
28 CM = CM(:,1:(fftlen/2)+1);
|
boblsturm@0
|
29
|
boblsturm@0
|
30 % Keep only local maxes in freq
|
boblsturm@0
|
31 Dm = (D > D([1,[1:nr-1]],:)) & (D >= D([[2:nr],nr],:));
|
boblsturm@0
|
32 Y = CM*(D.*Dm);
|