NAME

Peta::MP3::Encode::Filterbank - samples into Layer III's frequency lines

VERSION

version 0.2610180

SYNOPSIS

my $bank = Peta::MP3::Encode::Filterbank->new(44100);    # one per channel
my $xr   = $bank->granule(\@samples, $block_type);      # 576 samples, -1 .. 1

DESCRIPTION

The polyphase filterbank, the MDCT in its four windows and the aliasing butterflies of ISO 11172-3, in plain Perl. Each bank keeps what the next granule needs, so a channel needs its own. Short blocks come out in the bitstream's order (band, window, line).

Peta::MP3::Encode::Filterbank::PDL computes the same with PDL, from the functions matrixing, sign, long_window, long_mdct, short_mdct, butterflies and short_order here.

METHODS

new

new($rate): a bank for a sample rate, with nothing before the first granule.

granule

granule(\@samples, $type): the lines of the next granule of 576 samples, in a block type's window.

subbands, mdct

Its steps: a granule of 576 samples into 18 samples of each of the 32 subbands (sub[32 t + sb]); the lines of a granule from its subband samples and the previous granule's, in a block type's window.

FUNCTIONS

matrixing, sign

matrixing($sb, $k): the matrixing of 64 windowed sums into subband $sb, at sum $k; sign($sb, $t): the sign that undoes the filterbank's inverting every other subband in every other step.

long_window, long_mdct, short_mdct

A long block's window at input $k of 36 (the start and stop windows join a long half and a short one); the long MDCT through a block type's window, input $k's share of line $m; the short MDCT's, of line $m of 6.

butterflies, short_order

The aliasing butterflies' coefficients (Table B.9), (\@cs, \@ca); where each line of a short block in the bitstream's order is among the MDCT's (line 6 sb + m of window w is MDCT line 18 sb + 3 m + w).

AUTHOR

PetaMem s.r.o. <info@petamem.com>

COPYRIGHT

Copyright (c) 2026 PetaMem s.r.o.

LICENSE

This package is free software, dual-licensed under the Artistic License 2.0 and the BSD 2-Clause License. See the LICENSE file of the distribution.