function [timeSeries,spectrograms,labels] = generateSpectrogramData(numObsPerClass,classes)
% Generate noisy time series data and spectrograms of the data.

% Set properties of the time sampling:
% - fs: sample rate fs
% - tMax: upper time limit
fs = 100;
tMax = 5;

% Generate time points.
t = 0:(1/fs):tMax;

% Generate numObsPerClass observations of each class. Each observation
% includes both the original time series data and the corresponding power
% spectrum spectrogram.
for i=1:numObsPerClass
    [singleFreqY(i,:),singleFreqSpectrograms(:,:,1,i)] = singleFrequencySpectrogram(t,fs);
    [threeFreqY(i,:),threeFreqSpectrograms(:,:,1,i)] = threeFrequencySpectrogram(t,fs);
    [gaussianY(i,:),gaussianSpectrograms(:,:,1,i)] = gaussianSpectrogram(t,fs);
    [expY(i,:),expSpectrograms(:,:,1,i)] = gauspulsSpectrogram(t,fs);
end

% Combine per-class data into single variables for all times series
% and all spectrograms. Treat each spectrogram as a 1-channel image,
% with the observation dimension being the fourth dimension.
timeSeries = cat(1,singleFreqY,threeFreqY,gaussianY,expY);
spectrograms = cat(4,singleFreqSpectrograms,threeFreqSpectrograms, ...
    gaussianSpectrograms,expSpectrograms);

% Resize spectrogram images to be 128x128 pixel images.
imgSize = [128 128];
spectrograms = imresize(spectrograms,imgSize);

% Create class labels, in blocks of numObsPerClass.
labels = repmat(classes,numObsPerClass,1);
labels = labels(:);

% Shuffle the data and class labels.
shuffleIdx = randperm(size(spectrograms,4));
timeSeries = timeSeries(shuffleIdx,:);
spectrograms = spectrograms(:,:,:,shuffleIdx);
labels = labels(shuffleIdx);
end