function exampleID = getExampleID
% getExampleID Get ExampleID for the current Audio Toolbox example model.
%
%   This is an internal function. It may change in a future release.
%

%   Copyright 1995-2023 The MathWorks, Inc.

%   This function enables multiple versions of one demo to point to the
%   same doc page.
%
%   REQUIREMENTS:
%     1) The info block calling this function MUST be in the root of the
%        demo model.
%     2) The name of the demo must end with a combination of no more than 
%        two items from the following list:
%        _all, _frame, _fixpt, _win or _win32, _color, _intensity.

modelname = get_param(gcb, 'Parent');

% Remove _win32 or _fixpt (or _***) if present (before the ".")
exampleName = suffixstrip(modelname);

% Get example ID to be used by showExample function
exampleID = strcat('audio/', exampleName);


function exampleID = suffixstrip(modelName)
% Remove underscore and all characters after it
modelName = regexprep(modelName, '_.*$', '');

% map model names to example names
examplesMap = { ...
    'audioEqualizerAndroid', 'ParametricAudioEqualizerForAndroidDeviceExample'; ...
    'audioTHDNmeasurementexample', 'THDNMeasurementWithTonetrackingExample'; ...
    'audioanc', 'AcousticNoiseCancellationUsingLmExample'; ...
    'audiocochlear', 'CochlearImplantSpeechProcessorExample'; ...
    'audiodelaybasedeffects', 'DelayBasedAudioEffectExample'; ...
    'audiofreeverbreverberation', 'ReverberationUsingFreeverbExample'; ...
    'audiolpc', 'LPCAnalysisAndSynthesisOfSpeechExample'; ...
    'audiomatrixdecoding', 'SurroundSoundMatrixEncodingAndDecodingExample'; ...
    'audiomidi', 'UsingAMidiControlSurfaceToInteractWithASimulinkModelExample'; ...
    'audiomultibanddynamiccompression', 'MultibandDynamicRangeCompressionExample'; ...
    'audiopitchtime', 'PitchShiftingAndTimeDilationUsingAPhaseVocoderInSimulinkExample'; ...
    'audiopluck', 'SimulationOfAPluckedStringExample'; ...
    'audiopositioning', 'PositionalAudioExample'; ...
    'audiosourceseparation', 'AudioSourceSeparationExample'; ...
    'audiovorbisdecoder', 'VorbisDecoderExample'; ...
    'olamodel', 'DynamicRangeCompressionUsingOverlapaddReconstructionExample'};

[tf,idx] = ismember(modelName,examplesMap(:,1));
if any(tf)
    exampleID = examplesMap{idx,2};
else
    exampleID = modelName;
end
