"dsp": # -- #!/usr/bin/perl use Audio::DSP; ($buf, $chan, $fmt, $rate) = (4096, 1, 16, 8000); $dsp = new Audio::DSP(buffer => $buf, channels => $chan, format => $fmt, rate => $rate); $dsp->init() || die $dsp->errstr(); open(IN,"in.pcm"); open(OUT,">out.pcm"); for($i=0;$i<5;$i++){ print OUT $dsp->dread(4096); } while(4096==read(IN,$buffer,4096)){ print OUT $dsp->dread(4096); $dsp->dwrite($buffer); } $dsp->close(); --END dsp--- "soundc" : #!/usr/bin/perl -w use IO::Socket; $host = shift(@ARGV); $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "9000", ); $remote->autoflush(1); system("./dsp &"); if($kidpid=fork()){ open(WRITE,"|lame --decode --mp3input -f - in.pcm"); while(4096==read($client,$buffer,4096)){ print WRITE $buffer; } kill("TERM",$kidpid); } else { open(READ," lame -frx -s 8000 -m m -b 8 out.pcm - |"); for(;;){ read(READ,$buffer2,4096); print $client $buffer2; } } close(READ); close(WRITE); close $remote; -- END soundc --- "soundd" : #!/usr/bin/perl -w use IO::Socket; use Net::hostent; # for OO version of gethostbyaddr $PORT = 9000; # pick something not in use $server = IO::Socket::INET->new( Proto => 'tcp', LocalPort => $PORT, Listen => SOMAXCONN, Reuse => 1); die "can't setup server" unless $server; print "[Server $0 accepting clients]\n"; while ($client = $server->accept()) { $client->autoflush(1); system("./dsp &"); if($kidpid=fork()){ open(WRITE,"|lame --decode --mp3input -f - in.pcm"); while(4096==read($client,$buffer,4096)){ print WRITE $buffer; } kill("TERM",$kidpid); } else { open(READ," lame -frx -s 8000 -m m -b 8 out.pcm - |"); for(;;){ read(READ,$buffer2,4096); print $client $buffer2; } } close(READ); close(WRITE); #close $client; } --- END soundd ---

In reply to ip-phone by Anonymous Monk

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.