You probably want the Audio::DSP module. Here is an example of pulling the audio bits right off of the capture device of the soundcard's playback device.
You will then have the raw audio data, which you will have to separate out into individaul audio bytes by channels, format and rate.#!/usr/bin/perl use Audio::DSP; #alsamixer must be setup right, just turn everything up :-) ($buf, $chan, $fmt, $rate) = (4096, 1, 16, 22050); # $fmt=8 will work, but it's better to use the formats in soundcard. +h # some soundcards won't like 8-bit sound, or may need to be re-initial +ized $dsp = new Audio::DSP(buffer => $buf, channels => $chan, format => $fmt, rate => $rate); $dsp->init() || die $dsp->errstr(); open(OUT, ">out.raw") or warn $!; while ( $buffer = $dsp->dread(4096) ) { print OUT $buffer; } $dsp->close(); # to convert to wave # sox -r 8000 -u -b -c 1 out.raw out.wav
It is not simple code, to put audio onto a canvas, have a cursor select a section, determine the actual seek positions for begin and end in the audio file, then feed that to FFT.
To compound the problem, Perl is much slower than C for doing numerical computations, so you probably want a module that does the FFT thru a C based xs based module.
Even to plot the audio on a canvas, requires some intensive calculations to read the audio file, byte by audio byte. See Zero sound detection with Tk graphics and Tk-applause-meter
In reply to Re: Music and FFT
by zentara
in thread Music and FFT
by llancet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |