Audio::Extract::PCM::Format - Format of PCM data
This class is used by Audio::Extract::PCM and its backends to represent the format of PCM data.
Also known as the sample rate, in samples per second.
In bytes per sample.
The string little or big. The constructor also accepts the string native.
little
big
native
This will print your native endianness ("little" or "big"):
print Audio::Extract::PCM::Format->new(endian => 'native')->endian;
I've read somewhere that there are computers that have "middle endianness", and maybe there are computers that don't use any of the three. I only support systems with either little or big endianness.
A number.
1 or 0, which means signed or unsigned, respectively.
(seconds, may be fractional)
Of course, it doesn't make sense to specify the duration when you call "open" in Audio::Extract::PCM, however it will return you an object that has a duration field, but it may be undefined if the backend does not support getting the duration.
Once you have extracted all the pcm data, you can get the duration in seconds using the formula:
pcm_buffer_length / samplesize / channels / freq
Constructor. You'll probably call this when you want to call "open" in Audio::Extract::PCM or "pcm" in Audio::Extract::PCM. In this case, the following semantics apply:
Specify required values for frequency (samples per second), samplesize (bytes per sample), channels, endianness and signedness:
Audio::Extract::PCM::Format->new( freq => 44100, samplesize => 2, channels => 2, endian => 'native', signed => 1, );
If you omit a specification (or it is "undef"), the value will be chosen by the back-end.
Additionally, there are some special ways to say what you want:
Audio::Extract::PCM::Format->new( # The frequency *must* be one of 44100, 48000 freq => [44100, 48000], # If *possible*, you would like little endian, but you accept other # values too (aka "nice-to-have" values): endian => \['little'], );
Finally, there is a short form:
Audio::Extract::PCM::Format->new($freq, $samplesize, $channels);
This is equivalent to:
Audio::Extract::PCM::Format->new( freq => $freq, samplesize => $samplesize, channels => $channels, endian => 'native', );
This is a useful method if you want to write your own backend. You give it a list of the formats that your backend can provide, and it tells you which one fits the user's wishes best (according to the rules described under "new").
See the source of the provided backends for how to use it.
Argument: another format object
Combines the values of two format objects. Modifies $this and returns it.
$this
If more than one argument is given, the arguments will be interpreted like those of "new".
Returs whether the other format satisfies all required properties of this object.
This package exports the constant "AEPF", which expands to the name of this module.
To install Audio::Extract::PCM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Audio::Extract::PCM
CPAN shell
perl -MCPAN -e shell install Audio::Extract::PCM
For more information on module installation, please visit the detailed CPAN module installation guide.