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