|
@ -39,6 +39,15 @@ function AACSeq3 = AACoder3(fNameIn, fnameAACoded) |
|
|
|
|
|
|
|
|
% Declares constant window type |
|
|
% Declares constant window type |
|
|
WINDOW_TYPE = 'KBD'; |
|
|
WINDOW_TYPE = 'KBD'; |
|
|
|
|
|
% Declares constant numbers of bands for long and short windows |
|
|
|
|
|
LONG_WINDOW_NUMBER_OF_BANDS = 69; |
|
|
|
|
|
SHORT_WINDOW_NUMBER_OF_BANDS = 42; |
|
|
|
|
|
|
|
|
|
|
|
% Declares persistent variable holding the TNS tables and initializes if empty |
|
|
|
|
|
persistent TNSTables; |
|
|
|
|
|
if isempty(TNSTables) |
|
|
|
|
|
TNSTables = load('TableB219.mat'); |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
% Reads the audio file |
|
|
% Reads the audio file |
|
|
[originalAudioData, ~] = audioread(fNameIn); |
|
|
[originalAudioData, ~] = audioread(fNameIn); |
|
@ -111,8 +120,34 @@ function AACSeq3 = AACoder3(fNameIn, fnameAACoded) |
|
|
[SL, sfcL, GL] = AACquantizer(frameF(:, 1), frameTypes{i+1}, SMRL); |
|
|
[SL, sfcL, GL] = AACquantizer(frameF(:, 1), frameTypes{i+1}, SMRL); |
|
|
[SR, sfcR, GR] = AACquantizer(frameF(:, 2), frameTypes{i+1}, SMRR); |
|
|
[SR, sfcR, GR] = AACquantizer(frameF(:, 2), frameTypes{i+1}, SMRR); |
|
|
|
|
|
|
|
|
TL = 0; |
|
|
if ~strcmp(frameTypes{i+1}, 'ESH') |
|
|
TR = 0; |
|
|
TL(LONG_WINDOW_NUMBER_OF_BANDS, 1) = 0; |
|
|
|
|
|
TR(LONG_WINDOW_NUMBER_OF_BANDS, 1) = 0; |
|
|
|
|
|
for band = 1:LONG_WINDOW_NUMBER_OF_BANDS |
|
|
|
|
|
frameWlow = TNSTables.B219a(band, 2) + 1; |
|
|
|
|
|
frameWhigh = TNSTables.B219a(band, 3) + 1; |
|
|
|
|
|
subFrameF = frameF(frameWlow:frameWhigh); |
|
|
|
|
|
TL(band) = sumsqr(subFrameF) ./ SMRL(band); |
|
|
|
|
|
TR(band) = sumsqr(subFrameF) ./ SMRR(band); |
|
|
|
|
|
end |
|
|
|
|
|
plot(TL); |
|
|
|
|
|
else |
|
|
|
|
|
TL(SHORT_WINDOW_NUMBER_OF_BANDS, 1) = 0; |
|
|
|
|
|
TR(SHORT_WINDOW_NUMBER_OF_BANDS, 1) = 0; |
|
|
|
|
|
for subFrameIndex = 1:8 |
|
|
|
|
|
currFrameStart = (subFrameIndex - 1) * 128 + 1; |
|
|
|
|
|
currFrameStop = currFrameStart + 127; |
|
|
|
|
|
subFrame = frameF(currFrameStart:currFrameStop); |
|
|
|
|
|
for band = 1:SHORT_WINDOW_NUMBER_OF_BANDS |
|
|
|
|
|
frameWlow = TNSTables.B219b(band, 2); |
|
|
|
|
|
frameWhigh = TNSTables.B219b(band, 3); |
|
|
|
|
|
subFrameF = subFrame(frameWlow + 1:frameWhigh + 1); |
|
|
|
|
|
|
|
|
|
|
|
TL(band, subFrameIndex) = sumsqr(subFrameF) ./ SMRL(band); |
|
|
|
|
|
TR(band, subFrameIndex) = sumsqr(subFrameF) ./ SMRR(band); |
|
|
|
|
|
end |
|
|
|
|
|
end |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
[streamL, huffcodebookL] = encodeHuff(SL, huffLUT); |
|
|
[streamL, huffcodebookL] = encodeHuff(SL, huffLUT); |
|
|
[streamR, huffcodebookR] = encodeHuff(SR, huffLUT); |
|
|
[streamR, huffcodebookR] = encodeHuff(SR, huffLUT); |
|
|