linux 播放声音文件程序代码
声音文件必须为Wave PCM unsigned 8bits mono格式
/* the *.wav must be 8000Hz 64kbps 8bits MONO(1)*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/soundcard.h> /*for OSS style sound programing */
#define BUFF_SIZE 512 /*buffer size:512 Bytes */
#define FMT8BITS AFMT_U8 /*unsigned 8 bits(for almost PC) */
#define FMT16BITS AFMT_S16_LE /*signed 16 bits,little endian */
#define FMT8K 8000 /*default sampling rate */
#define FMT11K 11025 /*11,22,44,48 are three pop rate */
#define FMT22K 22050
#define FMT44K 44100
#define FMT48K 48000
#define MONO 1
#define STEREO 2
int main(int argc, char *argv[])
{
if(argc!=2)
printf("input error! ./playvoice filename");
int fd; //for device
fd=open("/dev/dsp",O_WRONLY);
if (fd<0){
perror("Can't open /dev/dsp");
return -1;
}
int outfile;
outfile=open(argv[1],O_RDONLY);
if (outfile<0) {
perror("Cannot open file for writing");
return -1;
}
/* set bit format */
int bits = FMT16BITS;
if (ioctl(fd, SNDCTL_DSP_SETFMT, &bits) == -1) {
fprintf(stderr, "Set fmt to bit %d failed:%s\n", bits,
strerror(errno));
return (-1);
}
if (bits != FMT16BITS) {
fprintf(stderr, "do not support bit %d, supported 8、16\n", bits);
return (-1);
}
/*set channel */
int channel = MONO;
if ((ioctl(fd, SNDCTL_DSP_CHANNELS, &channel)) == -1) {
fprintf(stderr, "Set Au
相关文档:
1、Linux里查看所有用户
linux里,并没有像windows的net user,net localgroup这些方便的命令来治理用户.
Xwindows界面的就不说了.
(1)在终端里.其实只需要查看 /etc/passwd文件就行了.
(2)看第三个参数:500以上的,就是后面建的用户了.其它则为系统的用户.
或者用cat /etc/passwd |cut -f ......
一、安装
创建安装目录,在/usr/local/java下建立安装路径,并将文件考到该路径下:
# mkdir /usr/local/java
1、jdk-6u11-linux-i586.bin
这个是自解压的文件,在linux上安装如下:
# chmod 755 jdk-6u11-linux-i586.bin
# ./jdk-6u11-linux-i586.bin
在按提示输入yes后,jdk被解压。
......
从Ubuntu 8.04到9.10,我的Acer Aspire 4920本子的媒体触摸控制键始终不能正常工作。最近找到了此问题的解决方法,供使用Linux操作系统及拥有Acer笔记本的用户参考。 在Ubuntu 9.10下,我的媒体控制键被识别为另一块Synaptics触摸板,并且四个键分别被识别为上、下、左、右翻页键,导致无法正常工作。需要通过修改按键映射 ......