NAME
Audio::Tools::Fades - Fading in & out algorithms.
DESCRIPTION
Fades is a collection of algorithms for fading in/ out audio files.
SYNOPSIS
use Audio::Tools::Fades;
my $up_to = 5;
my @names = qw( in out );
my $volume = 1;
my $fades = new Audio::Tools::Fades;
foreach my $type ( qw( linear exp invexp trig invtrig ) ) {
for my $direction ( 0, 1 ) {
my $fade = $fades -> fade( $up_to, $direction, $type );
print "fade $names[$direction] type: $type;\n\t";
for my $sample ( 0 .. $up_to ) {
printf ' %2d->%2.2f', $sample, &$fade( $sample, $volume );
}
print "\n";
}
}
AUTHOR
Nick Peskett - nick@soup.demon.co.uk
SEE ALSO
METHODS
new
Returns a blessed Audio::Tools::Fades object.
my $fades = new Audio::Tools::Fades;
fade
Returns a reference to a subroutine that is initialised to the length of samples the fade is to last for. The subroutine returned takes the current sample offset & the current sample value as parameters. In the example I have used sample value 1 so you can see the effect of the fade.
my $fade = $fades -> fade( $length, $direction, $type );
for my $sample ( 0 .. $length ) {
printf ' %2d->%2.2f', $sample, &$fade( $sample, 1 );
}
print "\n";
Where;
$length = length of fade
$direction = 0 for in, 1 for out
$type is one of;
linear = smooth gradient
exp = exponential (gets loud quickly)
invexp = inverse exponential (gets loud slowly)
trig = trigonomic, roughly in between linear & exp
invtrig = inverse trigonomic