Linux环境下用c语言写的播放wav文件的小程序
#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 11025
#define SIZE 16
#define CHANNELS
2 // 1表示单声道,2为立体声
/* ................ */
unsigned char
buf[RATE*SIZE/8]; //buf里面正好放一秒钟的音频,下面的计时还要用
int main()
{
int fd;
int wavfd; //wav文件的描述符
int arg; /* ..ioctl..... */
int status; /*
........ */
/* ...... */
fd = open("/dev/dsp",
O_RDWR);
if (fd < 0) {
printf("open of /dev/dsp failed");
exit(1);
}
wavfd = open("a.wav",O_RDONLY);
if (wavfd
< 0) {
printf("open of wav failed");
exit(1);
}
/* .......... */
arg = SIZE;
status = ioctl(fd,
SOUND_PCM_WRITE_BITS, &arg);
if (status == -1)
perror("SOUND_PCM_WRITE_BITS ioctl failed");
if (arg != SIZE)
perror("unable to set sample size");
/* .......... */
arg = CHANNELS;
status = ioctl(fd,
SOUND_PCM_WRITE_CHANNELS, &arg);
if (status == -1)
&nb
相关文档:
linux目录架构
/ 根目录
/bin 常用的命令 binary file 的目錄
/boot 存放系统启动时必须读取的档案,包括核心 (kernel) 在内
/boot/grub/menu.lst GRUB设置
/boot/vmlinuz 内核
......
MS 5.0 LINUX 版小集群并行安装手记
MS 5.0 LINUX 版小集群并行安装手记
这几天重新配置了一下计算环境,顺便记录下来供同行参考,这次以安装MS5.0为例,实际上4.0,4.2,4.4的版本这几天我都配置过了,方法基本相同。
1.操作系统环境说明
客户端要求是Windows XP Professional - SP3或Vista (Business & Enterpris ......
(一)中文字体的显示
(首先)用setup命令 开启“setup”对话框 --- 选择“service setup” 把“xfs” disable掉。
然后接下来:
(1)copy "c:/windows/fonts/simsun.ttc" to Linux directory : "/usr/share/fonts/liberation"
(2)edit "/etc/sysconfig/i1 ......
星际译王的安装
“星际译王”是用Gtk2开发的跨平台的国际化的词典软件。它具有“通配符匹配”、“选中区取词”、“模糊查询”等强大功能。本文主要解说一下主程序和词库的安装;
一、什么 ......
权限与文件系统安全
1,“ls -l”命令输出结果中各字段含义:
(1),文件类型,第1位(“-”普通文件、“d”目录文件、“l”符号链接文件、“b”快设备文件、“c”字符设备文件、“p”管道文件、“s”socket文件)
(2),权限,第2至10位( ......