1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| function ctrvol
fig = findobj('type','figure','tag','ctrvol');
if ishandle(fig)
return
end
fig = figure('units','normalized',...
'position',[.1 .1 .1 .33],...
'menubar','none',...
'toolbar','none',...
'resize','off',...
'numbertitle','off',...
'visible','off',...
'tag','ctrvol');
movegui(fig,'center')
[left, right] = mx_volume('WAVE');
u = uipanel('units','normalized',...
'position',[.066 .15 .4 .8],...
'title','Left');
handles.ui(1) = uicomponent(u,'style','javax.swing.jslider','name','slidl',...
'units','normalized','Orientation',true,...
'minimum',0,'maximum',100,'value',100*double(left)/((2^16-2)/2),...
'PaintTicks',true,'MajorTickSpacing',50,...
'PaintLabels', true,'MajorTickSpacing',10);
set(handles.ui(1),'position',[.05 0 .9 1],'StateChangedCallback',@cb_vol);
u = uipanel('units','normalized',...
'position',[.533 .15 .4 .8],...
'title','Right');
handles.ui(2) = uicomponent(u,'style','javax.swing.jslider','name','slidr',...
'units','normalized','Orientation',true,...
'minimum',0,'maximum',100,'value',100*double(right)/((2^16-2)/2),...
'PaintTicks',true,'MajorTickSpacing',50,...
'PaintLabels', true,'MajorTickSpacing',10);
set(handles.ui(2),'position',[.05 0 .9 1],'StateChangedCallback',@cb_vol);
u = uipanel('units','normalized','position', [.066 .02 .868 .125],...
'title','Mute');
handles.chkl = uicontrol(u,'style','checkbox',...
'units','normalized',...
'position',[.15 .05 .3 .9],...
'tag','chkl',...
'value',1,...
'callback',@cb_vol);
handles.chkr = uicontrol(u,'style','checkbox',...
'units','normalized',...
'position',[.7 .05 .3 .9],...
'tag','chkr',...
'value',1,...
'callback',@cb_vol);
guidata(fig,handles);
set(fig,'visible','on')
function cb_vol(obj,event)
val = get(obj,'value');
if isprop(obj,'name')
str = get(obj,'name');
else str = get(obj,'tag');
end
fig = findobj('type','figure','tag','ctrvol');
handles = guidata(fig);
[left, right] = mx_volume('WAVE');
switch str
case 'chkr'
if ~val
mx_volume('WAVE', left, 0);
else
mx_volume('WAVE', left, (2^16-1)/2*get(handles.ui(2),'value')/100);
end
case 'chkl'
if ~val
mx_volume('WAVE', 0, right);
else
mx_volume('WAVE', (2^16-1)/2*get(handles.ui(1),'value')/100, right);
end
case 'slidr'
val = (2^16-1)/2*val/100;
if get(handles.chkr,'value')
mx_volume('WAVE', left, val);
end
case 'slidl'
val = (2^16-1)/2*val/100;
if get(handles.chkl,'value')
mx_volume('WAVE', val, right);
end
end |
Partager