itaMSPlaybackRecord.m 29.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629
classdef itaMSPlaybackRecord < itaMSRecord
    
    % <ITA-Toolbox>
    % This file is part of the application Measurement for the ITA-Toolbox. All rights reserved.
    % You can find the license for this m-file in the application folder.
    % </ITA-Toolbox>
    
    % This is a class for playing back and recording at the same time, but
    % without deconvolution
    %
    % See also: ita_measurement, itaMSRecord, itaMeasurementChain
    
    properties(Access = public, Hidden = true)
        mOutputamplification    = -40;
        mExcitation             = [];
        mOutputChannels         = [];
        mOutputMeasurementChain = itaMeasuringStation.loadCurrentOutputMC; %itaMeasurementChain('output');
    end
    
    properties(Dependent = true, Hidden = false, Transient = true)
        outputamplification             % Attenuation factor of the output signal in dBFS (Fullscale)
        excitation                      % itaAudio containing the excitation signal, for this class. 1 channel.
    end
    
    properties(Dependent = true, Hidden = false, Transient = true, AbortSet = true, SetObservable = true) %triggers @this.init !!!
        outputChannels          % Vector specifying the output channel IDs e.g. [1 5]
        outputMeasurementChain  % itaMeasurementChain('output') defining all output measurement chain elements
    end
    
    properties(Dependent = true, Hidden = true, Transient = true, AbortSet = true)
        outputamplification_lin % Linear factor from dBFS 'outputamplification' for multiplication
        final_excitation        % Excitation including compensation of relative output sensitivites/spectra - number of channels equal outputMC
        outputVoltage           % used to set outputamplification for a calibrated output chain
    end
    
    properties (Hidden = false, Transient = true, AbortSet = true, SetObservable = true)
        latencysamples  = 0;    % number of samples (positive integer) used to compensate the delay of the AD/DA conversion
    end
    
    properties (SetObservable = true, AbortSet = true)
        outputEqualization  = false;
    end
    
    methods
        
        %% CONSTRUCT / INIT / EDIT / COMMANDLINE
        
        function this = itaMSPlaybackRecord(varargin)
            % itaMSPlaybackRecord - Constructs an itaMSPlaybackRecord object.
            if nargin == 0
                
                % For the creation of itaMSPlaybackRecord objects from commandline strings
                % like the ones created with the commandline method of this
                % class, 2 or more input arguments have to be allowed. All
                % desired properties have to be given in pairs of two, the
                % first element being an identifying string which will be used
                % as field name for the property, and the value of the
                % specified property.
            elseif nargin >= 2
                if ~isnatural(nargin/2)
                    error('Even number of input arguments expected!');
                end
                
                % For all given pairs of two, use the first element as
                % field name, the second one as value. The validity of the
                % field names will NOT be checked.
                for idx = 1:2:nargin
                    this.(varargin{idx}) = varargin{idx+1};
                end
                
                % Only one input argument is required for the creation of an
                % itaMSPlaybackRecord class object from a struct, created by the saveobj
                % method, or as a copy of an already existing itaMSPlaybackRecord class
                % object. In the latter case, only the properties contained in
                % the list of saved properties will be copied.
            elseif isstruct(varargin{1}) || isa(varargin{1},'itaMSPlaybackRecord')
                % Check type of given argument and obtain the list of saved
                % properties accordingly.
                if isa(varargin{1},'itaMSPlaybackRecord')
                    %The save struct is obtained by using the saveobj
                    % method, as in the case in which a struct is given
                    % from the start (see if-case above).
                    varargin{1} = saveobj(varargin{1});
                    % have to delete the dateSaved field to make clear it
                    % might be from an inherited class
                    varargin{1} = rmfield(varargin{1},'dateSaved');
                end
                if isfield(varargin{1},'dateSaved')
                    varargin{1} = rmfield(varargin{1},'dateSaved');
                    fieldName = fieldnames(varargin{1});
                else %we have a class instance here, maybe a child
                    fieldName = fieldnames(rmfield(this.saveobj,'dateSaved'));
                end
                
                for ind = 1:numel(fieldName);
                    try
                        this.(fieldName{ind}) = varargin{1}.(fieldName{ind});
                    catch errmsg
                        disp(errmsg);
                    end
                end
            else
                error('itaMSPlaybackRecord::wrong input arguments given to the constructor');
            end
            
            % Define listeners to automatically call the init function of
            % this class in case of a change the the below specified
            % properties.
            
            % not needed here, only in classes inherited from this one
        end
        
        function this = edit(this)
            % edit - Start GUI.
            %
            % This function calls the itaMSPlaybackRecord GUI.
            
            this = ita_msplaybackrecord_gui(this);
        end
        
        %% CALIBRATION
        
        function this = calibrate(this)
            % this will guide you thru the calibration process
            this = calibrate_input(this);
            % outputMeasurementChain
            this = calibrate_output(this);
        end
        
        function MS = calibrationMS(this)
            % Generates a simple Measurement Setup for calibration purposes.
            saveStruct = saveobj(this);
            % delete all fields that itaMSTF cannot handle
            % this is important when calling from inherited classes
            fieldNames = fieldnames(saveStruct);
            classFields = [itaMSRecord.propertiesSaved itaMSPlaybackRecord.propertiesSaved itaMSTF.propertiesSaved 'dateSaved'];
            additionalFields = fieldNames(~cellfun(@(x) any(strcmpi(classFields,x)),fieldNames));
            if ~isempty(additionalFields)
                saveStruct = rmfield(saveStruct,additionalFields);
            end
            
            saveStruct.mExcitation = itaAudio(); % erase excitation so it will be rebuilt
            saveStruct.mNSamples = 2^15;
            saveStruct.mType = 'exp';
            saveStruct.stopMargin = min(0.3,2^14/this.samplingRate); % for high sampling frequencies
            saveStruct.mOutputamplification = -50;           % Low amplification, to be safe. Will be autoranged later.
            saveStruct.mFreqrange = [1 this.samplingRate/2]; % Full range for calibration.
            saveStruct.applyBandpass = 0;
            saveStruct.pause = 0;                           % no pause for calibration
            MS = itaMSTF(saveStruct);                     % Init new MSTF object.
        end
        
        function this = calibrate_output(this,input_chain_number)
            % Calibrates all output chains, using only the first
            % (hopefully calibrated) input chain. Input chain calibration
            
            if ~exist('input_chain_number','var')
                input_chain_number = find(this.inputMeasurementChain.hw_ch == this.inputChannels(1));
            end
            ita_verbose_info(['Calibrating using input channel ' num2str(this.inputMeasurementChain(input_chain_number).hardware_channel)],1);
            
            MS = this.calibrationMS;            % Get new simple Measurement Setup for calibration. See above.
            mco = this.outputMeasurementChain;    % Get all output measurement chains.
            outChannels = this.outputChannels;    % Get all output channels.
            
            % The calibration of the multiple output measurement chains /
            % outout channels will be executed one-by-one.
            for outIdx = 1:numel(outChannels)
                chIdx = find(mco.hw_ch == outChannels(outIdx)); % Return single index of entry in 'mco', equal to the out channel, which is to be calibrated.
                MS.outputMeasurementChain = mco(chIdx);         % Set Measurement Setup's single output chain to match the one, which is to be calibrated.
                MS.outputChannels = outChannels(outIdx);        % Set Measurement Setup's single output channel to match the one, which is to be calibrated.
                
                % Execute calibration for every single element in the
                % current output measurement chain.
                % 'ita_mstfoutput_calibration' determines if the object can
                % be calibrated at all.
                for ele_idx = 1:length(mco(chIdx).elements)
                    MS = ita_measurement_chain_output_calibration(MS,input_chain_number,ele_idx);
                end
                
                % if there was no latency info before, copy it from the
                % calibrationMS because latency was measured in the output
                % calibration routine
                if this.latencysamples == 0
                    this.latencysamples = MS.latencysamples;
                end
                % Put the current calibrated measurement chain back into
                % its appropriate position in the list of all output
                % measurment chains.
                mco(chIdx) = MS.outputMeasurementChain;
            end
            this.outputMeasurementChain = mco;          % Copy over the list of all calibrated output measurement chains into the real Measurement Setup.
        end
        
        %% RUN
        function checkready(this)
            %check if the instance is ready for measurement run and ask for
            %missing entries
            if isempty(this.inputChannels) || isempty(this.outputChannels) || isempty(this.excitation)
                this.edit;
            end
            
        end
        
        function [result, max_rec_lvl] = run_raw(this)
            % run_raw - Run measurement
            this.checkready;
            singleprecision = strcmpi(this.precision,'single'); % Bool for single precision for portaudio.
            
            result = ita_portaudio(this.final_excitation,'InputChannels',this.inputChannels, ...
                'OutputChannels', this.outputChannels,'repeats',1,...
                'latencysamples',this.latencysamples,'singleprecision',singleprecision,'reset', this.reset);
            
            if this.outputVoltage ~= 1 % only if output is calibrated
                result.comment = [result.comment ' @' num2str(round(this.outputVoltage*1000)/1000) 'Vrms'];
            end
            max_rec_lvl = max(abs(result.timeData),[],1);
            
        end
        
        function [result, max_rec_lvl] = run(this)
            % run - Run standard measurement.
            %
            % This function runs a measurement, and compensates for the
            % input measurement chain. If the output is calibrated, the
            % output voltage will be stored in the comment, but it will
            % not be compensated for.
            
            [result, max_rec_lvl] = run_raw_imc(this);
            if this.applyBandpass
                result = ita_mpb_filter(result,this.freqRange,'zerophase');
            end
        end
        
        function [result, max_rec_lvl] = run_backgroundNoise(this)
            % run_backgroundNoise - Run simple background noise
            % measurement.
            %
            % This function runs a measurement with -500dBFS
            % outputamplification to measure the background noise.
            
            original_outputamplification = this.outputamplification;
            this.outputamplification = -500;
            [result, max_rec_lvl] = run_raw_imc(this);
            this.outputamplification = original_outputamplification;
        end
        
        function [result, max_rec_lvl] = run_raw_imc_omc(this)
            % run_raw_imc_omc - Run raw and compensate both input and output.
            
            [result, max_rec_lvl] = run_raw_imc(this);
            result = result / this.outputamplification_lin;
            result = compensateOutputMeasurementChain(this,result);
        end
        
        function [result, max_rec_lvl] = run_latency(this)
            % run_latency - Run measurement and determine the latency
            % samples.
            %
            % This function runs a not input/output measurement chain
            % compensated measurement, does the deconvolution itself,
            % analyzes the resulting impulse response and sets the latency
            % samples in the measurement setup. It returns the not
            % compensated impulse response and max recording level.
            
            ita_verbose_info('Measuring latency samples...',1);
            
            MS = this.calibrationMS;
            MS.inputChannels = MS.inputChannels(1);
            ita_verbose_info(['Using channel ' num2str(MS.inputChannels) ' for latency measurement'],1);
            MS.outputamplification = this.outputamplification;
            
            MS.latencysamples = 0;
            
            [result, max_rec_lvl] = run_raw(MS);
            result = result * MS.compensation / MS.outputamplification_lin;
            result.signalType = 'energy';
            
            [maxamplitude, lsamples]  = max(abs(result.timeData),[],1);      % Get the measurement's max absolute amplitude and exact sample position of max amplitude for each channel.
            [maxamplitude, idx] = max(maxamplitude); %#ok<ASGLU>
            
            lsamples = lsamples(idx) - 1;                               % Get the max of all position samples of all channels ans substract 1, to prevent anti-causal impuls responses.
            
            if (~isempty(lsamples) && lt(lsamples, 0)) || isempty(lsamples) % If result would be acausal... suppress it!
                ita_verbose_info('Could not find a suitable impulse! Try a higher output amplification.',0);
                this.latencysamples = [];
            else
                this.latencysamples = lsamples;
            end
            
        end
        
        function [result,signal,noise] = run_snr(this,fraction)
            % run noise and signal and compare
            if nargin < 2
                fraction = 3;
            end
            ita_verbose_info('Recording noise level for SNR',1);
            noise   = this.run_backgroundNoise;
            N       = ita_spk2frequencybands(noise,'bandsperoctave',fraction,'freqRange',[min(this.freqRange(:)) max(this.freqRange(:))]);
            ita_verbose_info('Recording signal level for SNR',1);
            signal  = this.run_raw_imc;
            sig     = sqrt(abs(signal')^2 - abs(noise')^2);
            S       = ita_spk2frequencybands(sig,'bandsperoctave',fraction,'freqRange',[min(this.freqRange(:)) max(this.freqRange(:))]);
            result  = S/N;
            result.comment = ['Signal-to-Noise Ratio in 1/' num2str(fraction) ' octave bands'];
        end
        
        %% Aux
        function result = compensateOutputMeasurementChain(this,result)
            % Apply the output measurement chain and the output
            % amplification to the result. It only makes sense to apply the
            % final response of the output measurement chain if only one
            % channel has been used during the measurement (no MIMO
            % calibration possible, here).
            if ~isempty(this.outputMeasurementChain)
                if length(this.outputChannels) <= 1
                    outChannel = this.outputChannels;
                    if this.outputEqualization && isa(this.outputMeasurementChain.hw_ch(outChannel).final_response,'itaAudio')
                        omc = this.outputMeasurementChain.hw_ch(outChannel);
                        final_response = ita_extend_dat(omc.final_response, this.fftDegree, 'symmetric');
                        omcTypes = {omc.elements.type};
                        lsIdx = find(strcmpi(omcTypes,'loudspeaker'));
                        if ~isempty(lsIdx) && ~isempty(omc.elements(lsIdx).response) % Houston, we have a Loudspeaker
                            % better use smaller freqRange, if LS is included
                            % lower frequency of 1 would lead to very high amplification
                            final_response = ita_smooth_notches(final_response,'bandwidth',1,'squeezeFactor',0.3);
                            outputFilter = ita_invert_spk_regularization(final_response,this.finalFreqRange,'filter');
                        else % otherwise just electrical
                            outputFilter = ita_invert_spk_regularization(final_response,[1 this.samplingRate/2],'filter');
                        end
                        outputFilter.channelNames(:) = {''};
                        result = result*outputFilter;
                    else
                        final_response = this.outputMeasurementChain.hw_ch(outChannel).sensitivity;
                        result = result/final_response;
                    end
                else
                    ita_verbose_info('Too many output channels. Output chain compensation not possible',0);
                end
            end
        end
        
        %% PLOT
        function plot(this)
            % plot - Plot ideal FRF and IR of excitation * compensation.
            
            ita_plot_all(this.excitation);
        end
        
        %% GET / SET
        % outputamplification
        function set.outputamplification(this,value)
            if ischar(value)
                value = str2num(value(~isstrprop(value,'alpha'))); %#ok<ST2NM>
            end
            this.mOutputamplification = -abs(value);
        end
        
        function res = get.outputamplification(this)
            res = [num2str(round(this.mOutputamplification)),'dBFS'];
        end
        
        function res = get.outputamplification_lin(this)
            res = 10^(this.mOutputamplification/20);
        end
        
        function plus(this,value)
            % increase output amplification
            this.outputamplification = min(this.mOutputamplification +  value,0);
            disp(['Output amplification: ' this.outputamplification]);
        end
        
        function minus(this,value)
            % decrease output amplification
            plus(this,-value);
        end
        
        function set.outputVoltage(this,value)
            if numel(this.outputChannels) ~= 1
                ita_verbose_info('Multiple output channels, selecting the one with maximum gain',0);
                [dummy,idx] = max(double(this.outputMeasurementChain.hw_ch(this.outputChannels).sensitivity('loudspeaker')));
                omc = this.outputMeasurementChain.hw_ch(this.outputChannels(idx));
            else
                omc = this.outputMeasurementChain.hw_ch(this.outputChannels);
            end
            if ~omc.calibrated || omc.sensitivity.value == 1
                ita_verbose_info('The outputMeasurementChain is not calibrated, this makes no sense then',1);
                ita_verbose_info('Leaving outputamplification unchanged',0);
            else
                outSens = omc.sensitivity('loudspeaker');
                this.outputamplification = 20*log10(abs(double(value/(this.raw_excitation.rms*outSens))));
            end
        end
        
        function res = get.outputVoltage(this) % including outputamplification
            omc = this.outputMeasurementChain.hw_ch(this.outputChannels);
            for iCh = 1:numel(omc)
                if ~omc(iCh).calibrated || double(omc(iCh).sensitivity) == 1
                    ita_verbose_info('The outputMeasurementChain is not calibrated, this makes no sense then',1);
                    res = 1;
                    return;
                end
            end
            
            outSens = double(omc.sensitivity('loudspeaker'));
            res = this.raw_excitation.rms*this.outputamplification_lin.*outSens;
        end
        
        function set.excitation(this,value)
            set_excitation(this,value);
        end
        
        function set_excitation(this,value)  %trick to overload in derivatives
            if isempty(value)
                error('itaMSPlaybackRecord::I cannot play empty signals');
            elseif isa(value,'itaAudio')
                value.dataType          = this.precision;
                value.dataTypeOutput    = this.precision;
                this.samplingRate       = value.samplingRate;
                this.fftDegree          = value.fftDegree;
                this.mExcitation        = ita_normalize_dat(value);
            else
                error(['itaMSPlaybackRecord::what kind of playback signal is this (class is: ' class(value) ')']);
            end
        end
        
        function res = get.excitation(this)
            % get final excitation
            res = this.final_excitation;
        end
        
        function res = raw_excitation(this)  %trick to overload in derivatives
            % build the elementary/raw excitation signal
            res = this.mExcitation;
        end
        
        function set.final_excitation(this,value)
            this.mExcitation = value;
        end
        
        function res = get.final_excitation(this)
            res = get_final_excitation(this); %trick to overload in derivatives
        end
        
        function res = get_final_excitation(this)
            % get the corrected excitation (outputamplification)
            res = this.raw_excitation * this.outputamplification_lin ;
        end
        
        function set.outputChannels(this,value)
            if ~all(ismember(value,this.outputMeasurementChain.hw_ch))
                % pdi: this works as hell! ask joe for any comments
                this.mOutputChannels = value;
                newChannels = value(~ismember(value,this.outputMeasurementChain.hw_ch));
                % if the output chain is empty create a new one
                if numel(this.outputMeasurementChain) == 1 && this.outputMeasurementChain.hw_ch == 0
                    if this.useMeasurementChain
                        this.outputMeasurementChain = ita_measurement_chain_output(newChannels);
                    else % create an empty dummy chain
                        dummyChain = itaMeasurementChain(numel(newChannels));
                        for iCh = 1:numel(newChannels)
                            dummyChain(iCh).type = 'output';
                            dummyChain(iCh).hardware_channel = newChannels(iCh);
                        end
                        this.outputMeasurementChain = dummyChain;
                    end
                    % otherwise add new channels
                else
                    if this.useMeasurementChain
                        this.outputMeasurementChain = [this.outputMeasurementChain ita_measurement_chain_output(newChannels)];
                    else % create an empty dummy chain
                        dummyChain = itaMeasurementChain(numel(newChannels));
                        for iCh = 1:numel(newChannels)
                            dummyChain(iCh).type = 'output';
                            dummyChain(iCh).hardware_channel = newChannels(iCh);
                        end
                        this.outputMeasurementChain = [this.outputMeasurementChain dummyChain];
                    end
                end
                this.mOutputChannels = value;
            else
                this.mOutputChannels = value;
            end
            set_outputChannels(this,value);
        end
        
        function set_outputChannels(this,value)
            this.mOutputChannels = value;
        end
        
        function res = get.outputChannels(this)
            res = this.mOutputChannels;
        end
        
        function set.outputMeasurementChain(this,value)
            this.mOutputMeasurementChain = value;
        end
        
        function res = get.outputMeasurementChain(this)
            res = this.mOutputMeasurementChain;
        end
        
        %% commandline
        function str = commandline(this)
            % commandline - Generate comandline string.
            %
            % This function creates a commandline string for creating the
            % exact same measurement setup.
            % first get the values from parent class
            parentStr = commandline@itaMSRecord(this);
            str = ['itaMSPlaybackRecord' parentStr(12:end-2) ','];
            list = {'fftDegree','freqRange','outputamplification','latencysamples','outputEqualization','outputChannels'};
            for idx  = 1:numel(list)
                token = this.(list{idx});
                if isempty(token)
                    continue;
                end;
                
                if ischar(token)
                    token = ['''' token ''''];
                elseif isnumeric(token) || islogical(token)
                    token = num2str(token);
                    if numel(token) > 1
                        token = ['[' token ']'];
                    end
                else
                    error([upper(mfilename) '.commandline: What kind of field value is this?']);
                end;
                str = [str '''' list{idx} '''' ',' token ];
                
                if idx < numel(list)
                    str = [str ',']; %#ok<*AGROW>
                end
            end
            str = [str ');'];
        end
    end
    
    %% Hidden methods
    methods(Hidden = true)
        
        function display(this)
            % Begin Display Start Line
            classnameString = ['|' class(this) '|'];
            result = repmat('=',1,itaSuper.LINE_LENGTH);
            result(3:(2+length(classnameString))) = classnameString;
            disp(result);
            % End Display Start Line
            if ~isempty(this.excitation)
                commentStr = this.excitation.comment;
                if length(commentStr) > 10
                    commentStr = [commentStr(1:7) '...'];
                else
                    commentStr = [commentStr, repmat(' ',1,10-length(commentStr))];
                end
                trackLength = this.excitation.trackLength;
            else
                commentStr = 'empty';
                trackLength = 0;
            end
            
            % Start Display Values
            disp(['   excitation = ' commentStr ' samplingRate  = ' num2str(this.samplingRate) '        nSamples      = ' num2str(this.nSamples)])
            oa = repmat(' ',1,7);
            oa_temp = (this.outputamplification);
            oa(1:length(oa_temp)) = oa_temp;
            disp(['   length     = ' num2str(trackLength,5) ' s '  ' level         = ' oa '      freqRange     = [' num2str(this.freqRange(:)') ']  '])
            disp(['   averages   = ' num2str(this.averages) '          repeats       = ' num2str(this.repeats) '            latency       = ' num2str(this.latencysamples)])
            disp(['   output ch. = [' num2str(this.outputChannels) ']        input ch.     = [' num2str(this.inputChannels) ']'])
            % End Display Values
            
            global lastDiplayedVariableName
            lastDiplayedVariableName = inputname(1);
            
            if ita_preferences('dispVerboseFunctions')
                
                display_line4commands({'   MS      ', {'__.edit','.edit'},{'plot(__)','plot excitation'},{'builtin(''disp'',__)','Show Inside of Class'},' Level:',{'__ - 5','-5dB'},{'__ - 1','-1dB'},{'__ + 1','+1dB'},{'__ + 5','+5dB'}},lastDiplayedVariableName);
                display_line4commands({'   Measure ', {'__.run','.run'}, {'__.run_raw','.run_raw'}, {'__.run_latency','.run_latency'}, ...
                    {'__.run_backgroundNoise','.run_backgroundNoise'}, {'__.run_snr','.run_SNR'}},lastDiplayedVariableName);
            else
                display_line4commands({'                                                      ', ...
                    {'ita_preferences(''dispVerboseFunctions'',1); display(__)', 'What to do...?'}}, lastDiplayedVariableName);
            end
        end
        
        
        function this = force_calibration(this)
            %set all measurement chain components to status: 'calibrated'
            this.inputMeasurementChain  = this.inputMeasurementChain.force_calibration;
            this.outputMeasurementChain = this.outputMeasurementChain.force_calibration;
        end
        
        function sObj = saveobj(this)
            % saveobj - Saves the important properties of the current
            % measurement setup to a struct.
            
            sObj = saveobj@itaMSRecord(this);
            % Get list of properties to be saved for this measurement
            % class.
            propertylist = itaMSPlaybackRecord.propertiesSaved;
            
            % Write the content of every item in the list of the to be saved
            % properties into its own field in the save struct.
            for idx = 1:numel(propertylist)
                sObj.(propertylist{idx}) = this.(propertylist{idx});
            end
        end
        
    end
    
    methods(Static, Hidden = true)
        function this = loadobj(sObj)
            this = itaMSPlaybackRecord(sObj); % Just call constructor, he will take care
        end
        
        function result = propertiesSaved
            % propertiesSaved - Creates a list of all the properties to be
            % saved of the current measurement setup.
            %
            % This function gets the list of all
            % properties to be saved during the saving process.
            
            % Get list of saved properties for this class.
            result = {'mOutputamplification', 'mOutputChannels','mOutputMeasurementChain','mExcitation','latencysamples','outputEqualization'};
        end
    end
    
end