本篇文章给大家谈谈c语言解码wav文件,以及如何解码wav文件对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
1、OC语言读取wav文件2、用C如何播放wav文件。。不用播放器。。3、怎样用c语言读取WAV文件振幅信息
OC语言读取wav文件
用AudioServicesPlaySystemSound进行播放,代码如下:(wav文件名为end.wav)
SystemSoundID ph;
id sndpath = [[NSBundle mainBundle]pathForResource:@”end” ofType:@”wav” inDirectory:@”/”];
CFURLRef baseUrl = (__bridge CFURLRef)[NSURL fileURLWithPath:sndpath];
AudioServicesCreateSystemSoundID(baseUrl, ph);
AudioServicesPlaySystemSound(ph);
用C如何播放wav文件。。不用播放器。。
在网页制作中加入以下代码就可以播放文件。
BGSOUND
balance=0
loop=infinite
src=”(文件路径)*.wav”
volume=0
在C语言中我没试过,查了一下,要调用API函数sndplay或者playsound
怎样用c语言读取WAV文件振幅信息
C也能像matlab一样读取wav格式文件!
用外置库libsndfile,可以读取数据,频率,通道等等
以下是一段读取sample.wav,将数据存入double格式的array:
#include “sndfile.h”
#pragma comment(lib, “libsndfile-1.lib”)
void readwav(double output[length]){
SNDFILE *sf;
SF_INFO info;
int num_channels;
int num, num_items;
double *buf;
int f,sr,c;
int i,j;
info.format = 0;
sf = sf_open(“sample.wav”,SFM_READ,info);
if (sf == NULL){
printf(“Failed to open the file.\n”);
exit(-1);
}
f = info.frames;
sr = info.samplerate;
c = info.channels;
printf(“frames=%d\n”,f);
printf(“samplerate=%d\n”,sr);
printf(“channels=%d\n”,c);
num_items = f*c;
printf(“num_items=%d\n”,num_items);
buf = (double *)malloc(num_items*sizeof(double));
num = sf_read_double(sf,buf,num_items);
sf_close(sf);
printf(“Read %d items\n”,num);
for (i = 0; i num; i += c){
for (j = 0; j c; ++j){
if ((i+j)length) {
output[i+j] = buf[i+j];
}
}
}
}
c语言解码wav文件的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于如何解码wav文件、c语言解码wav文件的信息别忘了在本站进行查找喔。