]>
iEval git - audio-opusfile.git/blob - lib/Audio/Opusfile/Head.pm
1 package Audio
::Opusfile
::Head
;
2 # Don't load this module directly, load Audio::Opusfile instead
8 our $VERSION = '0.004';
17 Audio::Opusfile::Head - The header of an Ogg Opus file
23 my $of = Audio::Opusfile->new_from_file('empty.opus');
25 say $head->version; # 1
26 say $head->channel_count; # 2
27 say $head->pre_skip; # 356
28 say $head->input_sample_rate; # 44100
29 say $head->output_gain; # 0
30 say $head->mapping_family; # 0
31 say $head->stream_count; # 1
32 say $head->coupled_count; # 1
33 say $head->mapping(0); # 0
34 say $head->mapping(1); # 1
38 This module represents the header of an Ogg Opus file. See the
39 documentation of L<Audio::Opusfile> for more information.
45 =item $head->B<version>
47 The Ogg Opus format version, in the range 0...255.
49 The top 4 bits represent a "major" version, and the bottom four bits
50 represent backwards-compatible "minor" revisions.
52 The current specification describes version 1.
54 =item $head->B<channel_count>
56 The number of channels, in the range 1...255.
58 =item $head->B<pre_skip>
60 The number of samples that should be discarded from the beginning of
63 =item $head->B<input_sample_rate>
65 The sampling rate of the original input.
67 All Opus audio is coded at 48 kHz, and should also be decoded at 48
68 kHz for playback (unless the target hardware does not support this
69 sampling rate). However, this field may be used to resample the audio
70 back to the original sampling rate, for example, when saving the
73 =item $head->B<output_gain>
75 The gain to apply to the decoded output, in dB, as a Q8 value in the
78 The libopusfile API will automatically apply this gain to the decoded
79 output before returning it, scaling it by
80 pow(10,output_gain/(20.0*256)).
82 =item $head->B<mapping_family>
84 The channel mapping family, in the range 0...255.
86 Channel mapping family 0 covers mono or stereo in a single stream.
87 Channel mapping family 1 covers 1 to 8 channels in one or more
88 streams, using the Vorbis speaker assignments. Channel mapping family
89 255 covers 1 to 255 channels in one or more streams, but without any
90 defined speaker assignment.
92 =item $head->B<stream_count>
94 The number of Opus streams in each Ogg packet, in the range 1...255.
96 =item $head->B<coupled_count>
98 The number of coupled Opus streams in each Ogg packet, in the range
101 This must satisfy 0 <= coupled_count <= stream_count and coupled_count
102 + stream_count <= 255. The coupled streams appear first, before all
103 uncoupled streams, in an Ogg Opus packet.
105 =item $head->B<mapping>(I<$k>)
107 The mapping from coded stream channels to output channels.
109 Let C<< index = mapping[k] >> be the value for channel I<$k>. If
110 C<< index < 2 * coupled_count >>, then it refers to the left channel
111 from stream C<< (index/2) >> if even, and the right channel from
112 stream C<< (index/2) >> if odd. Otherwise, it refers to the output of
113 the uncoupled stream C<< (index-coupled_count) >>.
115 Dies if I<$k> is more than OPUS_CHANNEL_COUNT_MAX.
122 L<http://opus-codec.org/>,
123 L<http://opus-codec.org/docs/opusfile_api-0.7/structOpusHead.html>
127 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
129 =head1 COPYRIGHT AND LICENSE
131 Copyright (C) 2016 by Marius Gavrilescu
133 This library is free software; you can redistribute it and/or modify
134 it under the same terms as Perl itself, either Perl version 5.24.0 or,
135 at your option, any later version of Perl 5 you may have available.
This page took 0.053559 seconds and 4 git commands to generate.