in reply to Playing wave file in Ubuntu 10.10
On Ubuntu, with the Alsa sound system, you have a great utility called aplay. It will auto-detect the soundfile stats, for proper playing, so all you need to play a wav is
#!/usr/bin/perl # fork off, so the playback is non-blocking if(fork() == 0){exec("aplay $my_sound_file")}
Or with Perl......
#!/usr/bin/perl use warnings; use strict; use Audio::DSP; #alsamixer must be setup right, just turn everything up :-) # use the channel count, bitrate, and samplerate of the wave # you want to play my ($buf, $chan, $fmt, $rate) = (4096, 1, 8, 22050); my $dsp = new Audio::DSP(buffer => $buf, channels => $chan, format => $fmt, rate => $rate); $dsp->init() || die $dsp->errstr(); my $file = shift || 'Om.wav'; open(IN, "<$file") or warn $!; while ( 4096 == read( IN, my $buffer, 4096 ) ) { $dsp->dwrite($buffer); } $dsp->close();
|
|---|