Audio
view release on metacpan or search on metacpan
Data/Data.pm view on Meta::CPAN
=item $audio->noise($dur,$amp);
Append burst of (white) noise of specified duration and peak amplitude.
=item $window = $audio->hamming($SIZE,$start_sample[,$k])
Returns a "raised cosine window" sample of I<$SIZE> samples starting at specified
sample. If I<$k> is specified it overrides the default value of 0.46
(e.g. a value of 0.5 would give a Hanning window as opposed to a Hamming window.)
windowed = ((1.0-k)+k*cos(x*PI))
=item $freq = $audio->fft($SIZE)
=item $time = $freq->ifft($SIZE);
Perform a Fast Fourier Transform (or its inverse).
(Note that in general result of these methods have complex numbers
as the elements. I<$SIZE> should be a power-of-two (if it isn't next larger
power of two is used). Data is padded with zeros as necessary to get to
I<$SIZE> samples.
=item @values = $audio->amplitude([$N[,$count]])
Return values of amplitude for sample $N..$N+$count inclusive.
if I<$N> is not specified it defaults to zero.
If I<$count> is not specified it defaults to 1 for scalar context
and rest-of-data in array context.
=item @values = $audio->dB([$N[,$count]])
Return amplitude - in deci-Bells.
(0dB is 1/2**15 i.e. least detectable value to 16-bit device.)
Defaults as for amplitude.
=item @values = $audio->phase([$N [,$count]])
Return Phase - (if data are real returns 0).
Defaults as for amplitude.
=item $diff = $audio->difference
Returns the first difference between successive elements of the data -
so result is one sample shorter. This is a simple high-pass filter and
is much used to remove DC offsets.
=item $Avalues = $audio->lpc($NUM_POLES,[$auto [,$refl]])
Perform Linear Predictive Coding analysis of $audio and return coefficents
of resulting All-Pole filter. 0'th Element is I<not> a filter coefficent
(there is no A[0] in such a filter) - but is a measure of the "error"
in the matching process. I<$auto> is an output argument and returns
computed autocorrelation. I<$refl> is also output and are so-called
reflection coefficents used in "lattice" realization of the filter.
(Code for this lifted from "Festival" speech system's speech_tools.)
=item $auto = $audio->autocorrelation($LENGTH)
Returns an (unscaled) autocorrelation function - can be used to cause
peaks when data is periodic - and is used as a precursor to LPC analysis.
=back 4
=head2 Operators
B<Audio::Data> also provides overloaded operators where the B<Audio::Data> object
is treated as a vector in a mathematical sense. The other operand of an
operator can either be another B<Audio::Data> or a scalar which can be
converted to a real number.
=over 4
=item $audio * $scalar
Multiply each element by the scalar - e.g. adjust "volume".
=item $audio * $another
Is ear-marked to perform convolution but does not work yet.
=item $audio / $scalar
Divide each element by the scalar - e.g. adjust "volume".
=item $scalar / $audio
Return a new object with each element being result of dividing scalar
by the corresponding element in original I<$audio>.
=item $audio + $scalar
Add $scalar to each element - i.e. apply a DC offset.
=item $audio + $another
Adds element-by-element - i.e. mixes them.
=item $audio - $scalar
Subtract $scalar from each element.
=item $audio - $another
Subtracts element-by-element
=item $audio . $scalar
Append a new element. (Perhaps if scalar is a string it should
append to comment instead - but what is a string ... )
=item $audio . $another
Appends the two objects to get a longer one.
=item $audio . [ @things ]
Appends contents of array to the object, the contents can
be scalars, Audio::Data objects or (as it recurses) refrences to arrays.
( run in 0.555 second using v1.01-cache-2.11-cpan-39bf76dae61 )