Semester assignment for the course "Multimedia systems and virtual reality" of THMMY in AUTH university.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.4 KiB

6 years ago
function x = iAACoder1(AACSeq1, fNameOut)
6 years ago
%Implementation of AAC decoder
6 years ago
% Usage x = iAACoder1(AACSeq1, fNameOut), where:
% Inputs
% - fNameOut is the filename and path of the file that will be
% written after decoding
% - AACSeq1 is an array of structs containing K structs, where K is
% the number of computed frames. Every struct of the array consists
% of a frameType, a winType, chl.frameF which are the MDCT
% coefficients of this frame's left channel, chr.frameF which are
% the MDCT coefficients of this frame's right channel
%
% Output
% - x is an array containing the decoded audio samples
6 years ago
% Initializes an array to hold the decoded samples
6 years ago
decodedAudio(1024 * (length(AACSeq1) + 1), 2) = 0;
6 years ago
% Initializes an array to hold both audio channels
6 years ago
frameF(1024, 2) = 0;
6 years ago
% Decodes audio file
for i = 0:length(AACSeq1) - 1
6 years ago
currFrameStart = i * 1024 + 1;
currFrameStop = currFrameStart + 2047;
frameF(:, 1) = AACSeq1(i+1).chl.frameF;
frameF(:, 2) = AACSeq1(i+1).chr.frameF;
frameT = iFilterbank(frameF, AACSeq1(i+1).frameType, AACSeq1(i+1).winType);
decodedAudio(currFrameStart:currFrameStop, :) = decodedAudio(currFrameStart:currFrameStop, :) + frameT;
end
audiowrite(fNameOut, decodedAudio, 48000);
x = decodedAudio;
end