Audio-Opusfile
view release on metacpan or search on metacpan
lib/Audio/Opusfile.pm view on Meta::CPAN
package Audio::Opusfile;
use 5.014000;
use strict;
use warnings;
use Carp;
use parent qw/Exporter/;
use AutoLoader;
my @constants =
qw/OPUS_CHANNEL_COUNT_MAX
OP_ABSOLUTE_GAIN
OP_DEC_FORMAT_FLOAT
OP_DEC_FORMAT_SHORT
OP_DEC_USE_DEFAULT
OP_EBADHEADER
OP_EBADLINK
OP_EBADPACKET
OP_EBADTIMESTAMP
OP_EFAULT
OP_EIMPL
OP_EINVAL
OP_ENOSEEK
OP_ENOTAUDIO
OP_ENOTFORMAT
OP_EOF
OP_EREAD
OP_EVERSION
OP_FALSE
OP_GET_SERVER_INFO_REQUEST
OP_HEADER_GAIN
OP_HOLE
OP_HTTP_PROXY_HOST_REQUEST
OP_HTTP_PROXY_PASS_REQUEST
OP_HTTP_PROXY_PORT_REQUEST
OP_HTTP_PROXY_USER_REQUEST
OP_PIC_FORMAT_GIF
OP_PIC_FORMAT_JPEG
OP_PIC_FORMAT_PNG
OP_PIC_FORMAT_UNKNOWN
OP_PIC_FORMAT_URL
OP_SSL_SKIP_CERTIFICATE_CHECK_REQUEST
OP_TRACK_GAIN/;
our @EXPORT_OK = @constants;
our @EXPORT = @constants;
our $VERSION = '1.000';
sub AUTOLOAD { ## no critic (ProhibitAutoloading)
my $constname;
our $AUTOLOAD;
($constname = $AUTOLOAD) =~ s/.*:://s;
croak '&Audio::Opusfile::constant not defined' if $constname eq 'constant';
my ($error, $val) = constant($constname);
if ($error) { croak $error; }
{
no strict 'refs'; ## no critic (ProhibitNoStrict)
*$AUTOLOAD = sub { $val };
}
goto &$AUTOLOAD;
}
require XSLoader;
XSLoader::load('Audio::Opusfile', $VERSION);
require Audio::Opusfile::Head;
require Audio::Opusfile::Tags;
require Audio::Opusfile::PictureTag;
sub new_from_file {
my ($class, $file) = @_;
open_file($file)
}
sub new_from_memory {
my ($class, $buf) = @_;
open_memory($buf)
}
1;
__END__
=encoding utf-8
=head1 NAME
Audio::Opusfile - partial interface to the libopusfile Ogg Opus library
=head1 SYNOPSIS
use Audio::Opusfile;
my $of = Audio::Opusfile->new_from_file('silence.opus');
my $tags = $of->tags;
say $tags->query('TITLE'); # Cellule
=head1 DESCRIPTION
lib/Audio/Opusfile.pm view on Meta::CPAN
=item $of->B<read>([I<$bufsize>])
It is recommended to use B<read_float> instead of this method if the
rest of your audio processing chain can handle floating point.
Reads more samples from the stream. I<$bufsize> is the maximum number
of samples read, and it defaults to 1048576. Returns a list whose
first element is the link index this data was decoded from, and the
rest of the elements are PCM samples, as signed 16-bit values at 48
kHz with a nominal range of [-32768,32767). Multiple channels are
interleaved using the L<Vorbis channel ordering|https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810004.3.9>.
You can use C<< $of->head($li)->channel_count >> to find out the
channel count of a given link index.
=item $of->B<read_float>([I<$bufsize>])
Like B<read>, but samples are signed floats with a nominal range of
[-1.0, 1.0].
=item $of->B<read_stereo>([I<$bufsize>])
Like B<read>, but downmixes the stream to stereo (therefore you will
always get two channels) and does NOT return the link index (the first
return value is the first sample).
=item $of->B<read_float_stereo>([I<$bufsize>])
Like B<read_float>, but downmixes the stream to stereo (therefore you
will always get two channels) and does NOT return the link index (the
first return value is the first sample).
=back
=head1 EXPORT
All constants are exported by default:
OPUS_CHANNEL_COUNT_MAX
OP_ABSOLUTE_GAIN
OP_DEC_FORMAT_FLOAT
OP_DEC_FORMAT_SHORT
OP_DEC_USE_DEFAULT
OP_EBADHEADER
OP_EBADLINK
OP_EBADPACKET
OP_EBADTIMESTAMP
OP_EFAULT
OP_EIMPL
OP_EINVAL
OP_ENOSEEK
OP_ENOTAUDIO
OP_ENOTFORMAT
OP_EOF
OP_EREAD
OP_EVERSION
OP_FALSE
OP_GET_SERVER_INFO_REQUEST
OP_HEADER_GAIN
OP_HOLE
OP_HTTP_PROXY_HOST_REQUEST
OP_HTTP_PROXY_PASS_REQUEST
OP_HTTP_PROXY_PORT_REQUEST
OP_HTTP_PROXY_USER_REQUEST
OP_PIC_FORMAT_GIF
OP_PIC_FORMAT_JPEG
OP_PIC_FORMAT_PNG
OP_PIC_FORMAT_UNKNOWN
OP_PIC_FORMAT_URL
OP_SSL_SKIP_CERTIFICATE_CHECK_REQUEST
OP_TRACK_GAIN
=head1 SEE ALSO
L<Audio::Opusfile::Head>,
L<Audio::Opusfile::Tags>,
L<http://opus-codec.org/>,
L<http://opus-codec.org/docs/opusfile_api-0.7/index.html>
=head1 AUTHOR
Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2016-2017 by Marius Gavrilescu
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.24.0 or,
at your option, any later version of Perl 5 you may have available.
=cut
( run in 1.148 second using v1.01-cache-2.11-cpan-483215c6ad5 )