annotate src/matlab/templateAdditionResynth.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 [output, segments] = templateAdditionResynth(X, H, varargin)
|
boblsturm@0
|
2
|
boblsturm@0
|
3 if(nargin > 2)
|
boblsturm@0
|
4 win = varargin{1};
|
boblsturm@0
|
5 windowLength = win.Length;
|
boblsturm@0
|
6 overlap = win.Hop;
|
boblsturm@0
|
7 winfn = lower(win.Type);
|
boblsturm@0
|
8 win = window(winfn, windowLength);
|
boblsturm@0
|
9 else
|
boblsturm@0
|
10 overlap = floor((length(X)/size(H, 2))/2);
|
boblsturm@0
|
11 windowLength = floor(2*overlap);
|
boblsturm@0
|
12 win = window(@hann,(windowLength));
|
boblsturm@0
|
13 end
|
boblsturm@0
|
14
|
boblsturm@0
|
15 windowhop = windowLength - overlap;
|
boblsturm@0
|
16 start_samples_in_corpus=[0:size(H,1)-1]*windowhop + 1;
|
boblsturm@0
|
17 end_samples_in_corpus = start_samples_in_corpus + windowLength - 1;
|
boblsturm@0
|
18 start_samples_in_synthesis=[0:size(H,2)-1]*windowhop + 1;
|
boblsturm@0
|
19 end_samples_in_synthesis = start_samples_in_synthesis + windowLength - 1;
|
boblsturm@0
|
20
|
boblsturm@0
|
21 waitbarHandle = waitbar(0, 'Starting Template Addition Synthesis...');
|
boblsturm@0
|
22
|
boblsturm@0
|
23 output=zeros(windowhop*(size(H,2)-1)+windowLength,1);
|
boblsturm@0
|
24
|
boblsturm@0
|
25 for kk=1:size(H, 2)
|
boblsturm@0
|
26 waitbar(kk/size(H, 2), waitbarHandle, ['Creating segments...', num2str(kk), '/', num2str(size(H, 2))]);
|
boblsturm@0
|
27 extracted=H(:,kk);
|
boblsturm@0
|
28
|
boblsturm@0
|
29 for ii=find(extracted>1e-10)'
|
boblsturm@0
|
30 if length(X) > end_samples_in_corpus(ii)
|
boblsturm@0
|
31 output(start_samples_in_synthesis(kk):end_samples_in_synthesis(kk)) = ...
|
boblsturm@0
|
32 output(start_samples_in_synthesis(kk):end_samples_in_synthesis(kk)) + ...
|
boblsturm@0
|
33 win.*( ...
|
boblsturm@0
|
34 X(start_samples_in_corpus(ii):end_samples_in_corpus(ii))*extracted(ii));
|
boblsturm@0
|
35 end
|
boblsturm@0
|
36 end
|
boblsturm@0
|
37 end
|
boblsturm@0
|
38
|
boblsturm@0
|
39 output = output';
|
boblsturm@0
|
40
|
boblsturm@0
|
41 output = output./max(max(output));
|
boblsturm@0
|
42 close(waitbarHandle)
|
boblsturm@0
|
43 end |