You are asking for a very complicated procedure, to be nicely encapsulated into a simple to use module. Nope..... we are not that advanced yet...... maybe Spock's Tricorder can do it. :-)

If you want to try, here are the steps you will need to do.

1. You will need to run alsactl (through system or a piped open) to make sure your input is set to Linein (as opposed to Mic). It would go something like this:

#setup a shell thru IPC to carry out different # mixer control commands my $pidcon = open3(\*CON,0,0,'/bin/sh'); # ...... ..... snip ...... #set Line as input print CON "amixer sset Line Capture cap\n";

2. Then you need to record 5 seconds of input:

#!/usr/bin/perl use Audio::DSP; #alsamixer must be setup right, just turn everything up :-) ($buf, $chan, $fmt, $rate) = (4096, 1, 16 , 8000); $dsp = new Audio::DSP(buffer => $buf, channels => $chan, format => $fmt, rate => $rate); $seconds = 5; $length = ($chan * $fmt * $rate * $seconds) / 8; $dsp->init() || die $dsp->errstr(); open(OUT, ">out.raw") or warn $!; # Record x seconds of sound for (my $i = 0; $i < $length; $i += $buf) { $dsp->read() || die $dsp->errstr(); print OUT $dsp->data(); } $dsp->close();

3. Then once you have that input, you can compare it with a FFT (Fast Fourier Transform) to the 5 seconds of song. See PDL::Audio and Re: Manipulating Audio Data in Perl

Finally, you have about 3 months of work to perfect this. If you get it to work, the Dept. of Homeland Security probably would give you a job in it's voice analysis unit. :-)


I'm not really a human, but I play one on earth. Cogito ergo sum a bum

In reply to Re: Process Sound by zentara
in thread Process Sound by Cheater

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.