Audio-Analyzer
view release on metacpan or search on metacpan
lib/Audio/Analyzer.pm view on Meta::CPAN
=item sample_rate
How many samples per second are in the PCM file. Default of 44100.
=item bits_per_sample
How many bits per sample in the PCM; must be 16. Default of 16.
=item channels
How many channels of audio is in the PCM; Default 2.
=item fps
How many frames per second are going to be used for audio/visual sync.
Overrides seek_step. No default.
=item seek_step
How far to move forward every iteration. Overridden by fps. Default is not to do
additional seeking which will not create audio/visual synchronized output.
=item scaler
Use another scaler class besides the default Audio::Analyzer::ACurve;
pass in either a string of the name of the class that will be scaling or undef
to perform no scaling at all. See below for information on writting your own
scaler classes. The currently available scalers are:
=over 4
=item Audio::Analyzer::ACurve
A scaling system that maps the output of the Fourier Transform onto an
approximation of the human perception of volume for 20-10,000 hz. This
makes the most sense of the output of the Fourier Transform if you want
to do visual representations of what you are hearing.
=item Audio::Analyzer::AutoScaler
A scaling system which tracks the peak level and forces all numbers to be
between 0 and 1, with 1 being a magnitude of the peak level.
=back
=back
=item $chunk = $analyzer->next;
Iterate once and return a new chunk; see below for information on
Audio::Analyzer::Chunk.
=item $freqs = $analyzer->freqs;
Return an array reference of the frequency numbers that we analyze. This array
ref is the same size as the number of elements in each channel from $chunk->fft.
=item $completed = $analyzer->progress;
Return a number between 0 and 99 that represents in percent how far along in
the file we have processed.
=back
=head1 CHUNK SYSTEM
Instances of Audio::Analyzer::Chunk represent a set of PCM from the file.
Operations on instances of this class perform the FFT and access the PCM.
=over 4
=item $channels = $chunk->pcm;
Return an array ref of channels; each array value is an array ref which contains
the samples from the PCM converted to numbers between -1 and 1.
=item $channels = $chunk->fft;
Return an array ref of channels; each array value is an array ref which contains
the magnitudes from the Fast Fourier Transform. Numbers are between 0 and 1.
=item $combined = $chunk->combine_fft($channels);
Combine together 2 or more channels of FFT output into a single array ref. The
returned ref contains the RMS of each of the channel specific readings.
=back
=head1 SCALER CLASSES
The scaler classes are simple. The scaler will be created through new and a
reference to the analyzer object is provided as an argument. The scaler class
must return a blessed instance of itself.
To perform scaling, Audio::Analyzer will periodically invoke the scale method
of the scaler class. This method must take an array reference which represents
the data returned by the FFT for one channel. The scaler modifies the data
inside the array reference and does not return any value.
Your scaler class should also force all output to be between 0 and 1.
=head1 EXAMPLE MEDIA
The following pieces of media were done using Audio::Analyzer:
=over 4
=item http://www.youtube.com/watch?v=W8Jk8rTP5lg
=item http://www.youtube.com/watch?v=6yTEUBgvxs4
Templatized PovRay scenes written out one file per frame then rendered
into images individually with a make file.
=item http://www.youtube.com/watch?v=bFp2zZlFgv4
Imager::Graph generated pngs of the output of Audio::Analyzer and the internal
state of a software beat detector.
=back
( run in 2.243 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )