Re: Recording /dev/dsp script output
AlgoMantra <algomantra <at> gmail.com>
2008-12-05 01:48:18 GMT
On Fri, Dec 5, 2008 at 12:24 AM, robs
<aquegg <at> yahoo.co.uk> wrote:
--- On Thu, 4/12/08, AlgoMantra <
algomantra <at> gmail.com> wrote:
> on Ubuntu 8.04. I want to record some of these suounds
> using
> sox, like...by feeding the output to sox instead of the
> speakers.
If your program can send its data to stdout, try something like:
your_program | sox -s -2 -c 1 -r 16000 -t raw - sounds.wav
Thanks....I tried this....but the program plays the sounds (i can hear it) and then exits
as usual, leaving an empty file called sounds.wav
Just to clarify what the program is doing, I'm pasting it below.....
----------------------------------------
#include <math.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/soundcard.h>
#include <stdio.h>
void doomsday(int day,unsigned short int foo[]);
int main(void) {
unsigned short int zap[44100];
int c; int out; int f=150;
out=open("/dev/dsp", O_WRONLY);
c=16;
ioctl(out, SOUND_PCM_WRITE_BITS, &c);
c=1;
ioctl(out,SOUND_PCM_WRITE_CHANNELS, &c);
c=44100;
ioctl(out,SOUND_PCM_WRITE_RATE, &c);
doomsday(f,zap);
for(c=0;c<4;c++){
write(out, zap, sizeof(zap));
}
close(out);
return c;
}
void doomsday(int day,unsigned short int foo[])
{
int n,m,z,c;
for (m=1;m<1471;m++){
c=0;
for(n=1;n<16;n=n++){
foo[m*n] = 10000*sin(day*2*M_PI*(m*n)/44100);
}
z=m*n;
for (n=16;n<30;n++){
foo[m*n] = foo[z-c];
c=c++;
}
}
}
----------------------------------------------------------------------------
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Sox-users mailing list
Sox-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users