|
@ -20,72 +20,68 @@ function frameF = filterbank(frameT, frameType, winType) |
|
|
persistent kaiserWindowLong kaiserWindowShort sinWindowLong sinWindowShort; |
|
|
persistent kaiserWindowLong kaiserWindowShort sinWindowLong sinWindowShort; |
|
|
if isempty(kaiserWindowLong) || isempty(kaiserWindowShort) || ... |
|
|
if isempty(kaiserWindowLong) || isempty(kaiserWindowShort) || ... |
|
|
isempty(sinWindowLong) || isempty(sinWindowShort) |
|
|
isempty(sinWindowLong) || isempty(sinWindowShort) |
|
|
kaiserLong = kaiser(1024, 6*pi); |
|
|
kaiserLong = kaiser(1025, 6*pi); |
|
|
kaiserSumLong = sum(kaiserLong); |
|
|
kaiserSumLong = sum(kaiserLong); |
|
|
kaiserShort = kaiser(128, 4*pi); |
|
|
kaiserShort = kaiser(129, 4*pi); |
|
|
kaiserSumShort = sum(kaiserShort); |
|
|
kaiserSumShort = sum(kaiserShort); |
|
|
|
|
|
|
|
|
for n = 1:1024 |
|
|
kaiserWindowLong(1:1024) = movsum(kaiserLong(1:1024), [1024 0]); |
|
|
kaiserWindowLong(n) = sqrt(sum(kaiserLong(1:n))/kaiserSumLong); |
|
|
kaiserWindowLong(1025:2048) = movsum(flipud(kaiserLong(1:1024)), [0 1024]); |
|
|
kaiserWindowLong(1024 + n) = sqrt(sum(kaiserLong(1:end-n+1))/kaiserSumLong); |
|
|
kaiserWindowLong = sqrt(kaiserWindowLong ./ kaiserSumLong); |
|
|
|
|
|
|
|
|
sinWindowLong(n) = sin(pi*(n + 0.5)/2048); |
|
|
sinWindowLong = sin(pi * ((0:2047) + 0.5) / 2048); |
|
|
sinWindowLong(1024 + n) = sin(pi*(1024 + n + 0.5)/2048); |
|
|
|
|
|
|
|
|
|
|
|
end |
|
|
kaiserWindowShort(1:128) = movsum(kaiserShort(1:128), [128 0]); |
|
|
|
|
|
kaiserWindowShort(129:256) = movsum(flipud(kaiserShort(1:128)), [0 128]); |
|
|
for n = 1:128 |
|
|
kaiserWindowShort = sqrt(kaiserWindowShort ./ kaiserSumShort); |
|
|
kaiserWindowShort(n) = sqrt(sum(kaiserShort(1:n))/kaiserSumShort); |
|
|
|
|
|
kaiserWindowShort(128 + n) = sqrt(sum(kaiserShort(1:end-n+1))/kaiserSumShort); |
|
|
|
|
|
|
|
|
|
|
|
sinWindowShort(n) = sin(pi*(n + 0.5)/256); |
|
|
sinWindowShort = sin(pi * ((0:255) + 0.5) / 256); |
|
|
sinWindowShort(128 + n) = sin(pi*(128 + n + 0.5)/256); |
|
|
|
|
|
end |
|
|
|
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
% Initializes output array |
|
|
frameF(1024, 2) = 0; |
|
|
frameF(1024, 2) = 0; |
|
|
|
|
|
|
|
|
% Applies appropriate window to the frame |
|
|
% Applies appropriate window to the frame |
|
|
for channel=1:2 |
|
|
if strcmp(frameType, 'OLS') |
|
|
if strcmp(frameType, 'OLS') |
|
|
if strcmp(winType, 'KBD') |
|
|
if strcmp(winType, 'KBD') |
|
|
frameT = bsxfun(@times, frameT, kaiserWindowLong'); |
|
|
frameT(:, channel) = frameT(:, channel) .* kaiserWindowLong(:); |
|
|
elseif strcmp(winType, 'SIN') |
|
|
elseif strcmp(winType, 'SIN') |
|
|
frameT = bsxfun(@times, frameT, sinWindowLong'); |
|
|
frameT(:, channel) = frameT(:, channel) .* sinWindowLong(:); |
|
|
else |
|
|
else |
|
|
error('filterbank, l[20]: Unsupported window type input!') |
|
|
error('filterbank, l[20]: Unsupported window type input!') |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
frameF(:, channel) = mdct4(frameT(:, channel)); |
|
|
frameF = mdct4(frameT); |
|
|
elseif strcmp(frameType, 'LSS') |
|
|
elseif strcmp(frameType, 'LSS') |
|
|
if strcmp(winType, 'KBD') |
|
|
if strcmp(winType, 'KBD') |
|
|
frameT(1:1024, channel) = frameT(1:1024, channel) .* kaiserWindowLong(1:1024)'; |
|
|
frameT(1:1024, :) = bsxfun(@times, frameT(1:1024, :), kaiserWindowLong(1:1024)'); |
|
|
frameT(1473:1600, channel) = frameT(1473:1600, channel) .* kaiserWindowShort(129:end)'; |
|
|
frameT(1473:1600, :) = bsxfun(@times, frameT(1473:1600, :), kaiserWindowShort(129:end)'); |
|
|
frameT(1601:end, channel) = 0; |
|
|
frameT(1601:end, :) = 0; |
|
|
elseif strcmp(winType, 'SIN') |
|
|
elseif strcmp(winType, 'SIN') |
|
|
frameT(1:1024, channel) = frameT(1:1024, channel) .* sinWindowLong(1:1024)'; |
|
|
frameT(1:1024, :) = bsxfun(@times, frameT(1:1024, :), sinWindowLong(1:1024)'); |
|
|
frameT(1473:1600, channel) = frameT(1473:1600, channel) .* sinWindowShort(129:end)'; |
|
|
frameT(1473:1600, :) = bsxfun(@times, frameT(1473:1600, :), sinWindowShort(129:end)'); |
|
|
frameT(1601:end, channel) = 0; |
|
|
frameT(1601:end, :) = 0; |
|
|
else |
|
|
else |
|
|
error('filterbank, l[20]: Unsupported window type input!') |
|
|
error('filterbank, l[20]: Unsupported window type input!') |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
frameF(:, channel) = mdct4(frameT(:, channel)); |
|
|
frameF = mdct4(frameT); |
|
|
elseif strcmp(frameType, 'LPS') |
|
|
elseif strcmp(frameType, 'LPS') |
|
|
if strcmp(winType, 'KBD') |
|
|
if strcmp(winType, 'KBD') |
|
|
frameT(1:448, channel) = 0; |
|
|
frameT(1:448, :) = 0; |
|
|
frameT(449:576, channel) = frameT(449:576, channel) .* kaiserWindowShort(1:128)'; |
|
|
frameT(449:576, :) = bsxfun(@times, frameT(449:576, :), kaiserWindowShort(1:128)'); |
|
|
frameT(1025:end, channel) = frameT(1025:end, channel) .* kaiserWindowLong(1025:end)'; |
|
|
frameT(1025:end, :) = bsxfun(@times, frameT(1025:end, :), kaiserWindowLong(1025:end)'); |
|
|
elseif strcmp(winType, 'SIN') |
|
|
elseif strcmp(winType, 'SIN') |
|
|
frameT(1:448, channel) = 0; |
|
|
frameT(1:448, :) = 0; |
|
|
frameT(449:576, channel) = frameT(449:576, channel) .* sinWindowShort(1:128)'; |
|
|
frameT(449:576, :) = bsxfun(@times, frameT(449:576, :), sinWindowShort(1:128)'); |
|
|
frameT(1025:end, channel) = frameT(1025:end, channel) .* sinWindowLong(1025:end)'; |
|
|
frameT(1025:end, :) = bsxfun(@times, frameT(1025:end, :), sinWindowLong(1025:end)'); |
|
|
else |
|
|
else |
|
|
error('filterbank, l[20]: Unsupported window type input!') |
|
|
error('filterbank, l[20]: Unsupported window type input!') |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
frameF(:, channel) = mdct4(frameT(:, channel)); |
|
|
frameF = mdct4(frameT); |
|
|
elseif strcmp(frameType, 'ESH') |
|
|
elseif strcmp(frameType, 'ESH') |
|
|
|
|
|
for channel = 1:2 |
|
|
% Splits the frame into sub-frames |
|
|
% Splits the frame into sub-frames |
|
|
[subFrames, ~] = buffer(frameT(449:end-448, channel), 256, 128, 'nodelay'); |
|
|
[subFrames, ~] = buffer(frameT(449:end-448, channel), 256, 128, 'nodelay'); |
|
|
|
|
|
|
|
@ -96,7 +92,8 @@ function frameF = filterbank(frameT, frameType, winType) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
for subFrameIndex = 1:8 |
|
|
for subFrameIndex = 1:8 |
|
|
frameF((subFrameIndex - 1) * 128 + 1:subFrameIndex * 128, channel) = mdct4(subFrames(:, subFrameIndex)); |
|
|
frameF((subFrameIndex - 1) * 128 + 1:subFrameIndex * 128, channel) = ... |
|
|
|
|
|
mdct4(subFrames(:, subFrameIndex)); |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|