Commit 7f92fd90 authored by Florian Pausch's avatar Florian Pausch

Merge branch 'master' of https://git.rwth-aachen.de/ita/toolbox

parents 2e44e5b5 1284d051
...@@ -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);
par_number = '02'; for index = 1:length(sArgs.channel)
par_value = round((- sArgs.inputrange + 56)/10); %round to nearest possible sArgs.inputrange = min( max(settings.ch(sArgs.channel(index)).inputrange,-34) , 56);
for idx = 1:numel(sArgs.channel) par_number = '02';
oldSettings.ch(sArgs.channel(idx)).inputrange = 56 - (par_value * 10); par_value = round((- sArgs.inputrange + 56)/10); %round to nearest possible
end % for idx = 1:numel(sArgs.channel)
if sArgs.securityMode % disp(idx)
par_value = par_value + 40; % 56 - (par_value * 10)
% settings.ch(sArgs.channel(idx)).inputrange = 56 - (par_value * 10);
% encd
if sArgs.securityMode
par_value = par_value + 40;
end
par_value = ita_angle2str(par_value,2);
send_sysex(par_number, par_value, ita_angle2str(sArgs.channel(index)-1,2)); %send to device
end end
par_value = ita_angle2str(par_value,2); % end
send_sysex(par_number, par_value, ch_number); %send to device
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'; par_value = dec2hex( bin2dec ( ['0' rS.Wait rS.Lem28 rS.Phan rS.Feed rS.ICP rS.Glift rS.AC] ));
Feed = '0'; send_sysex(rS.par_number, par_value, ita_angle2str(sArgs.channel(index)-1,2)); % send final sysex
ICP = '0'; end
Glift = num2str(sArgs.groundLift);
AC = num2str(sArgs.inputCouplingAC);
switch lower(sArgs.feed)
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
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)
...@@ -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;