Audio-MPEG

 view release on metacpan or  search on metacpan

MPEG.pm  view on Meta::CPAN


=head2 Audio::MPEG::Decode

=over 4

=item B<new>()

This creates a new object. Each object has it's own private context, so
it is possible to have more than one object created at a time.

Once a stream has started to be decoded, the object may only be used for
that stream (due to state information kept in the object).

=item B<$len> = B<buffer>(I<$data>)

This method adds an arbitrary "chunk" of input MP3 data to the internal
buffering pool. Typically, this is at least 4KB of data. A good length
of data to pass is 40KB (approximately 1 second of audio encoded at 320kbps
or 2.5 seconds of audio encoded at 128KBs).

Method returns the length of data, in bytes, that has not be decoded yet.

=item B<decode_frame>()

This method will process the next MP3 frame of the data that has been
buffered with B<buffer>(), prepares it for PCM synthesis. The prepared
data is stored in the object. Do not use both this function and
B<decode_frame_header>() on the same object.

Method returns 1 if a frame was decoded (successfully or not), and 0
if it ran out of data before finishing decoding.

Upon return, program should interrogate I<$obj->err>. If it is > 0, then
a decoding error has occurred, and no PCM synthesis is possible (i.e. frame
should be skipped). See the EXAMPLES section later in this document.

=item B<decode_frame_header>()

This method will process the next MP3 frame of the data that has been
buffered with B<buffer>(), and does B<not> prepare it for PCM synthesis.

MPEG.pm  view on Meta::CPAN

Returns the 1 if the error is recoverable, or 0 if it's a bad error. This,
or err(), should be checked after every B<decode_frame>() or
B<decode_frame_header>() call.

=item B<errstr>()

Returns an English string describing the error condition.

=item B<current_frame>()

Returns the current MP3 frame that was decoded.

=item B<total_frames>()

Returns the total number of MP3 frames decoded. Used after decoding has
been completed.

=item B<frame_duration>()

Returns the length of the frame, in seconds, that was decoded.

=item B<total_duration>()

Returns the total duration, in seconds, that was decoded. Used after decoding
has been completed.

=item B<bit_rate>()

Returns the bitrate, in kbs, of the frame that was decoded.

=item B<average_bit_rate>()

Returns the average bitrate of the decoded frames. Used after decoding has
been completed.

=item B<sample_rate>()

Returns the samplerate, in Hertz, of the decoded frame.

=item B<layer>()

Returns the MPEG audio layer number of the decoded frame.

=item B<channels>()

Returns the number of PCM channels that were decoded (1 or 2) of the
decoded frame.

=item B<pcm>()

Returns the synthesized PCM structure of the decoded/synthesized frame.
This format is in a 24bit fixed-point format, and is only intended for
passing to an B<Audio::MPEG::Output> object. It is also intended to be
used by a planned future filtering object.

=back

=head2 Audio::MPEG::Output

=over 4

MPEG.pm  view on Meta::CPAN

frame's PCM stream will be skipped and not converted to an output stream.
Default is to not correct for delay.

=back

=item B<header>($I<datasize>)

This method will return a header (first few bytes of data) that is valid
for the output type. $I<datasize> refers to the length of audio data in bytes.
If not passed the length, B<header>() will output a valid header, except that
the embedded length will be zero. After the sample is decoded, header is
typically called again, and re-written to the beginning of the file (see
the EXAMPLE section of the document). If called with an object type that
does not have a header, this returns an empty scalar.

Currently, only Sun mulaw and WAV formats have headers.

=item B<encode>($I<pcm>)

This method will encode an input PCM stream and return a scalar containing
the output audio stream. Input is typically the output of

MPEG.xs  view on Meta::CPAN

		if (MAD_RECOVERABLE(stream->error))
			err = 0;
		if (!err) {
			THIS->current_frame++;
			THIS->accum_bitrate += header->bitrate / 1000;
			mad_timer_add(&THIS->total_duration, header->duration);
		}
		XSRETURN_YES;

#
# Create PCM stream (in mad_fixed_t type) from decoded frame
#

void
synth_frame(THIS)
		Audio_MPEG_Decode THIS
	CODE:
		mad_synth_frame(THIS->synth, THIS->frame);

#
# Return last error code



( run in 0.252 second using v1.01-cache-2.11-cpan-26ccb49234f )