Audio::Mad::Timer - Interface to mad_timer_t structure
my $timer = new Audio::Mad::Timer(15, 505, MAD_UNITS_MILLISECONDS); my $timer2 = $timer->new_copy(); $timer2->set(31, 5, MAD_UNITS_CENTISECONDS); $timer->reset(); $timer->negate(); if ($timer->compare($timer2) == -1) { print "timer < timer2" } if ($timer2->sign() == -1) { print "timer2 is < 0"; $timer2->abs(); print "timer2 is > 0"; } $timer->add($timer2); $timer2->multiply(15); my $ms = $timer2->count(MAD_UNITS_MILLISECONDS); my $cs = $timer->fraction(MAD_UNITS_CENTISECONDS);
This package provides access to the underlying mad_timer_t data structure used in the decoder library. It also provides several overloaded methods so you can treat the timer more like a fundamental data type than an object.
new([seconds, fraction, denominator])
Creates a new timer, and optionally initializes it's initial count with it's paramaters. seconds is the whole seconds to add to the timer, fraction is the whole number of fractional seconds to add to the timer, denominator is used to divide the fractional seconds before it's added to the timer.
new_copy
Creates a new timer, and sets the initial value to the value of the object it was called on.
set(seconds, fraction, denominator])
Sets the value of the timer, see the ->new method, above.
reset
Resets the value of the timer to zero.
negate
Negates the current value of the timer, in place.
compare(timer)
Returns -1, 0, or 1 if the value of the object is currently less than, equal to, or greater than (respectively) the value of timer.
sign
Returns -1, 0, or 1 if the value of the object is currently less than, equal to, or greater than (respectively) zero.
abs
Resets the timer to the abosolute value of itself, in place.
add(timer)
Adds the value of timer to the value of the object.
multiply(int)
Multiplies the value of the object by int.
count(units)
Returns the current count of the timer, in units, generally expressed as a MAD_UNITS constant.
fraction(denominator)
Returns the current whole number of fractional seconds in terms of the denominator.
+, ++, -, --, *, /
The set of mathemetical operators that work on Audio::Mad::Timer objects. You may sepecify either another Audio::Mad::Timer object or a whole number on the right hand side.
>, >=, <, <=, ==, !=, <=>
The set of comparison operators that work on Audio::Mad::Timer objects.
", 0+, ${}, @{}, %{}
The set of conversion operators that work on Audio::Mad::Timer objects.
Mark McConnell <mischke@cpan.org>
To install Audio::Mad, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Audio::Mad
CPAN shell
perl -MCPAN -e shell install Audio::Mad
For more information on module installation, please visit the detailed CPAN module installation guide.