%% Apply Specified Independent Augmentations
% Read in an audio signal and listen to it.

[audioIn,fs] = audioread("Counting-16-44p1-mono-15secs.wav");

%
% Create an audioDataAugmenter object that applies volume control, noise corruption, and time shifting in parallel branches.

augmenter = audioDataAugmenter( ...
    "AugmentationMode","independent", ...
    "AugmentationParameterSource","specify", ...
    "ApplyTimeStretch",false, ...
    "ApplyPitchShift",false, ...
    "VolumeGain",2, ...
    "SNR",0, ...
    "TimeShift",2)

%
% Call augment on the audio to create 3 augmentations.

data = augment(augmenter,audioIn,fs)

%
% You can check the parameter configuration of each augmentation using the AugmentatioInfo table variable.

augmentationToInspect = 3;
data.AugmentationInfo{augmentationToInspect}

%
% Listen to the audio you are inspecting. Plot the time-domain representations of the original and augmented signals.

augmentation = data.Audio{augmentationToInspect};
sound(augmentation,fs)

t = (0:(numel(audioIn)-1))/fs;
taug = (0:(numel(augmentation)-1))/fs;
plot(t,audioIn,taug,augmentation)
legend("Original Audio","Augmented Audio")
ylabel("Amplitude")
xlabel("Time (s)")

% Copyright 2019 The MathWorks, Inc.