#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <stdio.h>
#include <linux/soundcard.h>
#include <termios.h>
#define RATE 16000
#define SIZE 16
#define CHANNELS 1
#define RSIZE 80
int main(void)
{
int fd_dev_r;
int fd_dev_w;
int fd_f;
int arg;
int status;
char choice;
int i;
unsigned char buf[RSIZE];
fd_dev_r= open("/dev/dsp", O_RDONLY,0777);
if (fd_dev_r < 0)
{
perror("Cannot open /dev/dsp device");
return 1;
}
arg = SIZE;
status = ioctl(fd_dev_r, SOUND_PCM_WRITE_BITS, &arg);
if (status == -1)
{
perror("Cannot set SOUND_PCM_WRITE_BITS ");
return 1;
}
arg = CHANNELS;
status = ioctl(fd_dev_r, SOUND_PCM_WRITE_CHANNELS, &arg);
if (status == -1)
{
perror("Cannot set SOUND_PCM_WRITE_CHANNELS");
return 1;
}
arg = RATE;
status = ioctl(fd_dev_r, SOUND_PCM_WRITE_RATE, &arg);
if (status == -1)
{
perror("Cannot set SOUND_PCM_WRITE_WRITE");
return 1;
}
fd_dev_w = open("/dev/dsp", O_WRONLY,0777