Skip to content
Snippets Groups Projects
Commit 1f7ebffa authored by Jan-Gerrit Richter's avatar Jan-Gerrit Richter
Browse files

moved to new aureliocontrol

parent 6c780f91
No related branches found
No related tags found
No related merge requests found
...@@ -13,33 +13,19 @@ function varargout = ita_aurelio_control(varargin) ...@@ -13,33 +13,19 @@ function varargout = ita_aurelio_control(varargin)
% <a href="matlab:doc ita_robocontrol">doc ita_robocontrol</a> % <a href="matlab:doc ita_robocontrol">doc ita_robocontrol</a>
% <ITA-Toolbox> % <ITA-Toolbox>
% This file is part of the application RoboAurelioModulITAControl for the ITA-Toolbox. All rights reserved. % This file is part of the application FrontendControl for the ITA-Toolbox. All rights reserved.
% You can find the license for this m-file in the application folder. % You can find the license for this m-file in the application folder.
% </ITA-Toolbox> % </ITA-Toolbox>
% Author: Pascal Dietrich - pdi@akustik.rwth-aachen.de % Author: Pascal Dietrich - pdi@akustik.rwth-aachen.de
% reworked: Jan Richter - jri@akustik.rwth-aachen.de
%% persistent %% persistent
persistent oldSettings last_input last_AmpHighPower last_Amplifier last_AmpBridgeMode last_AmpLowImpedanceMode last_Amp26dBu last_AmpAC last_AmpMono % persistent oldSettings last_input last_AmpHighPower last_Amplifier last_AmpBridgeMode last_AmpLowImpedanceMode last_Amp26dBu last_AmpAC last_AmpMono
persistent settings presets presetNames currentPresetIndex;
% force_init = false; % force_init = false;
if isempty(last_input) if isempty(settings)
% force_init = true; settings = getInitSettings();
last_input = 'xlr';
last_AmpHighPower = false;
last_Amplifier = true;
last_AmpBridgeMode = false;
last_AmpLowImpedanceMode = false;
last_Amp26dBu = false;
last_AmpAC = false;
last_AmpMono = false;
oldSettings.ch(1).inputrange = 6;
oldSettings.ch(2).inputrange = 6;
oldSettings.ch(1).inputfeed = 'none';
oldSettings.ch(2).inputfeed = 'none';
oldSettings.ch(1).inputselect = 'xlr';
oldSettings.ch(2).inputselect = 'xlr';
oldSettings.amp_gain = -20;
end end
if nargin == 0 if nargin == 0
...@@ -47,20 +33,38 @@ if nargin == 0 ...@@ -47,20 +33,38 @@ if nargin == 0
end end
%% init %% init
sArgs = struct('channel',1:2,'groundLift',true,'inputCouplingAC',true,'feed',oldSettings.ch(1).inputfeed,'inputrange',[],... sArgs = getArgsFromSettings(settings);
'input',last_input,'mode','norm','securityMode',false,'init',false,'samplingRate',ita_preferences('samplingRate'),'outputvolume',[],...
'AmpHighPower',last_AmpHighPower,'AmpLowPower',false,'Amplifier',last_Amplifier,'NoAmplifier',false,'AmpBridgeMode',last_AmpBridgeMode,'AmpLowImpedanceMode',last_AmpLowImpedanceMode,...
'Amp26dBu',last_Amp26dBu,'Amp06dBu',false , 'NoGroundLift', false, 'AmpAC', last_AmpAC, 'AmpMono', last_AmpMono, 'getSettings',false,'reset',false);
%% parse %% parse
[sArgs] = ita_parse_arguments(sArgs,varargin); [sArgs] = ita_parse_arguments(sArgs,varargin);
ch_number = ita_angle2str( sArgs.channel - 1, 2); %zero indexing for channel numbering ch_number = ita_angle2str( sArgs.channel - 1, 2); %zero indexing for channel numbering
if sArgs.getSettings if sArgs.getSettings
varargout{1} = oldSettings; varargout{1} = settings;
varargout{2} = presetNames;
varargout{3} = currentPresetIndex;
if ~isempty(presets)
presetChanged = ~isequal(presets{currentPresetIndex},settings);
else
presetChanged = 1;
end
varargout{4} = presetChanged;
return; return;
end end
if sArgs.savePreset
presetIndex = length(presetNames) + 1;
presets{presetIndex} = settings;
presetNames{presetIndex} = sArgs.presetName;
currentPresetIndex = presetIndex;
end
if sArgs.getPresets
end
if sArgs.reset if sArgs.reset
clear all clear all
ita_aurelio_control('init'); ita_aurelio_control('init');
...@@ -74,26 +78,56 @@ end ...@@ -74,26 +78,56 @@ end
if sArgs.Amp06dBu if sArgs.Amp06dBu
sArgs.Amp26dBu = false; sArgs.Amp26dBu = false;
end end
if sArgs.Amp26dBu == false
sArgs.Amp06dBu = true;
end
if sArgs.NoAmplifier if sArgs.NoAmplifier
sArgs.Amplifier = false; sArgs.Amplifier = false;
end end
if sArgs.Amplifier
sArgs.NoAmplifier = false;
end
if sArgs.AmpLowPower if sArgs.AmpLowPower
sArgs.AmpHighPower = false; sArgs.AmpHighPower = false;
end end
if sArgs.AmpHighPower
sArgs.AmpLowPower = false;
end
if sArgs.NoGroundLift if sArgs.NoGroundLift
sArgs.groundLift = false; sArgs.groundLift = false;
% sArgs.feed = 'none'; end
if sArgs.groundLift
sArgs.NoGroundLift = false;
end
settings = setSettingsFromArgs(sArgs,settings);
if sArgs.setPreset
% find the preset with the given name
for index = 1:length(presetNames)
if strcmp(presetNames{index},sArgs.presetName)
currentPresetIndex = index;
settings = presets{index};
end
end
end end
%% write back to persistents %% write back to persistents
last_input = sArgs.input; % last_input = sArgs.input;
last_AmpHighPower = sArgs.AmpHighPower; % last_AmpHighPower = sArgs.AmpHighPower;
last_Amplifier = sArgs.Amplifier; % last_Amplifier = sArgs.Amplifier;
last_AmpBridgeMode = sArgs.AmpBridgeMode; % last_AmpBridgeMode = sArgs.AmpBridgeMode;
last_AmpLowImpedanceMode = sArgs.AmpLowImpedanceMode; % last_AmpLowImpedanceMode = sArgs.AmpLowImpedanceMode;
last_Amp26dBu = sArgs.Amp26dBu; % last_Amp26dBu = sArgs.Amp26dBu;
last_AmpAC = sArgs.AmpAC; % last_AmpAC = sArgs.AmpAC;
last_AmpMono = sArgs.AmpMono; % last_AmpMono = sArgs.AmpMono;
%% INIT device %% INIT device
if sArgs.init if sArgs.init
...@@ -104,24 +138,29 @@ if sArgs.init ...@@ -104,24 +138,29 @@ if sArgs.init
end end
%% range %% range
if ~isempty( sArgs.inputrange ) % if ~isempty( sArgs.inputrange )
sArgs.inputrange = min( max(sArgs.inputrange,-34) , 56);
for index = 1:length(sArgs.channel)
sArgs.inputrange = min( max(settings.ch(sArgs.channel(index)).inputrange,-34) , 56);
par_number = '02'; par_number = '02';
par_value = round((- sArgs.inputrange + 56)/10); %round to nearest possible par_value = round((- sArgs.inputrange + 56)/10); %round to nearest possible
for idx = 1:numel(sArgs.channel) % for idx = 1:numel(sArgs.channel)
oldSettings.ch(sArgs.channel(idx)).inputrange = 56 - (par_value * 10); % disp(idx)
end % 56 - (par_value * 10)
% settings.ch(sArgs.channel(idx)).inputrange = 56 - (par_value * 10);
% encd
if sArgs.securityMode if sArgs.securityMode
par_value = par_value + 40; par_value = par_value + 40;
end end
par_value = ita_angle2str(par_value,2); par_value = ita_angle2str(par_value,2);
send_sysex(par_number, par_value, ch_number); %send to device send_sysex(par_number, par_value, ita_angle2str(sArgs.channel(index)-1,2)); %send to device
end end
% end
%% input select -- routing control -- HUHU old values needed %% input select -- routing control -- HUHU old values needed
if ~isempty(sArgs.input) % if ~isempty(sArgs.input)
par_number = '01'; par_number = '01';
switch lower(sArgs.mode) switch lower(settings.mode)
case 'norm' %normal mode case 'norm' %normal mode
Mode = '0000'; Mode = '0000';
case 'imp' %impedance measurement case 'imp' %impedance measurement
...@@ -156,79 +195,31 @@ if ~isempty(sArgs.input) ...@@ -156,79 +195,31 @@ if ~isempty(sArgs.input)
ita_verbose_info('Careful, channel swapping is activated.',0) ita_verbose_info('Careful, channel swapping is activated.',0)
end end
switch lower(sArgs.input) % get input selection
case 'xlr' IS = getCommandFromInputSelect(settings.ch(1).inputselect);
IS = '11';
case 'lemo'
IS = '01';
sArgs.feed = 'pol';
case 'gnd'
IS = '00';
case 'bnc'
IS = '10';
otherwise
error(['input select unknown: ' sArgs.input])
end
par_value = dec2hex( bin2dec( [IS ChSwp Mode ] ) ); par_value = dec2hex( bin2dec( [IS ChSwp Mode ] ) );
send_sysex(par_number, par_value, ch_number); %send to device send_sysex(par_number, par_value, ita_angle2str(0,2));
for iCh = 1:numel(sArgs.channel) IS = getCommandFromInputSelect(settings.ch(2).inputselect);
oldSettings.ch(sArgs.channel(iCh)).inputselect = lower(sArgs.input); par_value2 = dec2hex( bin2dec( [IS ChSwp Mode ] ) );
end send_sysex(par_number, par_value2, ita_angle2str(1,2)); %send to device
end
% end
%% coupling and feed control %% coupling and feed control
if ~isempty( sArgs.feed ) % if ~isempty( sArgs.feed )
par_number = '00'; for index = 1:length(sArgs.channel)
Wait = '0'; %wait for relays to switch later rS = getCommandFromFeedSelect(sArgs,sArgs.channel(index),settings);
Lem28 = '0'; %switch 14 to 28Volts, Pin7 is then grounded
Phan = '0';
Feed = '0';
ICP = '0';
Glift = num2str(sArgs.groundLift);
AC = num2str(sArgs.inputCouplingAC);
switch lower(sArgs.feed) par_value = dec2hex( bin2dec ( ['0' rS.Wait rS.Lem28 rS.Phan rS.Feed rS.ICP rS.Glift rS.AC] ));
case 'pha' send_sysex(rS.par_number, par_value, ita_angle2str(sArgs.channel(index)-1,2)); % send final sysex
Phan = '1';
AC = '1'; %block DC from preamp inputs
case 'pol'
Feed = '1';
AC = '1'; %block DC from preamp inputs
case {'icp','iepe'}
ICP = '1';
Feed = '1';
AC = '1';
case 'p+p'
Phan = '1';
Feed = '1';
AC = '1';
case 'all'
Phan = '1';
Feed = '1';
ICP = '1';
AC = '1';
case 'ccx'
Phan = '0';
Feed = '0';
ICP = '0';
AC = '0';
Glift = '1';
case {0 ,'none','off'}
%
otherwise
error('feed wrong')
end end
par_value = dec2hex( bin2dec ( ['0' Wait Lem28 Phan Feed ICP Glift AC] ));
send_sysex(par_number, par_value, ch_number); % send final sysex
for iCh = 1:numel(sArgs.channel)
oldSettings.ch(sArgs.channel(iCh)).inputfeed = lower(sArgs.feed); % end
end
end
%% sampling rate %% sampling rate
if sArgs.samplingRate % if sArgs.samplingRate
par_number = '03'; par_number = '03';
if isnatural(sArgs.samplingRate / 48000) if isnatural(sArgs.samplingRate / 48000)
...@@ -257,27 +248,27 @@ if sArgs.samplingRate ...@@ -257,27 +248,27 @@ if sArgs.samplingRate
send_sysex(par_number, par_value, []); % send final sysex send_sysex(par_number, par_value, []); % send final sysex
ita_preferences('samplingRate',sArgs.samplingRate); % also initializes playrec ita_preferences('samplingRate',sArgs.samplingRate); % also initializes playrec
end % end
%% analog output control - Parameter 05 %% analog output control - Parameter 05
HiPow = num2str(sArgs.AmpHighPower); HiPow = num2str(settings.AmpHighPower);
AmpOn = num2str(sArgs.Amplifier); AmpOn = num2str(settings.Amplifier);
Bridge = num2str(sArgs.AmpBridgeMode); Bridge = num2str(settings.ampBridgeMode);
LoImp = num2str(sArgs.AmpLowImpedanceMode); LoImp = num2str(settings.ampLowImpedanceMode);
dBu26 = num2str(sArgs.Amp26dBu); dBu26 = num2str(settings.Amp26dBu);
AC = num2str(sArgs.AmpAC); AC = num2str(settings.ampAC);
mono = num2str(sArgs.AmpMono); mono = num2str(settings.ampMono);
par_number = '05'; par_number = '05';
par_value = dec2hex(bin2dec(['0' HiPow AmpOn Bridge LoImp dBu26 AC mono])); % 0dB attenuation par_value = dec2hex(bin2dec(['0' HiPow AmpOn Bridge LoImp dBu26 AC mono])); % 0dB attenuation
send_sysex(par_number, par_value, ch_number); %send to device send_sysex(par_number, par_value, ch_number); %send to device
if sArgs.Amp06dBu if settings.Amp26dBu
oldSettings.amp_gain = -20; settings.amp_gain = 0;
elseif sArgs.Amp26dBu else
oldSettings.amp_gain = 0; settings.amp_gain = -20;
end end
...@@ -295,6 +286,9 @@ end ...@@ -295,6 +286,9 @@ end
%% ********************** send sysex ************************************ %% ********************** send sysex ************************************
function send_sysex(par_number, par_value, ch_number) function send_sysex(par_number, par_value, ch_number)
% disp([par_number par_value ch_number])
%
if ~isempty(ch_number) && numel(str2num(ch_number)) >= 2 if ~isempty(ch_number) && numel(str2num(ch_number)) >= 2
ch_number = '7F'; ch_number = '7F';
end end
...@@ -320,3 +314,140 @@ sysex = [hex2dec('F0') hex2dec('70') complete_sysex hex2dec('F7')]; %pre- post- ...@@ -320,3 +314,140 @@ sysex = [hex2dec('F0') hex2dec('70') complete_sysex hex2dec('F7')]; %pre- post-
ita_midi(sysex,ita_preferences('out_midi_DeviceID')); ita_midi(sysex,ita_preferences('out_midi_DeviceID'));
end end
%% get settings
function settings = getInitSettings()
settings.AmpHighPower = false;
settings.Amplifier = true;
settings.ampBridgeMode = false;
settings.ampLowImpedanceMode = false;
settings.Amp26dBu = false;
settings.ampAC = false;
settings.ampMono = false;
settings.samplingRate = ita_preferences('samplingRate');
settings.mode = 'norm';
settings.groundLift = true;
settings.inputCouplingAC = true;
settings.ch(1).inputrange = 6;
settings.ch(2).inputrange = 6;
settings.ch(1).inputfeed = 'none';
settings.ch(2).inputfeed = 'none';
settings.ch(1).inputselect = 'xlr';
settings.ch(2).inputselect = 'xlr';
% settings.amp_gain = -20;
end
function sArgs = getArgsFromSettings(settings)
sArgs = struct('input',[],'feed',[],'inputrange',[],'channel',1:2,'groundLift',settings.groundLift,'inputCouplingAC',settings.inputCouplingAC,...
'mode',settings.mode,'securityMode',false,'init',false,'samplingRate',settings.samplingRate,'outputvolume',[],...
'AmpHighPower',settings.AmpHighPower,'AmpLowPower',false,'Amplifier',settings.Amplifier,'NoAmplifier',false,'AmpBridgeMode',settings.ampBridgeMode,'AmpLowImpedanceMode',settings.ampLowImpedanceMode,...
'Amp26dBu',settings.Amp26dBu,'Amp06dBu',false , 'NoGroundLift', false, 'AmpAC', settings.ampAC, 'AmpMono', settings.ampMono, 'getSettings',false,'reset',false,'setPreset',false,'getPresets',false,'savePreset',false,'presetName','');
end
function settings = setSettingsFromArgs(sArgs,settings)
settings.AmpHighPower = sArgs.AmpHighPower;
settings.Amplifier = sArgs.Amplifier;
settings.ampBridgeMode = sArgs.AmpBridgeMode;
settings.ampLowImpedanceMode = sArgs.AmpLowImpedanceMode;
settings.Amp26dBu = sArgs.Amp26dBu;
settings.ampAC = sArgs.AmpAC;
settings.ampMono = sArgs.AmpMono;
settings.samplingRate = sArgs.samplingRate;
settings.mode = sArgs.mode;
settings.groundLift = sArgs.groundLift;
settings.inputCouplingAC = sArgs.inputCouplingAC;
for index = 1:length(sArgs.channel)
if ~isempty(sArgs.inputrange)
settings.ch(sArgs.channel(index)).inputrange = sArgs.inputrange;
end
if ~isempty(sArgs.feed)
settings.ch(sArgs.channel(index)).inputfeed = sArgs.feed;
end
if ~isempty(sArgs.input)
settings.ch(sArgs.channel(index)).inputselect = sArgs.input;
end
end
end
% input selection
function IS = getCommandFromInputSelect(in)
switch lower(in)
case 'xlr'
IS = '11';
case 'lemo'
IS = '01';
sArgs.feed = 'pol';
case 'gnd'
IS = '00';
case 'bnc'
IS = '10';
otherwise
%JRI error
disp(['input select unknown'])
end
end
function returnStruct = getCommandFromFeedSelect(sArgs,channel,settings)
par_number = '00';
Wait = '0'; %wait for relays to switch later
Lem28 = '0'; %switch 14 to 28Volts, Pin7 is then grounded
Phan = '0';
Feed = '0';
ICP = '0';
Glift = num2str(settings.groundLift);
AC = num2str(settings.inputCouplingAC);
switch lower(settings.ch(channel).inputfeed)
case 'pha'
Phan = '1';
AC = '1'; %block DC from preamp inputs
case 'pol'
Feed = '1';
AC = '1'; %block DC from preamp inputs
case {'icp','iepe'}
ICP = '1';
Feed = '1';
AC = '1';
case 'p+p'
Phan = '1';
Feed = '1';
AC = '1';
case 'all'
Phan = '1';
Feed = '1';
ICP = '1';
AC = '1';
case 'ccx'
Phan = '0';
Feed = '0';
ICP = '0';
AC = '0';
Glift = '1';
case {0 ,'none','off'}
%
otherwise
error('feed wrong')
end
returnStruct.par_number = par_number;
returnStruct.Wait = Wait;
returnStruct.Lem28 = Lem28;
returnStruct.Phan = Phan;
returnStruct.Feed = Feed;
returnStruct.ICP = ICP;
returnStruct.Glift = Glift;
returnStruct.AC = AC;
end
function varargout = ita_aurelio_control_new(varargin) function varargout = ita_aurelio_control(varargin)
%ITA_AURELIO_CONTROL - Send Settings to Aurelio 2014 Frontend %ITA_AURELIO_CONTROL - Send Settings to Aurelio 2014 Frontend
% This function sends Midi Sysex Commands to the Aurelio High Precision % This function sends Midi Sysex Commands to the Aurelio High Precision
% Frontend (Swen Mueller, Immetro, Rio de Janiero, Brazil). % Frontend (Swen Mueller, Immetro, Rio de Janiero, Brazil).
...@@ -13,58 +13,54 @@ function varargout = ita_aurelio_control_new(varargin) ...@@ -13,58 +13,54 @@ function varargout = ita_aurelio_control_new(varargin)
% <a href="matlab:doc ita_robocontrol">doc ita_robocontrol</a> % <a href="matlab:doc ita_robocontrol">doc ita_robocontrol</a>
% <ITA-Toolbox> % <ITA-Toolbox>
% This file is part of the application FrontendControl for the ITA-Toolbox. All rights reserved. % This file is part of the application RoboAurelioModulITAControl for the ITA-Toolbox. All rights reserved.
% You can find the license for this m-file in the application folder. % You can find the license for this m-file in the application folder.
% </ITA-Toolbox> % </ITA-Toolbox>
% Author: Pascal Dietrich - pdi@akustik.rwth-aachen.de % Author: Pascal Dietrich - pdi@akustik.rwth-aachen.de
% reworked: Jan Richter - jri@akustik.rwth-aachen.de
%% persistent %% persistent
% persistent oldSettings last_input last_AmpHighPower last_Amplifier last_AmpBridgeMode last_AmpLowImpedanceMode last_Amp26dBu last_AmpAC last_AmpMono persistent oldSettings last_input last_AmpHighPower last_Amplifier last_AmpBridgeMode last_AmpLowImpedanceMode last_Amp26dBu last_AmpAC last_AmpMono
persistent settings presets presetNames currentPresetIndex;
% force_init = false; % force_init = false;
if isempty(settings) if isempty(last_input)
settings = getInitSettings(); % force_init = true;
last_input = 'xlr';
last_AmpHighPower = false;
last_Amplifier = true;
last_AmpBridgeMode = false;
last_AmpLowImpedanceMode = false;
last_Amp26dBu = false;
last_AmpAC = false;
last_AmpMono = false;
oldSettings.ch(1).inputrange = 6;
oldSettings.ch(2).inputrange = 6;
oldSettings.ch(1).inputfeed = 'none';
oldSettings.ch(2).inputfeed = 'none';
oldSettings.ch(1).inputselect = 'xlr';
oldSettings.ch(2).inputselect = 'xlr';
oldSettings.amp_gain = -20;
end end
if nargin == 0 if nargin == 0
ita_aureliocontrol_gui_new(); ita_aureliocontrol_gui();
end end
%% init %% init
sArgs = getArgsFromSettings(settings); sArgs = struct('channel',1:2,'groundLift',true,'inputCouplingAC',true,'feed',oldSettings.ch(1).inputfeed,'inputrange',[],...
'input',last_input,'mode','norm','securityMode',false,'init',false,'samplingRate',ita_preferences('samplingRate'),'outputvolume',[],...
'AmpHighPower',last_AmpHighPower,'AmpLowPower',false,'Amplifier',last_Amplifier,'NoAmplifier',false,'AmpBridgeMode',last_AmpBridgeMode,'AmpLowImpedanceMode',last_AmpLowImpedanceMode,...
'Amp26dBu',last_Amp26dBu,'Amp06dBu',false , 'NoGroundLift', false, 'AmpAC', last_AmpAC, 'AmpMono', last_AmpMono, 'getSettings',false,'reset',false);
%% parse %% parse
[sArgs] = ita_parse_arguments(sArgs,varargin); [sArgs] = ita_parse_arguments(sArgs,varargin);
ch_number = ita_angle2str( sArgs.channel - 1, 2); %zero indexing for channel numbering ch_number = ita_angle2str( sArgs.channel - 1, 2); %zero indexing for channel numbering
if sArgs.getSettings if sArgs.getSettings
varargout{1} = settings; varargout{1} = oldSettings;
varargout{2} = presetNames;
varargout{3} = currentPresetIndex;
if ~isempty(presets)
presetChanged = ~isequal(presets{currentPresetIndex},settings);
else
presetChanged = 1;
end
varargout{4} = presetChanged;
return; return;
end end
if sArgs.savePreset
presetIndex = length(presetNames) + 1;
presets{presetIndex} = settings;
presetNames{presetIndex} = sArgs.presetName;
currentPresetIndex = presetIndex;
end
if sArgs.getPresets
end
if sArgs.reset if sArgs.reset
clear all clear all
ita_aurelio_control('init'); ita_aurelio_control('init');
...@@ -78,89 +74,54 @@ end ...@@ -78,89 +74,54 @@ end
if sArgs.Amp06dBu if sArgs.Amp06dBu
sArgs.Amp26dBu = false; sArgs.Amp26dBu = false;
end end
if sArgs.Amp26dBu == false
sArgs.Amp06dBu = true;
end
if sArgs.NoAmplifier if sArgs.NoAmplifier
sArgs.Amplifier = false; sArgs.Amplifier = false;
end end
if sArgs.Amplifier
sArgs.NoAmplifier = false;
end
if sArgs.AmpLowPower if sArgs.AmpLowPower
sArgs.AmpHighPower = false; sArgs.AmpHighPower = false;
end end
if sArgs.AmpHighPower
sArgs.AmpLowPower = false;
end
if sArgs.NoGroundLift if sArgs.NoGroundLift
sArgs.groundLift = false; sArgs.groundLift = false;
end % sArgs.feed = 'none';
if sArgs.groundLift
sArgs.NoGroundLift = false;
end
settings = setSettingsFromArgs(sArgs,settings);
if sArgs.setPreset
% find the preset with the given name
for index = 1:length(presetNames)
if strcmp(presetNames{index},sArgs.presetName)
currentPresetIndex = index;
settings = presets{index};
end
end
end end
%% write back to persistents %% write back to persistents
% last_input = sArgs.input; last_input = sArgs.input;
% last_AmpHighPower = sArgs.AmpHighPower; last_AmpHighPower = sArgs.AmpHighPower;
% last_Amplifier = sArgs.Amplifier; last_Amplifier = sArgs.Amplifier;
% last_AmpBridgeMode = sArgs.AmpBridgeMode; last_AmpBridgeMode = sArgs.AmpBridgeMode;
% last_AmpLowImpedanceMode = sArgs.AmpLowImpedanceMode; last_AmpLowImpedanceMode = sArgs.AmpLowImpedanceMode;
% last_Amp26dBu = sArgs.Amp26dBu; last_Amp26dBu = sArgs.Amp26dBu;
% last_AmpAC = sArgs.AmpAC; last_AmpAC = sArgs.AmpAC;
% last_AmpMono = sArgs.AmpMono; last_AmpMono = sArgs.AmpMono;
%% INIT device %% INIT device
if sArgs.init if sArgs.init
% go thru all stages % go thru all stages
clear clear
ita_aurelio_control_new('input','XLR','inputrange',6,'feed',0 , 'samplingRate',ita_preferences('samplingRate')); ita_aurelio_control('input','XLR','inputrange',6,'feed',0 , 'samplingRate',ita_preferences('samplingRate'));
return return
end end
%% range %% range
% if ~isempty( sArgs.inputrange ) if ~isempty( sArgs.inputrange )
sArgs.inputrange = min( max(sArgs.inputrange,-34) , 56);
for index = 1:length(sArgs.channel)
sArgs.inputrange = min( max(settings.ch(sArgs.channel(index)).inputrange,-34) , 56);
par_number = '02'; par_number = '02';
par_value = round((- sArgs.inputrange + 56)/10); %round to nearest possible par_value = round((- sArgs.inputrange + 56)/10); %round to nearest possible
% for idx = 1:numel(sArgs.channel) for idx = 1:numel(sArgs.channel)
% disp(idx) oldSettings.ch(sArgs.channel(idx)).inputrange = 56 - (par_value * 10);
% 56 - (par_value * 10) end
% settings.ch(sArgs.channel(idx)).inputrange = 56 - (par_value * 10);
% encd
if sArgs.securityMode if sArgs.securityMode
par_value = par_value + 40; par_value = par_value + 40;
end end
par_value = ita_angle2str(par_value,2); par_value = ita_angle2str(par_value,2);
send_sysex(par_number, par_value, ita_angle2str(sArgs.channel(index)-1,2)); %send to device send_sysex(par_number, par_value, ch_number); %send to device
end end
% end
%% input select -- routing control -- HUHU old values needed %% input select -- routing control -- HUHU old values needed
% if ~isempty(sArgs.input) if ~isempty(sArgs.input)
par_number = '01'; par_number = '01';
switch lower(settings.mode) switch lower(sArgs.mode)
case 'norm' %normal mode case 'norm' %normal mode
Mode = '0000'; Mode = '0000';
case 'imp' %impedance measurement case 'imp' %impedance measurement
...@@ -195,31 +156,79 @@ end ...@@ -195,31 +156,79 @@ end
ita_verbose_info('Careful, channel swapping is activated.',0) ita_verbose_info('Careful, channel swapping is activated.',0)
end end
% get input selection switch lower(sArgs.input)
IS = getCommandFromInputSelect(settings.ch(1).inputselect); case 'xlr'
IS = '11';
case 'lemo'
IS = '01';
sArgs.feed = 'pol';
case 'gnd'
IS = '00';
case 'bnc'
IS = '10';
otherwise
error(['input select unknown: ' sArgs.input])
end
par_value = dec2hex( bin2dec( [IS ChSwp Mode ] ) ); par_value = dec2hex( bin2dec( [IS ChSwp Mode ] ) );
send_sysex(par_number, par_value, ita_angle2str(0,2)); send_sysex(par_number, par_value, ch_number); %send to device
IS = getCommandFromInputSelect(settings.ch(2).inputselect);
par_value2 = dec2hex( bin2dec( [IS ChSwp Mode ] ) );
send_sysex(par_number, par_value2, ita_angle2str(1,2)); %send to device
% end for iCh = 1:numel(sArgs.channel)
oldSettings.ch(sArgs.channel(iCh)).inputselect = lower(sArgs.input);
end
end
%% coupling and feed control %% coupling and feed control
% if ~isempty( sArgs.feed ) if ~isempty( sArgs.feed )
for index = 1:length(sArgs.channel) par_number = '00';
rS = getCommandFromFeedSelect(sArgs,sArgs.channel(index),settings); Wait = '0'; %wait for relays to switch later
Lem28 = '0'; %switch 14 to 28Volts, Pin7 is then grounded
Phan = '0';
Feed = '0';
ICP = '0';
Glift = num2str(sArgs.groundLift);
AC = num2str(sArgs.inputCouplingAC);
par_value = dec2hex( bin2dec ( ['0' rS.Wait rS.Lem28 rS.Phan rS.Feed rS.ICP rS.Glift rS.AC] )); switch lower(sArgs.feed)
send_sysex(rS.par_number, par_value, ita_angle2str(sArgs.channel(index)-1,2)); % send final sysex case 'pha'
Phan = '1';
AC = '1'; %block DC from preamp inputs
case 'pol'
Feed = '1';
AC = '1'; %block DC from preamp inputs
case {'icp','iepe'}
ICP = '1';
Feed = '1';
AC = '1';
case 'p+p'
Phan = '1';
Feed = '1';
AC = '1';
case 'all'
Phan = '1';
Feed = '1';
ICP = '1';
AC = '1';
case 'ccx'
Phan = '0';
Feed = '0';
ICP = '0';
AC = '0';
Glift = '1';
case {0 ,'none','off'}
%
otherwise
error('feed wrong')
end end
par_value = dec2hex( bin2dec ( ['0' Wait Lem28 Phan Feed ICP Glift AC] ));
send_sysex(par_number, par_value, ch_number); % send final sysex
for iCh = 1:numel(sArgs.channel)
% end oldSettings.ch(sArgs.channel(iCh)).inputfeed = lower(sArgs.feed);
end
end
%% sampling rate %% sampling rate
% if sArgs.samplingRate if sArgs.samplingRate
par_number = '03'; par_number = '03';
if isnatural(sArgs.samplingRate / 48000) if isnatural(sArgs.samplingRate / 48000)
...@@ -248,27 +257,27 @@ end ...@@ -248,27 +257,27 @@ end
send_sysex(par_number, par_value, []); % send final sysex send_sysex(par_number, par_value, []); % send final sysex
ita_preferences('samplingRate',sArgs.samplingRate); % also initializes playrec ita_preferences('samplingRate',sArgs.samplingRate); % also initializes playrec
% end end
%% analog output control - Parameter 05 %% analog output control - Parameter 05
HiPow = num2str(settings.AmpHighPower); HiPow = num2str(sArgs.AmpHighPower);
AmpOn = num2str(settings.Amplifier); AmpOn = num2str(sArgs.Amplifier);
Bridge = num2str(settings.ampBridgeMode); Bridge = num2str(sArgs.AmpBridgeMode);
LoImp = num2str(settings.ampLowImpedanceMode); LoImp = num2str(sArgs.AmpLowImpedanceMode);
dBu26 = num2str(settings.Amp26dBu); dBu26 = num2str(sArgs.Amp26dBu);
AC = num2str(settings.ampAC); AC = num2str(sArgs.AmpAC);
mono = num2str(settings.ampMono); mono = num2str(sArgs.AmpMono);
par_number = '05'; par_number = '05';
par_value = dec2hex(bin2dec(['0' HiPow AmpOn Bridge LoImp dBu26 AC mono])); % 0dB attenuation par_value = dec2hex(bin2dec(['0' HiPow AmpOn Bridge LoImp dBu26 AC mono])); % 0dB attenuation
send_sysex(par_number, par_value, ch_number); %send to device send_sysex(par_number, par_value, ch_number); %send to device
if settings.Amp26dBu if sArgs.Amp06dBu
settings.amp_gain = 0; oldSettings.amp_gain = -20;
else elseif sArgs.Amp26dBu
settings.amp_gain = -20; oldSettings.amp_gain = 0;
end end
...@@ -286,168 +295,28 @@ end ...@@ -286,168 +295,28 @@ end
%% ********************** send sysex ************************************ %% ********************** send sysex ************************************
function send_sysex(par_number, par_value, ch_number) function send_sysex(par_number, par_value, ch_number)
if ~isempty(ch_number) && numel(str2num(ch_number)) >= 2
% disp([par_number par_value ch_number]) ch_number = '7F';
%
% if ~isempty(ch_number) && numel(str2num(ch_number)) >= 2
% ch_number = '7F';
% end
% %build complete sysex
% sys_hex = {};
% sys_hex{numel(sys_hex)+1} = par_number; % hex
% sys_hex{numel(sys_hex)+1} = par_value; % hex
% if ~isempty(ch_number)
% sys_hex{numel(sys_hex)+1} = ch_number; % hex
% end
%
% for idx = 1:numel(sys_hex)
% sys_dec(idx) = hex2dec( sys_hex{idx} );
% end
%
% % generate checksum
% checksum = sum(sys_dec);
% checksum = bin2dec(num2str(mod(str2double(dec2bin(checksum)), 10000000)));
% complete_sysex = [sys_dec checksum];
%
% %send sysex
% sysex = [hex2dec('F0') hex2dec('70') complete_sysex hex2dec('F7')]; %pre- post- ampel
% ita_midi(sysex,ita_preferences('out_midi_DeviceID'));
end end
%build complete sysex
sys_hex = {};
%% get settings sys_hex{numel(sys_hex)+1} = par_number; % hex
sys_hex{numel(sys_hex)+1} = par_value; % hex
function settings = getInitSettings() if ~isempty(ch_number)
sys_hex{numel(sys_hex)+1} = ch_number; % hex
settings.AmpHighPower = false;
settings.Amplifier = true;
settings.ampBridgeMode = false;
settings.ampLowImpedanceMode = false;
settings.Amp26dBu = false;
settings.ampAC = false;
settings.ampMono = false;
settings.samplingRate = ita_preferences('samplingRate');
settings.mode = 'norm';
settings.groundLift = true;
settings.inputCouplingAC = true;
settings.ch(1).inputrange = 6;
settings.ch(2).inputrange = 6;
settings.ch(1).inputfeed = 'none';
settings.ch(2).inputfeed = 'none';
settings.ch(1).inputselect = 'xlr';
settings.ch(2).inputselect = 'xlr';
% settings.amp_gain = -20;
end end
function sArgs = getArgsFromSettings(settings) for idx = 1:numel(sys_hex)
sys_dec(idx) = hex2dec( sys_hex{idx} );
sArgs = struct('input',[],'feed',[],'inputrange',[],'channel',1:2,'groundLift',settings.groundLift,'inputCouplingAC',settings.inputCouplingAC,...
'mode',settings.mode,'securityMode',false,'init',false,'samplingRate',settings.samplingRate,'outputvolume',[],...
'AmpHighPower',settings.AmpHighPower,'AmpLowPower',false,'Amplifier',settings.Amplifier,'NoAmplifier',false,'AmpBridgeMode',settings.ampBridgeMode,'AmpLowImpedanceMode',settings.ampLowImpedanceMode,...
'Amp26dBu',settings.Amp26dBu,'Amp06dBu',false , 'NoGroundLift', false, 'AmpAC', settings.ampAC, 'AmpMono', settings.ampMono, 'getSettings',false,'reset',false,'setPreset',false,'getPresets',false,'savePreset',false,'presetName','');
end end
function settings = setSettingsFromArgs(sArgs,settings) % generate checksum
checksum = sum(sys_dec);
settings.AmpHighPower = sArgs.AmpHighPower; checksum = bin2dec(num2str(mod(str2double(dec2bin(checksum)), 10000000)));
settings.Amplifier = sArgs.Amplifier; complete_sysex = [sys_dec checksum];
settings.ampBridgeMode = sArgs.AmpBridgeMode;
settings.ampLowImpedanceMode = sArgs.AmpLowImpedanceMode;
settings.Amp26dBu = sArgs.Amp26dBu;
settings.ampAC = sArgs.AmpAC;
settings.ampMono = sArgs.AmpMono;
settings.samplingRate = sArgs.samplingRate;
settings.mode = sArgs.mode;
settings.groundLift = sArgs.groundLift;
settings.inputCouplingAC = sArgs.inputCouplingAC;
for index = 1:length(sArgs.channel)
if ~isempty(sArgs.inputrange)
settings.ch(sArgs.channel(index)).inputrange = sArgs.inputrange;
end
if ~isempty(sArgs.feed)
settings.ch(sArgs.channel(index)).inputfeed = sArgs.feed;
end
if ~isempty(sArgs.input)
settings.ch(sArgs.channel(index)).inputselect = sArgs.input;
end
end
end
% input selection %send sysex
function IS = getCommandFromInputSelect(in) sysex = [hex2dec('F0') hex2dec('70') complete_sysex hex2dec('F7')]; %pre- post- ampel
ita_midi(sysex,ita_preferences('out_midi_DeviceID'));
switch lower(in)
case 'xlr'
IS = '11';
case 'lemo'
IS = '01';
sArgs.feed = 'pol';
case 'gnd'
IS = '00';
case 'bnc'
IS = '10';
otherwise
%JRI error
disp(['input select unknown'])
end end
end
function returnStruct = getCommandFromFeedSelect(sArgs,channel,settings)
par_number = '00';
Wait = '0'; %wait for relays to switch later
Lem28 = '0'; %switch 14 to 28Volts, Pin7 is then grounded
Phan = '0';
Feed = '0';
ICP = '0';
Glift = num2str(settings.groundLift);
AC = num2str(settings.inputCouplingAC);
switch lower(settings.ch(channel).inputfeed)
case 'pha'
Phan = '1';
AC = '1'; %block DC from preamp inputs
case 'pol'
Feed = '1';
AC = '1'; %block DC from preamp inputs
case {'icp','iepe'}
ICP = '1';
Feed = '1';
AC = '1';
case 'p+p'
Phan = '1';
Feed = '1';
AC = '1';
case 'all'
Phan = '1';
Feed = '1';
ICP = '1';
AC = '1';
case 'ccx'
Phan = '0';
Feed = '0';
ICP = '0';
AC = '0';
Glift = '1';
case {0 ,'none','off'}
%
otherwise
error('feed wrong')
end
returnStruct.par_number = par_number;
returnStruct.Wait = Wait;
returnStruct.Lem28 = Lem28;
returnStruct.Phan = Phan;
returnStruct.Feed = Feed;
returnStruct.ICP = ICP;
returnStruct.Glift = Glift;
returnStruct.AC = AC;
end
function ita_aureliocontrol_gui(varargin) function ita_aureliocontrol_gui(varargin)
% ITA_AURELIOCONTROL_GUI - gui for aurelio remote control % ita_aureliocontrol_gui - gui for aurelio remote control
% <ITA-Toolbox> % <ITA-Toolbox>
% This file is part of the application RoboAurelioModulITAControl for the ITA-Toolbox. All rights reserved. % This file is part of the application RoboAurelioModulITAControl for the ITA-Toolbox. All rights reserved.
% You can find the license for this m-file in the application folder. % You can find the license for this m-file in the application folder.
% </ITA-Toolbox> % </ITA-Toolbox>
oldSettings = ita_aurelio_control('getSettings'); [currentSettings, presetNames, currentPresetNumber,presetChanged] = ita_aurelio_control('getSettings');
persistent hFigure persistent hFigure
%% nice gui settings %% nice gui settings
...@@ -14,7 +14,7 @@ gui_bg_color = [0.8 0.8 0.8]; ...@@ -14,7 +14,7 @@ gui_bg_color = [0.8 0.8 0.8];
if nargin == 0 if nargin == 0
width = 440; width = 440;
height = 540; height = 640;
mpos = get(0,'Monitor'); %try to position in the middle of the screen mpos = get(0,'Monitor'); %try to position in the middle of the screen
w_position = (mpos(1,length(mpos)-1)/2)-(width/2); w_position = (mpos(1,length(mpos)-1)/2)-(width/2);
...@@ -59,6 +59,8 @@ ver_space = 0.5; ...@@ -59,6 +59,8 @@ ver_space = 0.5;
button_height = 1.5; button_height = 1.5;
button_width = 20; button_width = 20;
button_space = 0.125;
lower_space = 0.25;
for ch_idx = 1:2 for ch_idx = 1:2
%% FEED %% FEED
...@@ -66,7 +68,8 @@ for ch_idx = 1:2 ...@@ -66,7 +68,8 @@ for ch_idx = 1:2
nameStr = {'NONE','Pol','Pha','P+P','icp','all'}; nameStr = {'NONE','Pol','Pha','P+P','icp','all'};
nButtons = length(nameStr); nButtons = length(nameStr);
InputFeed{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height)];
InputFeed{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)];
InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size]; InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size];
InputFeed{ch_idx}.h = uibuttongroup(... InputFeed{ch_idx}.h = uibuttongroup(...
'Parent',hFigure,... 'Parent',hFigure,...
...@@ -81,7 +84,8 @@ for ch_idx = 1:2 ...@@ -81,7 +84,8 @@ for ch_idx = 1:2
'SelectionChangeFcn',@InputFeedCallback,... 'SelectionChangeFcn',@InputFeedCallback,...
'OldSelectedObject',[]); 'OldSelectedObject',[]);
position = [0 0 button_width button_height];
position = [lower_space button_space button_width button_height];
for button_idx = 1:nButtons for button_idx = 1:nButtons
InputFeed{ch_idx}.hButton(button_idx) = uicontrol(... InputFeed{ch_idx}.hButton(button_idx) = uicontrol(...
'Parent',InputFeed{ch_idx}.h,... 'Parent',InputFeed{ch_idx}.h,...
...@@ -92,15 +96,15 @@ for ch_idx = 1:2 ...@@ -92,15 +96,15 @@ for ch_idx = 1:2
'String',nameStr{button_idx},... 'String',nameStr{button_idx},...
'Style','togglebutton',... 'Style','togglebutton',...
'UserData',userdata,... 'UserData',userdata,...
'Value',strcmpi(nameStr{button_idx},oldSettings.ch(ch_idx).inputfeed),... 'Value',strcmpi(nameStr{button_idx},currentSettings.ch(ch_idx).inputfeed),...
'Tag','togglebuttonNorm'); 'Tag','togglebuttonNorm');
position = position + [0 button_height 0 0]; position = position + [0 button_height+button_space 0 0];
end end
%% INPUT SELECT %% INPUT SELECT
nameStr = {'Lemo','XLR','gnd','BNC'}; nameStr = {'Lemo','XLR','gnd','BNC'};
nButtons = length(nameStr); nButtons = length(nameStr);
InputSelect{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height)]; InputSelect{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)];
InputSelect{ch_idx}.Position = [InputFeed{ch_idx}.Position(1) InputFeed{ch_idx}.Position(2)+ InputFeed{ch_idx}.Position(4)+ver_space InputSelect{ch_idx}.Size]; InputSelect{ch_idx}.Position = [InputFeed{ch_idx}.Position(1) InputFeed{ch_idx}.Position(2)+ InputFeed{ch_idx}.Position(4)+ver_space InputSelect{ch_idx}.Size];
InputSelect{ch_idx}.h = uibuttongroup(... InputSelect{ch_idx}.h = uibuttongroup(...
'Parent',hFigure,... 'Parent',hFigure,...
...@@ -115,7 +119,7 @@ for ch_idx = 1:2 ...@@ -115,7 +119,7 @@ for ch_idx = 1:2
'SelectionChangeFcn',@InputSelectCallback,... 'SelectionChangeFcn',@InputSelectCallback,...
'OldSelectedObject',[]); 'OldSelectedObject',[]);
position = [0 0 button_width button_height]; position = [lower_space button_space button_width button_height];
for button_idx = 1:nButtons for button_idx = 1:nButtons
InputSelect{ch_idx}.hButton(button_idx) = uicontrol(... InputSelect{ch_idx}.hButton(button_idx) = uicontrol(...
'Parent',InputSelect{ch_idx}.h,... 'Parent',InputSelect{ch_idx}.h,...
...@@ -125,9 +129,9 @@ for ch_idx = 1:2 ...@@ -125,9 +129,9 @@ for ch_idx = 1:2
'String',nameStr{button_idx},... 'String',nameStr{button_idx},...
'UserData',userdata,... 'UserData',userdata,...
'Style','togglebutton',... 'Style','togglebutton',...
'Value',strcmpi(nameStr{button_idx},oldSettings.ch(ch_idx).inputselect),... 'Value',strcmpi(nameStr{button_idx},currentSettings.ch(ch_idx).inputselect),...
'Tag','togglebuttonNorm'); 'Tag','togglebuttonNorm');
position = position + [0 button_height 0 0]; position = position + [0 button_height+button_space 0 0];
end end
%% INPUT RANGE %% INPUT RANGE
...@@ -135,7 +139,7 @@ for ch_idx = 1:2 ...@@ -135,7 +139,7 @@ for ch_idx = 1:2
nameStr = cellstr(num2str(inputRange_vec')); nameStr = cellstr(num2str(inputRange_vec'));
nButtons = length(nameStr); nButtons = length(nameStr);
InputRange{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height)]; InputRange{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)];
InputRange{ch_idx}.Position = [InputSelect{ch_idx}.Position(1) InputSelect{ch_idx}.Position(2)+ InputSelect{ch_idx}.Position(4)+ver_space InputRange{ch_idx}.Size]; InputRange{ch_idx}.Position = [InputSelect{ch_idx}.Position(1) InputSelect{ch_idx}.Position(2)+ InputSelect{ch_idx}.Position(4)+ver_space InputRange{ch_idx}.Size];
InputRange{ch_idx}.h = uibuttongroup(... InputRange{ch_idx}.h = uibuttongroup(...
'Parent',hFigure,... 'Parent',hFigure,...
...@@ -150,7 +154,7 @@ for ch_idx = 1:2 ...@@ -150,7 +154,7 @@ for ch_idx = 1:2
'SelectionChangeFcn',@InputRangeCallback,... 'SelectionChangeFcn',@InputRangeCallback,...
'OldSelectedObject',[]); 'OldSelectedObject',[]);
position = [0 0 button_width button_height]; position = [lower_space button_space button_width button_height];
for button_idx = 1:nButtons for button_idx = 1:nButtons
InputRange{ch_idx}.hButton(button_idx) = uicontrol(... InputRange{ch_idx}.hButton(button_idx) = uicontrol(...
'Parent',InputRange{ch_idx}.h,... 'Parent',InputRange{ch_idx}.h,...
...@@ -161,9 +165,9 @@ for ch_idx = 1:2 ...@@ -161,9 +165,9 @@ for ch_idx = 1:2
'BackgroundColor',[0.1 0.9 0.1],... 'BackgroundColor',[0.1 0.9 0.1],...
'UserData',userdata,... 'UserData',userdata,...
'Style','togglebutton',... 'Style','togglebutton',...
'Value',oldSettings.ch(ch_idx).inputrange == inputRange_vec(button_idx),... 'Value',currentSettings.ch(ch_idx).inputrange == inputRange_vec(button_idx),...
'Tag','togglebuttonNorm'); 'Tag','togglebuttonNorm');
position = position + [0 button_height 0 0]; position = position + [0 button_height+button_space 0 0];
end end
hor_start = hor_start + button_width + hor_space; hor_start = hor_start + button_width + hor_space;
...@@ -192,7 +196,7 @@ argCell{ele} = {'mode','norm'}; ...@@ -192,7 +196,7 @@ argCell{ele} = {'mode','norm'};
%% generate modebuttons %% generate modebuttons
InputFeed = InputFeed(1); InputFeed = InputFeed(1);
nButtons = length(nameStr); nButtons = length(nameStr);
InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height)]; InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)];
InputFeed{1}.Position = [hor_start+1 ver_start InputFeed{1}.Size]; InputFeed{1}.Position = [hor_start+1 ver_start InputFeed{1}.Size];
InputFeed{1}.h = uibuttongroup(... InputFeed{1}.h = uibuttongroup(...
'Parent',hFigure,... 'Parent',hFigure,...
...@@ -204,9 +208,10 @@ InputFeed{1}.h = uibuttongroup(... ...@@ -204,9 +208,10 @@ InputFeed{1}.h = uibuttongroup(...
'Position',InputFeed{1}.Position,... 'Position',InputFeed{1}.Position,...
'BackgroundColor',gui_bg_color,... 'BackgroundColor',gui_bg_color,...
'SelectedObject',[],... 'SelectedObject',[],...
'OldSelectedObject',[]); 'OldSelectedObject',[], ...
'SelectionChangeFcn',@modePushButtonCallback);
ch_idx = 1; ch_idx = 1;
position = [0 0 button_width button_height]; position = [lower_space button_space button_width button_height];
for button_idx = 1:nButtons for button_idx = 1:nButtons
userdata = argCell{button_idx}; userdata = argCell{button_idx};
ControlButton{ch_idx}.hButton(button_idx) = uicontrol(... ControlButton{ch_idx}.hButton(button_idx) = uicontrol(...
...@@ -215,12 +220,11 @@ for button_idx = 1:nButtons ...@@ -215,12 +220,11 @@ for button_idx = 1:nButtons
'FontSize',10,... 'FontSize',10,...
'Position',position,... 'Position',position,...
'String',nameStr{button_idx},... 'String',nameStr{button_idx},...
'Style','pushbutton',... 'Style','togglebutton',...
'Callback',@modePushButtonCallback,...
'UserData',userdata,... 'UserData',userdata,...
'Value',0,... 'Value',strcmpi(currentSettings.mode,argCell{button_idx}{2}),...
'Tag',''); 'Tag','');
position = position + [0 button_height 0 0]; position = position + [0 button_height+button_space 0 0];
end end
...@@ -230,39 +234,44 @@ argCell = {}; ...@@ -230,39 +234,44 @@ argCell = {};
ele = 1; ele = 1;
nameStr{ele} = {'Init'}; nameStr{ele} = {'Init'};
argCell{ele} = {'init'}; argCell{ele} = {'init'};
tooltip{ele} = {'Reinitialize the Aurelio'};
% ele = ele + 1; % ele = ele + 1;
% nameStr{ele} = {['Reset']}; % nameStr{ele} = {['Reset']};
% argCell{ele} = {'Reset'}; % argCell{ele} = {'Reset'};
ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'Amplifier'}; nameStr{ele} = {'Use Amplifier'};
argCell{ele} = {'Amplifier'}; argCell{ele} = {'Amplifier'};
tooltip{ele} = {'Turn the amplifier on'};
ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'NoAmplifier'}; % nameStr{ele} = {'NoAmplifier'};
argCell{ele} = {'NoAmplifier'}; % argCell{ele} = {'NoAmplifier'};
ele = ele + 1; % ele = ele + 1;
nameStr{ele} = {'Amp26dBu'}; nameStr{ele} = {'Amp +20dB'};
argCell{ele} = {'Amp26dBu'}; argCell{ele} = {'Amp26dBu'};
tooltip{ele} = {'Amp + 20 dB'};
ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'Amp06dBu'}; % nameStr{ele} = {'Amp06dBu'};
argCell{ele} = {'Amp06dBu'}; % argCell{ele} = {'Amp06dBu'};
ele = ele + 1; % ele = ele + 1;
nameStr{ele} = {'AmpHighPower'}; nameStr{ele} = {'AmpHighPower'};
argCell{ele} = {'AmpHighPower'}; argCell{ele} = {'AmpHighPower'};
tooltip{ele} = {'Activate High power Amp'};
ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'AmpLowPower'}; % nameStr{ele} = {'AmpLowPower'};
argCell{ele} = {'AmpLowPower'}; % argCell{ele} = {'AmpLowPower'};
ele = ele + 1; % ele = ele + 1;
nameStr{ele} = {'GroundLift'}; nameStr{ele} = {'GroundLift'};
argCell{ele} = {'GroundLift'}; argCell{ele} = {'groundLift'};
ele = ele + 1; tooltip{ele} = {'Use ground lift'};
nameStr{ele} = {'NoGroundLift'}; % ele = ele + 1;
argCell{ele} = {'NoGroundLift'}; % nameStr{ele} = {'NoGroundLift'};
% argCell{ele} = {'NoGroundLift'};
%% controlbuttons (push) %% controlbuttons (push)
nButtons = length(nameStr); nButtons = length(nameStr);
InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height)]; InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)];
InputFeed{1}.Position = [InputFeed{1}.Position(1) InputFeed{1}.Position(2)+ InputFeed{1}.Position(4)+ver_space InputFeed{1}.Size]; InputFeed{1}.Position = [InputFeed{1}.Position(1) InputFeed{1}.Position(2)+ InputFeed{1}.Position(4)+ver_space InputFeed{1}.Size];
% InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size]; % InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size];
InputFeed{1}.h = uipanel(... InputFeed{1}.h = uipanel(...
...@@ -276,8 +285,10 @@ InputFeed{1}.h = uipanel(... ...@@ -276,8 +285,10 @@ InputFeed{1}.h = uipanel(...
'BackgroundColor',gui_bg_color); 'BackgroundColor',gui_bg_color);
position = [0 0 button_width button_height]; position = [lower_space button_space button_width button_height];
for button_idx = 1:length(nameStr)
% checkboxes
for button_idx = 2:length(nameStr)
userdata = argCell{button_idx}; userdata = argCell{button_idx};
ControlButton{ch_idx}.hButton(button_idx) = uicontrol(... ControlButton{ch_idx}.hButton(button_idx) = uicontrol(...
'Units','characters',... 'Units','characters',...
...@@ -285,36 +296,62 @@ for button_idx = 1:length(nameStr) ...@@ -285,36 +296,62 @@ for button_idx = 1:length(nameStr)
'FontSize',10,... 'FontSize',10,...
'Position',[position],... 'Position',[position],...
'String',nameStr{button_idx},... 'String',nameStr{button_idx},...
'Style','checkbox',...
'Callback',@controlCheckboxCallback,...
'UserData',userdata,...
'Value',currentSettings.(argCell{button_idx}{1}),...
'Tag','', ...
'Tooltip',tooltip{button_idx}{1});
position = position + [0 button_height+button_space 0 0];
end
% init button
userdata = argCell{1};
ControlButton{ch_idx}.hButton(1) = uicontrol(...
'Units','characters',...
'Parent',InputFeed{1}.h,...
'FontSize',10,...
'Position',[position],...
'String',nameStr{1},...
'Style','pushbutton',... 'Style','pushbutton',...
'Callback',@controlPushButtonCallback,... 'Callback',@controlPushButtonCallback,...
'UserData',userdata,... 'UserData',userdata,...
'Value',0,... 'Value',0,...
'Tag',''); 'Tag','');
position = position + [0 button_height 0 0]; position = position + [0 button_height+button_space 0 0];
end
%% sampling rate %% sampling rate
nameStr = {}; nameStr = {};
argCell = {}; argCell = {};
ele = 1; ele = 1;
nameStr{ele} = {'96000'}; nameStr{ele} = {'44100'};
argCell{ele} = {96000}; argCell{ele} = {44100};
ele = ele + 1;
nameStr{ele} = {'48000'};
argCell{ele} = {48000};
ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'88200'}; nameStr{ele} = {'88200'};
argCell{ele} = {88200}; argCell{ele} = {88200};
ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'48000'}; nameStr{ele} = {'96000'};
argCell{ele} = {48000}; argCell{ele} = {96000};
ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'44100'};
argCell{ele} = {44100};
samplingValue = 0;
for index = 1:length(nameStr)
if argCell{index}{1} == currentSettings.samplingRate
samplingValue = index;
end
end
nameStr = {'44100','48000','88200','96000'};
%% controlbuttons (push) %% controlbuttons (push)
nButtons = length(nameStr); nButtons = 1;
InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height)]; InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)];
InputFeed{1}.Position = [InputFeed{1}.Position(1) InputFeed{1}.Position(2)+ InputFeed{1}.Position(4)+ver_space InputFeed{1}.Size]; InputFeed{1}.Position = [InputFeed{1}.Position(1) InputFeed{1}.Position(2)+ InputFeed{1}.Position(4)+ver_space InputFeed{1}.Size];
% InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size]; % InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size];
InputFeed{1}.h = uipanel(... InputFeed{1}.h = uipanel(...
...@@ -324,32 +361,86 @@ InputFeed{1}.h = uipanel(... ...@@ -324,32 +361,86 @@ InputFeed{1}.h = uipanel(...
'Title','SamplingRate',... 'Title','SamplingRate',...
'Tag','Mode',... 'Tag','Mode',...
'Clipping','on',... 'Clipping','on',...
'Position',InputFeed{ch_idx}.Position,... 'Position',InputFeed{1}.Position,...
'BackgroundColor',gui_bg_color); 'BackgroundColor',gui_bg_color);
position = [lower_space button_space button_width button_height];
position = [0 0 button_width button_height]; ControlButton{1}.hButton(1) = uicontrol(...
for button_idx = 1:length(nameStr)
userdata = argCell{button_idx};
ControlButton{ch_idx}.hButton(button_idx) = uicontrol(...
'Units','characters',... 'Units','characters',...
'Parent',InputFeed{1}.h,... 'Parent',InputFeed{1}.h,...
'FontSize',10,... 'FontSize',10,...
'Position',position,... 'Position',position,...
'String',nameStr{button_idx},... 'String',nameStr,...
'Style','pushbutton',... 'Style','popupmenu',...
'Callback',@samplingRateButtonCallback,... 'Callback',@samplingRateButtonCallback,...
'UserData',[],...
'Value',samplingValue,...
'Tag','');
position = position + [0 button_height+button_space 0 0];
%% presets
nButtons = 2;
% to get it up top to align with InputRange box, get its position and size
inputHeight = InputRange{1}.Position(2) + InputRange{1}.Size(2);
InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)];
InputFeed{1}.Position = [InputFeed{1}.Position(1) inputHeight - InputFeed{1}.Size(2) InputFeed{1}.Size];
% InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size];
InputFeed{1}.h = uipanel(...
'Parent',hFigure,...
'Units','characters',...
'FontSize',10,...
'Title','Settings Presets',...
'Tag','Mode',...
'Clipping','on',...
'Position',InputFeed{1}.Position,...
'BackgroundColor',gui_bg_color);
position = [lower_space button_space button_width button_height];
PresetButton{1}.hButton(1) = uicontrol(...
'Units','characters',...
'Parent',InputFeed{1}.h,...
'FontSize',10,...
'Position',[position],...
'String','Save',...
'Style','pushbutton',...
'Callback',@presetSaveCallback,...
'UserData',userdata,... 'UserData',userdata,...
'Value',0,...
'Tag',''); 'Tag','');
position = position + [0 button_height 0 0]; position = position + [0 button_height+button_space 0 0];
names = presetNames;
if ~presetChanged
popupValue = currentPresetNumber;
else
currentSettings = {'currentSettings'};
names = [presetNames currentSettings];
popupValue = length(names);
end end
PresetMenu{ch_idx}.hButton(1) = uicontrol(...
'Units','characters',...
'Parent',InputFeed{1}.h,...
'FontSize',10,...
'Position',position,...
'String',names,...
'Style','popupmenu',...
'Callback',@presetMenuCallback,...
'UserData',[],...
'Value',popupValue,...
'Tag','');
%% callback functions %% callback functions
function modePushButtonCallback(h,event) function modePushButtonCallback(h,event)
userdata = getfield(get(h),'UserData'); userdata = getfield(get(event.NewValue),'UserData');
argCell = userdata; argCell = userdata;
if ~isempty(argCell) if ~isempty(argCell)
ita_aurelio_control(argCell{:}); ita_aurelio_control(argCell{:});
...@@ -378,11 +469,37 @@ end ...@@ -378,11 +469,37 @@ end
end end
end end
function controlCheckboxCallback(h,event)
argCell = getfield(get(h),'UserData');
if ~isempty(argCell)
if strfind(argCell{1},'davolume')
a = ita_modulita_control('getSettings');
davolume = a.davolume;
if strfind(argCell{1},'--')
davolume = davolume - 1;
else
davolume = davolume + 1;
end
ita_aurelio_control('davolume',davolume);
% set(event.NewValue,'UserData',argCell);
else
argCell{end+1} = get(h,'Value');
ita_aurelio_control(argCell{:});
ita_aureliocontrol_gui('init');
end
end
end
function samplingRateButtonCallback(h,event) function samplingRateButtonCallback(h,event)
argCell = getfield(get(h),'UserData'); value = get(h,'Value');
strings = get(h,'String');
argCell{1} = str2num(strings{value});
if ~isempty(argCell) if ~isempty(argCell)
ita_aurelio_control('samplingRate',argCell{1}); ita_aurelio_control('samplingRate',argCell{1});
ita_aureliocontrol_gui('init');
end end
end end
...@@ -391,6 +508,7 @@ end ...@@ -391,6 +508,7 @@ end
userdata = getfield(get(event.NewValue),'UserData'); userdata = getfield(get(event.NewValue),'UserData');
inputselect = getfield(get(event.NewValue),'String'); inputselect = getfield(get(event.NewValue),'String');
ita_aurelio_control('channel',userdata.ch,'input',inputselect); ita_aurelio_control('channel',userdata.ch,'input',inputselect);
ita_aureliocontrol_gui('init');
end end
...@@ -398,6 +516,7 @@ end ...@@ -398,6 +516,7 @@ end
userdata = getfield(get(event.NewValue),'UserData'); userdata = getfield(get(event.NewValue),'UserData');
inputfeed = getfield(get(event.NewValue),'String'); inputfeed = getfield(get(event.NewValue),'String');
ita_aurelio_control('channel',userdata.ch,'feed',inputfeed); ita_aurelio_control('channel',userdata.ch,'feed',inputfeed);
ita_aureliocontrol_gui('init');
end end
...@@ -406,6 +525,56 @@ end ...@@ -406,6 +525,56 @@ end
value = getfield(get(event.NewValue),'String'); value = getfield(get(event.NewValue),'String');
inputrange = str2num(value); %#ok<ST2NM> inputrange = str2num(value); %#ok<ST2NM>
ita_aurelio_control('channel',userdata.ch,'inputrange',inputrange); ita_aurelio_control('channel',userdata.ch,'inputrange',inputrange);
ita_aureliocontrol_gui('init');
end
function presetMenuCallback(h,event)
value = get(h,'Value');
strings = get(h,'String');
if value <= length(strings)
ita_aurelio_control('setPreset',1,'presetName',strings{value});
ita_aureliocontrol_gui('init');
end end
end end
function presetSaveCallback(h,event)
isValidName = 0;
abort = 0;
inputString = 'Please give a preset name';
while ~isValidName
newTitle = inputdlg(inputString,'New Preset');
if ~isempty(newTitle)
if ~isempty(newTitle{1})
isValidName = 1;
% check if the name is already in use
for index = 1:length(presetNames)
if strcmp(newTitle{1},presetNames{index})
isValidName = 0;
inputString = 'Name already in use:';
end
end
else
% ok but no name
isValidName = 0;
inputString = 'Name was empty. Please give a name:';
end
else
% abort case
abort = 1;
isValidName = 1;
end
end
if ~abort
ita_aurelio_control('savePreset',1,'presetName',newTitle{1});
ita_aureliocontrol_gui('init');
end
end
end
\ No newline at end of file
function ita_aureliocontrol_gui_new(varargin) function ita_aureliocontrol_gui(varargin)
% ita_aureliocontrol_gui_new - gui for aurelio remote control % ITA_AURELIOCONTROL_GUI - gui for aurelio remote control
% <ITA-Toolbox> % <ITA-Toolbox>
% This file is part of the application RoboAurelioModulITAControl for the ITA-Toolbox. All rights reserved. % This file is part of the application RoboAurelioModulITAControl for the ITA-Toolbox. All rights reserved.
% You can find the license for this m-file in the application folder. % You can find the license for this m-file in the application folder.
% </ITA-Toolbox> % </ITA-Toolbox>
[currentSettings, presetNames, currentPresetNumber,presetChanged] = ita_aurelio_control_new('getSettings'); oldSettings = ita_aurelio_control('getSettings');
persistent hFigure persistent hFigure
%% nice gui settings %% nice gui settings
...@@ -14,7 +14,7 @@ gui_bg_color = [0.8 0.8 0.8]; ...@@ -14,7 +14,7 @@ gui_bg_color = [0.8 0.8 0.8];
if nargin == 0 if nargin == 0
width = 440; width = 440;
height = 640; height = 540;
mpos = get(0,'Monitor'); %try to position in the middle of the screen mpos = get(0,'Monitor'); %try to position in the middle of the screen
w_position = (mpos(1,length(mpos)-1)/2)-(width/2); w_position = (mpos(1,length(mpos)-1)/2)-(width/2);
...@@ -59,8 +59,6 @@ ver_space = 0.5; ...@@ -59,8 +59,6 @@ ver_space = 0.5;
button_height = 1.5; button_height = 1.5;
button_width = 20; button_width = 20;
button_space = 0.125;
lower_space = 0.25;
for ch_idx = 1:2 for ch_idx = 1:2
%% FEED %% FEED
...@@ -68,8 +66,7 @@ for ch_idx = 1:2 ...@@ -68,8 +66,7 @@ for ch_idx = 1:2
nameStr = {'NONE','Pol','Pha','P+P','icp','all'}; nameStr = {'NONE','Pol','Pha','P+P','icp','all'};
nButtons = length(nameStr); nButtons = length(nameStr);
InputFeed{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height)];
InputFeed{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)];
InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size]; InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size];
InputFeed{ch_idx}.h = uibuttongroup(... InputFeed{ch_idx}.h = uibuttongroup(...
'Parent',hFigure,... 'Parent',hFigure,...
...@@ -84,8 +81,7 @@ for ch_idx = 1:2 ...@@ -84,8 +81,7 @@ for ch_idx = 1:2
'SelectionChangeFcn',@InputFeedCallback,... 'SelectionChangeFcn',@InputFeedCallback,...
'OldSelectedObject',[]); 'OldSelectedObject',[]);
position = [0 0 button_width button_height];
position = [lower_space button_space button_width button_height];
for button_idx = 1:nButtons for button_idx = 1:nButtons
InputFeed{ch_idx}.hButton(button_idx) = uicontrol(... InputFeed{ch_idx}.hButton(button_idx) = uicontrol(...
'Parent',InputFeed{ch_idx}.h,... 'Parent',InputFeed{ch_idx}.h,...
...@@ -96,15 +92,15 @@ for ch_idx = 1:2 ...@@ -96,15 +92,15 @@ for ch_idx = 1:2
'String',nameStr{button_idx},... 'String',nameStr{button_idx},...
'Style','togglebutton',... 'Style','togglebutton',...
'UserData',userdata,... 'UserData',userdata,...
'Value',strcmpi(nameStr{button_idx},currentSettings.ch(ch_idx).inputfeed),... 'Value',strcmpi(nameStr{button_idx},oldSettings.ch(ch_idx).inputfeed),...
'Tag','togglebuttonNorm'); 'Tag','togglebuttonNorm');
position = position + [0 button_height+button_space 0 0]; position = position + [0 button_height 0 0];
end end
%% INPUT SELECT %% INPUT SELECT
nameStr = {'Lemo','XLR','gnd','BNC'}; nameStr = {'Lemo','XLR','gnd','BNC'};
nButtons = length(nameStr); nButtons = length(nameStr);
InputSelect{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)]; InputSelect{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height)];
InputSelect{ch_idx}.Position = [InputFeed{ch_idx}.Position(1) InputFeed{ch_idx}.Position(2)+ InputFeed{ch_idx}.Position(4)+ver_space InputSelect{ch_idx}.Size]; InputSelect{ch_idx}.Position = [InputFeed{ch_idx}.Position(1) InputFeed{ch_idx}.Position(2)+ InputFeed{ch_idx}.Position(4)+ver_space InputSelect{ch_idx}.Size];
InputSelect{ch_idx}.h = uibuttongroup(... InputSelect{ch_idx}.h = uibuttongroup(...
'Parent',hFigure,... 'Parent',hFigure,...
...@@ -119,7 +115,7 @@ for ch_idx = 1:2 ...@@ -119,7 +115,7 @@ for ch_idx = 1:2
'SelectionChangeFcn',@InputSelectCallback,... 'SelectionChangeFcn',@InputSelectCallback,...
'OldSelectedObject',[]); 'OldSelectedObject',[]);
position = [lower_space button_space button_width button_height]; position = [0 0 button_width button_height];
for button_idx = 1:nButtons for button_idx = 1:nButtons
InputSelect{ch_idx}.hButton(button_idx) = uicontrol(... InputSelect{ch_idx}.hButton(button_idx) = uicontrol(...
'Parent',InputSelect{ch_idx}.h,... 'Parent',InputSelect{ch_idx}.h,...
...@@ -129,9 +125,9 @@ for ch_idx = 1:2 ...@@ -129,9 +125,9 @@ for ch_idx = 1:2
'String',nameStr{button_idx},... 'String',nameStr{button_idx},...
'UserData',userdata,... 'UserData',userdata,...
'Style','togglebutton',... 'Style','togglebutton',...
'Value',strcmpi(nameStr{button_idx},currentSettings.ch(ch_idx).inputselect),... 'Value',strcmpi(nameStr{button_idx},oldSettings.ch(ch_idx).inputselect),...
'Tag','togglebuttonNorm'); 'Tag','togglebuttonNorm');
position = position + [0 button_height+button_space 0 0]; position = position + [0 button_height 0 0];
end end
%% INPUT RANGE %% INPUT RANGE
...@@ -139,7 +135,7 @@ for ch_idx = 1:2 ...@@ -139,7 +135,7 @@ for ch_idx = 1:2
nameStr = cellstr(num2str(inputRange_vec')); nameStr = cellstr(num2str(inputRange_vec'));
nButtons = length(nameStr); nButtons = length(nameStr);
InputRange{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)]; InputRange{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height)];
InputRange{ch_idx}.Position = [InputSelect{ch_idx}.Position(1) InputSelect{ch_idx}.Position(2)+ InputSelect{ch_idx}.Position(4)+ver_space InputRange{ch_idx}.Size]; InputRange{ch_idx}.Position = [InputSelect{ch_idx}.Position(1) InputSelect{ch_idx}.Position(2)+ InputSelect{ch_idx}.Position(4)+ver_space InputRange{ch_idx}.Size];
InputRange{ch_idx}.h = uibuttongroup(... InputRange{ch_idx}.h = uibuttongroup(...
'Parent',hFigure,... 'Parent',hFigure,...
...@@ -154,7 +150,7 @@ for ch_idx = 1:2 ...@@ -154,7 +150,7 @@ for ch_idx = 1:2
'SelectionChangeFcn',@InputRangeCallback,... 'SelectionChangeFcn',@InputRangeCallback,...
'OldSelectedObject',[]); 'OldSelectedObject',[]);
position = [lower_space button_space button_width button_height]; position = [0 0 button_width button_height];
for button_idx = 1:nButtons for button_idx = 1:nButtons
InputRange{ch_idx}.hButton(button_idx) = uicontrol(... InputRange{ch_idx}.hButton(button_idx) = uicontrol(...
'Parent',InputRange{ch_idx}.h,... 'Parent',InputRange{ch_idx}.h,...
...@@ -165,9 +161,9 @@ for ch_idx = 1:2 ...@@ -165,9 +161,9 @@ for ch_idx = 1:2
'BackgroundColor',[0.1 0.9 0.1],... 'BackgroundColor',[0.1 0.9 0.1],...
'UserData',userdata,... 'UserData',userdata,...
'Style','togglebutton',... 'Style','togglebutton',...
'Value',currentSettings.ch(ch_idx).inputrange == inputRange_vec(button_idx),... 'Value',oldSettings.ch(ch_idx).inputrange == inputRange_vec(button_idx),...
'Tag','togglebuttonNorm'); 'Tag','togglebuttonNorm');
position = position + [0 button_height+button_space 0 0]; position = position + [0 button_height 0 0];
end end
hor_start = hor_start + button_width + hor_space; hor_start = hor_start + button_width + hor_space;
...@@ -196,7 +192,7 @@ argCell{ele} = {'mode','norm'}; ...@@ -196,7 +192,7 @@ argCell{ele} = {'mode','norm'};
%% generate modebuttons %% generate modebuttons
InputFeed = InputFeed(1); InputFeed = InputFeed(1);
nButtons = length(nameStr); nButtons = length(nameStr);
InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)]; InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height)];
InputFeed{1}.Position = [hor_start+1 ver_start InputFeed{1}.Size]; InputFeed{1}.Position = [hor_start+1 ver_start InputFeed{1}.Size];
InputFeed{1}.h = uibuttongroup(... InputFeed{1}.h = uibuttongroup(...
'Parent',hFigure,... 'Parent',hFigure,...
...@@ -208,10 +204,9 @@ InputFeed{1}.h = uibuttongroup(... ...@@ -208,10 +204,9 @@ InputFeed{1}.h = uibuttongroup(...
'Position',InputFeed{1}.Position,... 'Position',InputFeed{1}.Position,...
'BackgroundColor',gui_bg_color,... 'BackgroundColor',gui_bg_color,...
'SelectedObject',[],... 'SelectedObject',[],...
'OldSelectedObject',[], ... 'OldSelectedObject',[]);
'SelectionChangeFcn',@modePushButtonCallback);
ch_idx = 1; ch_idx = 1;
position = [lower_space button_space button_width button_height]; position = [0 0 button_width button_height];
for button_idx = 1:nButtons for button_idx = 1:nButtons
userdata = argCell{button_idx}; userdata = argCell{button_idx};
ControlButton{ch_idx}.hButton(button_idx) = uicontrol(... ControlButton{ch_idx}.hButton(button_idx) = uicontrol(...
...@@ -220,11 +215,12 @@ for button_idx = 1:nButtons ...@@ -220,11 +215,12 @@ for button_idx = 1:nButtons
'FontSize',10,... 'FontSize',10,...
'Position',position,... 'Position',position,...
'String',nameStr{button_idx},... 'String',nameStr{button_idx},...
'Style','togglebutton',... 'Style','pushbutton',...
'Callback',@modePushButtonCallback,...
'UserData',userdata,... 'UserData',userdata,...
'Value',strcmpi(currentSettings.mode,argCell{button_idx}{2}),... 'Value',0,...
'Tag',''); 'Tag','');
position = position + [0 button_height+button_space 0 0]; position = position + [0 button_height 0 0];
end end
...@@ -234,44 +230,39 @@ argCell = {}; ...@@ -234,44 +230,39 @@ argCell = {};
ele = 1; ele = 1;
nameStr{ele} = {'Init'}; nameStr{ele} = {'Init'};
argCell{ele} = {'init'}; argCell{ele} = {'init'};
tooltip{ele} = {'Reinitialize the Aurelio'};
% ele = ele + 1; % ele = ele + 1;
% nameStr{ele} = {['Reset']}; % nameStr{ele} = {['Reset']};
% argCell{ele} = {'Reset'}; % argCell{ele} = {'Reset'};
ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'Use Amplifier'}; nameStr{ele} = {'Amplifier'};
argCell{ele} = {'Amplifier'}; argCell{ele} = {'Amplifier'};
tooltip{ele} = {'Turn the amplifier on'};
ele = ele + 1; ele = ele + 1;
% nameStr{ele} = {'NoAmplifier'}; nameStr{ele} = {'NoAmplifier'};
% argCell{ele} = {'NoAmplifier'}; argCell{ele} = {'NoAmplifier'};
% ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'Amp +20dB'}; nameStr{ele} = {'Amp26dBu'};
argCell{ele} = {'Amp26dBu'}; argCell{ele} = {'Amp26dBu'};
tooltip{ele} = {'Amp + 20 dB'};
ele = ele + 1; ele = ele + 1;
% nameStr{ele} = {'Amp06dBu'}; nameStr{ele} = {'Amp06dBu'};
% argCell{ele} = {'Amp06dBu'}; argCell{ele} = {'Amp06dBu'};
% ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'AmpHighPower'}; nameStr{ele} = {'AmpHighPower'};
argCell{ele} = {'AmpHighPower'}; argCell{ele} = {'AmpHighPower'};
tooltip{ele} = {'Activate High power Amp'};
ele = ele + 1; ele = ele + 1;
% nameStr{ele} = {'AmpLowPower'}; nameStr{ele} = {'AmpLowPower'};
% argCell{ele} = {'AmpLowPower'}; argCell{ele} = {'AmpLowPower'};
% ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'GroundLift'}; nameStr{ele} = {'GroundLift'};
argCell{ele} = {'groundLift'}; argCell{ele} = {'GroundLift'};
tooltip{ele} = {'Use ground lift'}; ele = ele + 1;
% ele = ele + 1; nameStr{ele} = {'NoGroundLift'};
% nameStr{ele} = {'NoGroundLift'}; argCell{ele} = {'NoGroundLift'};
% argCell{ele} = {'NoGroundLift'};
%% controlbuttons (push) %% controlbuttons (push)
nButtons = length(nameStr); nButtons = length(nameStr);
InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)]; InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height)];
InputFeed{1}.Position = [InputFeed{1}.Position(1) InputFeed{1}.Position(2)+ InputFeed{1}.Position(4)+ver_space InputFeed{1}.Size]; InputFeed{1}.Position = [InputFeed{1}.Position(1) InputFeed{1}.Position(2)+ InputFeed{1}.Position(4)+ver_space InputFeed{1}.Size];
% InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size]; % InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size];
InputFeed{1}.h = uipanel(... InputFeed{1}.h = uipanel(...
...@@ -285,10 +276,8 @@ InputFeed{1}.h = uipanel(... ...@@ -285,10 +276,8 @@ InputFeed{1}.h = uipanel(...
'BackgroundColor',gui_bg_color); 'BackgroundColor',gui_bg_color);
position = [lower_space button_space button_width button_height]; position = [0 0 button_width button_height];
for button_idx = 1:length(nameStr)
% checkboxes
for button_idx = 2:length(nameStr)
userdata = argCell{button_idx}; userdata = argCell{button_idx};
ControlButton{ch_idx}.hButton(button_idx) = uicontrol(... ControlButton{ch_idx}.hButton(button_idx) = uicontrol(...
'Units','characters',... 'Units','characters',...
...@@ -296,62 +285,36 @@ for button_idx = 2:length(nameStr) ...@@ -296,62 +285,36 @@ for button_idx = 2:length(nameStr)
'FontSize',10,... 'FontSize',10,...
'Position',[position],... 'Position',[position],...
'String',nameStr{button_idx},... 'String',nameStr{button_idx},...
'Style','checkbox',...
'Callback',@controlCheckboxCallback,...
'UserData',userdata,...
'Value',currentSettings.(argCell{button_idx}{1}),...
'Tag','', ...
'Tooltip',tooltip{button_idx}{1});
position = position + [0 button_height+button_space 0 0];
end
% init button
userdata = argCell{1};
ControlButton{ch_idx}.hButton(1) = uicontrol(...
'Units','characters',...
'Parent',InputFeed{1}.h,...
'FontSize',10,...
'Position',[position],...
'String',nameStr{1},...
'Style','pushbutton',... 'Style','pushbutton',...
'Callback',@controlPushButtonCallback,... 'Callback',@controlPushButtonCallback,...
'UserData',userdata,... 'UserData',userdata,...
'Value',0,... 'Value',0,...
'Tag',''); 'Tag','');
position = position + [0 button_height+button_space 0 0]; position = position + [0 button_height 0 0];
end
%% sampling rate %% sampling rate
nameStr = {}; nameStr = {};
argCell = {}; argCell = {};
ele = 1; ele = 1;
nameStr{ele} = {'44100'}; nameStr{ele} = {'96000'};
argCell{ele} = {44100}; argCell{ele} = {96000};
ele = ele + 1;
nameStr{ele} = {'48000'};
argCell{ele} = {48000};
ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'88200'}; nameStr{ele} = {'88200'};
argCell{ele} = {88200}; argCell{ele} = {88200};
ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'96000'}; nameStr{ele} = {'48000'};
argCell{ele} = {96000}; argCell{ele} = {48000};
ele = ele + 1; ele = ele + 1;
nameStr{ele} = {'44100'};
argCell{ele} = {44100};
samplingValue = 0;
for index = 1:length(nameStr)
if argCell{index}{1} == currentSettings.samplingRate
samplingValue = index;
end
end
nameStr = {'44100','48000','88200','96000'};
%% controlbuttons (push) %% controlbuttons (push)
nButtons = 1; nButtons = length(nameStr);
InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)]; InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height)];
InputFeed{1}.Position = [InputFeed{1}.Position(1) InputFeed{1}.Position(2)+ InputFeed{1}.Position(4)+ver_space InputFeed{1}.Size]; InputFeed{1}.Position = [InputFeed{1}.Position(1) InputFeed{1}.Position(2)+ InputFeed{1}.Position(4)+ver_space InputFeed{1}.Size];
% InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size]; % InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size];
InputFeed{1}.h = uipanel(... InputFeed{1}.h = uipanel(...
...@@ -361,90 +324,36 @@ InputFeed{1}.h = uipanel(... ...@@ -361,90 +324,36 @@ InputFeed{1}.h = uipanel(...
'Title','SamplingRate',... 'Title','SamplingRate',...
'Tag','Mode',... 'Tag','Mode',...
'Clipping','on',... 'Clipping','on',...
'Position',InputFeed{1}.Position,... 'Position',InputFeed{ch_idx}.Position,...
'BackgroundColor',gui_bg_color); 'BackgroundColor',gui_bg_color);
position = [lower_space button_space button_width button_height];
ControlButton{1}.hButton(1) = uicontrol(...
'Units','characters',...
'Parent',InputFeed{1}.h,...
'FontSize',10,...
'Position',position,...
'String',nameStr,...
'Style','popupmenu',...
'Callback',@samplingRateButtonCallback,...
'UserData',[],...
'Value',samplingValue,...
'Tag','');
position = position + [0 button_height+button_space 0 0];
%% presets
nButtons = 2;
% to get it up top to align with InputRange box, get its position and size
inputHeight = InputRange{1}.Position(2) + InputRange{1}.Size(2);
InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height+button_space)];
InputFeed{1}.Position = [InputFeed{1}.Position(1) inputHeight - InputFeed{1}.Size(2) InputFeed{1}.Size];
% InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size];
InputFeed{1}.h = uipanel(...
'Parent',hFigure,...
'Units','characters',...
'FontSize',10,...
'Title','Settings Presets',...
'Tag','Mode',...
'Clipping','on',...
'Position',InputFeed{1}.Position,...
'BackgroundColor',gui_bg_color);
position = [lower_space button_space button_width button_height]; position = [0 0 button_width button_height];
PresetButton{1}.hButton(1) = uicontrol(... for button_idx = 1:length(nameStr)
userdata = argCell{button_idx};
ControlButton{ch_idx}.hButton(button_idx) = uicontrol(...
'Units','characters',... 'Units','characters',...
'Parent',InputFeed{1}.h,... 'Parent',InputFeed{1}.h,...
'FontSize',10,... 'FontSize',10,...
'Position',[position],... 'Position',position,...
'String','Save',... 'String',nameStr{button_idx},...
'Style','pushbutton',... 'Style','pushbutton',...
'Callback',@presetSaveCallback,... 'Callback',@samplingRateButtonCallback,...
'UserData',userdata,... 'UserData',userdata,...
'Value',0,...
'Tag',''); 'Tag','');
position = position + [0 button_height+button_space 0 0]; position = position + [0 button_height 0 0];
names = presetNames;
if ~presetChanged
popupValue = currentPresetNumber;
else
currentSettings = {'currentSettings'};
names = [presetNames currentSettings];
popupValue = length(names);
end end
PresetMenu{ch_idx}.hButton(1) = uicontrol(...
'Units','characters',...
'Parent',InputFeed{1}.h,...
'FontSize',10,...
'Position',position,...
'String',names,...
'Style','popupmenu',...
'Callback',@presetMenuCallback,...
'UserData',[],...
'Value',popupValue,...
'Tag','');
%% callback functions %% callback functions
function modePushButtonCallback(h,event) function modePushButtonCallback(h,event)
userdata = getfield(get(event.NewValue),'UserData'); userdata = getfield(get(h),'UserData');
argCell = userdata; argCell = userdata;
if ~isempty(argCell) if ~isempty(argCell)
ita_aurelio_control_new(argCell{:}); ita_aurelio_control(argCell{:});
ita_aureliocontrol_gui_new('init'); ita_aureliocontrol_gui('init');
end end
end end
...@@ -460,46 +369,20 @@ PresetMenu{ch_idx}.hButton(1) = uicontrol(... ...@@ -460,46 +369,20 @@ PresetMenu{ch_idx}.hButton(1) = uicontrol(...
else else
davolume = davolume + 1; davolume = davolume + 1;
end end
ita_aurelio_control_new('davolume',davolume); ita_aurelio_control('davolume',davolume);
% set(event.NewValue,'UserData',argCell);
else
ita_aurelio_control_new(argCell{:});
ita_aureliocontrol_gui_new('init');
end
end
end
function controlCheckboxCallback(h,event)
argCell = getfield(get(h),'UserData');
if ~isempty(argCell)
if strfind(argCell{1},'davolume')
a = ita_modulita_control('getSettings');
davolume = a.davolume;
if strfind(argCell{1},'--')
davolume = davolume - 1;
else
davolume = davolume + 1;
end
ita_aurelio_control_new('davolume',davolume);
% set(event.NewValue,'UserData',argCell); % set(event.NewValue,'UserData',argCell);
else else
argCell{end+1} = get(h,'Value'); ita_aurelio_control(argCell{:});
ita_aurelio_control_new(argCell{:}); ita_aureliocontrol_gui('init');
ita_aureliocontrol_gui_new('init');
end end
end end
end end
function samplingRateButtonCallback(h,event) function samplingRateButtonCallback(h,event)
value = get(h,'Value'); argCell = getfield(get(h),'UserData');
strings = get(h,'String');
argCell{1} = str2num(strings{value});
if ~isempty(argCell) if ~isempty(argCell)
ita_aurelio_control_new('samplingRate',argCell{1}); ita_aurelio_control('samplingRate',argCell{1});
ita_aureliocontrol_gui_new('init');
end end
end end
...@@ -507,16 +390,14 @@ PresetMenu{ch_idx}.hButton(1) = uicontrol(... ...@@ -507,16 +390,14 @@ PresetMenu{ch_idx}.hButton(1) = uicontrol(...
function InputSelectCallback(h,event) function InputSelectCallback(h,event)
userdata = getfield(get(event.NewValue),'UserData'); userdata = getfield(get(event.NewValue),'UserData');
inputselect = getfield(get(event.NewValue),'String'); inputselect = getfield(get(event.NewValue),'String');
ita_aurelio_control_new('channel',userdata.ch,'input',inputselect); ita_aurelio_control('channel',userdata.ch,'input',inputselect);
ita_aureliocontrol_gui_new('init');
end end
function InputFeedCallback(h,event) function InputFeedCallback(h,event)
userdata = getfield(get(event.NewValue),'UserData'); userdata = getfield(get(event.NewValue),'UserData');
inputfeed = getfield(get(event.NewValue),'String'); inputfeed = getfield(get(event.NewValue),'String');
ita_aurelio_control_new('channel',userdata.ch,'feed',inputfeed); ita_aurelio_control('channel',userdata.ch,'feed',inputfeed);
ita_aureliocontrol_gui_new('init');
end end
...@@ -524,57 +405,7 @@ PresetMenu{ch_idx}.hButton(1) = uicontrol(... ...@@ -524,57 +405,7 @@ PresetMenu{ch_idx}.hButton(1) = uicontrol(...
userdata = getfield(get(event.NewValue),'UserData'); userdata = getfield(get(event.NewValue),'UserData');
value = getfield(get(event.NewValue),'String'); value = getfield(get(event.NewValue),'String');
inputrange = str2num(value); %#ok<ST2NM> inputrange = str2num(value); %#ok<ST2NM>
ita_aurelio_control_new('channel',userdata.ch,'inputrange',inputrange); ita_aurelio_control('channel',userdata.ch,'inputrange',inputrange);
ita_aureliocontrol_gui_new('init');
end
function presetMenuCallback(h,event)
value = get(h,'Value');
strings = get(h,'String');
if value <= length(strings)
ita_aurelio_control_new('setPreset',1,'presetName',strings{value});
ita_aureliocontrol_gui_new('init');
end end
end end
\ No newline at end of file
function presetSaveCallback(h,event)
isValidName = 0;
abort = 0;
inputString = 'Please give a preset name';
while ~isValidName
newTitle = inputdlg(inputString,'New Preset');
if ~isempty(newTitle)
if ~isempty(newTitle{1})
isValidName = 1;
% check if the name is already in use
for index = 1:length(presetNames)
if strcmp(newTitle{1},presetNames{index})
isValidName = 0;
inputString = 'Name already in use:';
end
end
else
% ok but no name
isValidName = 0;
inputString = 'Name was empty. Please give a name:';
end
else
% abort case
abort = 1;
isValidName = 1;
end
end
if ~abort
ita_aurelio_control_new('savePreset',1,'presetName',newTitle{1});
ita_aureliocontrol_gui_new('init');
end
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment