⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 record.c

📁 s3c2410IIS总线实验代码 实现录音以及放音功能
💻 C
字号:
#include<unistd.h>#include<fcntl.h>#include<sys/types.h>#include<sys/ioctl.h>#include<stdlib.h>#include<stdio.h>#include<linux/soundcard.h>#define RATE 44000#define SIZE 16#define CHANNELS 1int main(int argc,char * argv[]){	int fd,id;	int arg;	int status;	char buf[1024];	if((id = open(argv[1],O_RDWR | O_CREAT)) < 0)	{		printf("Can't open output file!\n");		exit (1);	}	if ((fd = open("/dev/dsp",O_RDONLY)) < 0)	{		printf("open of /dev/dsp failed");		exit(1);	}	arg = SIZE;	status = ioctl(fd,SOUND_PCM_WRITE_BITS,&arg);	if(status == -1)		printf("SOUND_PCM_WRITE_BITS ioctl failed");	if(arg != SIZE)		printf("unable to set sample size");		arg = CHANNELS; 	status = ioctl(fd,SOUND_PCM_WRITE_CHANNELS,&arg);	if(status == -1)		printf("SOUND_PCM_WRITE_CHANNELS ioctl failed");	if(arg != CHANNELS)		printf("unable to set number of channels");		arg = RATE;	status = ioctl(fd,SOUND_PCM_WRITE_RATE,&arg);	if(status == -1)		printf("SOUND_PCM_WRITE_WRITE ioctl failed");	printf("Say something:\n");	while(1)	{		read(fd,buf,sizeof(buf));		write(id,buf,sizeof(buf));	}	close(id);	close(fd);	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -