Audio::Tools::Time - time / sample / byte conversion tools.
Tools for converting bytes into samples, samples into time etc.
my $time = new Audio::Tools::Time 44100, 16, 2; my $bytes = $time -> nice_bytes( 11025 ); my $sample = $time -> bytes_to_samples( $bytes ); my $secs = $time -> samples_to_seconds( $sample ); my( $mins, $secs, $fract_secs ) = $time -> split_time( $secs ); my $dao_time = $time -> dao_time( $secs );
Nick Peskett - nick@soup.demon.co.uk
Audio::Wav
Audio::Mix
Audio::CoolEdit
Returns a blessed Audio::Tools::Time object.
my $time = new Audio::Tools::Time sample_rate, bits_per_sample, channels;
Where;
sample_rate = number of samples per second (44100 is cd quality) bits_per_sample = number of bits per samples (16 is cd quality) channels = number of channels of sound (stereo is 2)
Converts a sample offset to it's byte offset.
my $bytes = $time -> samples_to_bytes( $sample );
Converts a byte offset to it's sample offset.
my $sample = $time -> bytes_to_samples( $bytes );
Converts a sample offset to it's position as floating point seconds.
my $secs = $time -> samples_to_seconds( $sample );
Converts a byte offset to it's position as floating point seconds.
my $secs = $time -> bytes_to_seconds( $samples );
Converts a position in seconds (can be floating point) to it's sample offset.
my $sample = $time -> seconds_to_samples( $secs );
Converts a position in seconds (can be floating point) to it's byte offset.
my $sample = $time -> seconds_to_bytes( $secs );
Rounds down a byte offset to a appropriate byte offset for the current settings.
$bytes = $time -> nice_bytes( $bytes );
Converts a floating point seconds position to minutes, seconds & fractional seconds.
my( $mins, $secs, $fract_secs ) = $time -> split_time( $secs );
Converts a floating point seconds position to a string containing the format used by disk-at-once & CDRWin. (http://www.goldenhawk.com)
my $dao_time = $time -> dao_time( $secs );
Converts a floating point seconds position into a string that verbosely describes the time. If $terse is true then the output will only show the most significant value (to one decimal place if hour or minute).
print $time -> nice_time( 90 ); # returns "1 min, 30 secs" print $time -> nice_time( 90, 1 ); # returns "1.5 mins"
Writes a cue file in the format used by disk-at-once & CDRWin. (http://www.goldenhawk.com)
$time -> dao_cue_file( $breaks, './audio.wav', './output.cue' );
Where $breaks is a reference to an array of byte offsets.
Returns the current block alignment, ie 44.1khz 16 bit stereo: 1 sample = 4 bytes
my block_align = $time -> block_align();
To install Audio::Tools, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Audio::Tools
CPAN shell
perl -MCPAN -e shell install Audio::Tools
For more information on module installation, please visit the detailed CPAN module installation guide.