Mercurial > hg > nimfks
comparison src/matlab/drawClickCallBack.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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c52bc3e8d3ad |
---|---|
1 %Used for the plot drawing function | |
2 function drawClickCallBack(src,callbackdata, action) | |
3 matlabVer = version; | |
4 handles = guidata(src); | |
5 ah = handles.axes2; | |
6 if(strcmp(matlabVer, '9.0.0.341360 (R2016a)')) | |
7 xAxisProps = get(ah, 'XAxis'); | |
8 xLimits = get(xAxisProps, 'Limits') | |
9 else | |
10 xAxisProps = get(ah, 'Xlim'); | |
11 xLimits = xAxisProps | |
12 end | |
13 | |
14 acts = handles.SynthesisObject.Activations; | |
15 | |
16 yMax = size(acts, 1); | |
17 xMax = size(acts, 2); | |
18 | |
19 xUnit = xLimits/size(acts, 2); | |
20 | |
21 sliderHandle = handles.sld_actstrength; | |
22 | |
23 paintBrush = handles.grp_paintbrush.SelectedObject.String; | |
24 paintBrushSize = 0; | |
25 | |
26 if(strcmp(paintBrush, 'Large Brush')) | |
27 paintBrushSize = 1; | |
28 else(strcmp(paintBrush, 'Small Brush')) | |
29 paintBrushSize = 0; | |
30 end | |
31 | |
32 if(strcmp(action, 'Draw')) | |
33 src.Pointer = 'cross'; | |
34 fillValue = get(sliderHandle, 'Value') | |
35 elseif(strcmp(action, 'Erase')) | |
36 src.Pointer = 'circle'; | |
37 fillValue = 0; | |
38 end | |
39 | |
40 cp = ah.CurrentPoint; | |
41 cx = cp(1,1)/xUnit(2) | |
42 cy = cp(1,2) | |
43 | |
44 drawXMax = (ceil(cx) + paintBrushSize); | |
45 drawYMax = (ceil(cy) + paintBrushSize); | |
46 drawXMin = (ceil(cx) - paintBrushSize); | |
47 drawYMin = (ceil(cy) - paintBrushSize); | |
48 | |
49 if(drawXMax >= xMax) | |
50 drawXMax = xMax; | |
51 end | |
52 | |
53 if(drawYMax >= yMax) | |
54 drawYMax = yMax; | |
55 end | |
56 | |
57 if(drawXMin <=0) | |
58 drawXMin = 1; | |
59 end | |
60 | |
61 if(drawYMin <=0) | |
62 drawYMin = 1; | |
63 end | |
64 | |
65 acts(drawYMin:drawYMax, drawXMin:drawXMax) = fillValue; | |
66 handles.SynthesisObject.Activations = acts; | |
67 size(acts, 1) | |
68 guidata(src, handles); | |
69 | |
70 src.WindowButtonMotionFcn = @dragCallBack; | |
71 src.WindowButtonUpFcn = @releaseCallBack; | |
72 | |
73 function dragCallBack(src, callbackdata) | |
74 cp = ah.CurrentPoint; | |
75 cx = cp(1,1)/xUnit(2); | |
76 cy = cp(1,2); | |
77 | |
78 drawXMax = (ceil(cx) + paintBrushSize); | |
79 drawYMax = (ceil(cy) + paintBrushSize); | |
80 drawXMin = (ceil(cx) - paintBrushSize); | |
81 drawYMin = (ceil(cy) - paintBrushSize); | |
82 | |
83 if(drawXMax >= xMax) | |
84 drawXMax = xMax; | |
85 end | |
86 | |
87 if(drawYMax >= yMax) | |
88 drawYMax = yMax; | |
89 end | |
90 | |
91 if(drawXMin <=0) | |
92 drawXMin = 1; | |
93 end | |
94 | |
95 if(drawYMin <=0) | |
96 drawYMin = 1; | |
97 end | |
98 | |
99 % fprintf('X: %u Y: %u', ceil(cy), ceil(cx)) | |
100 acts(drawYMin:drawYMax, drawXMin:drawXMax) = fillValue; | |
101 handles.SynthesisObject.Activations = acts; | |
102 guidata(src, handles); | |
103 end | |
104 | |
105 function releaseCallBack(src, callbackdata) | |
106 controller('switchPlot', handles); | |
107 src.Pointer = 'arrow'; | |
108 src.WindowButtonMotionFcn = ''; | |
109 src.WindowButtonUpFcn = ''; | |
110 end | |
111 end |