- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
PCM编解码器
#includestdio.h
#includeiomanip.h
#includemath.h
#includetime.h
#includefstream.h
#includeiostream.h
int code1[9];
int code2[8];
int s[8];
void main()
{
void dlm(int n);
void dnm(int x,int m,int n);
int ipre(int x,int y[8]);
void jiema1();
void jiema2();
long int c,temp;
int x;
time_t Nowtime;
Nowtime=time(0);
for(int j=0;j5;j++)
{
for(int i=0;i8;i++)
{
temp=cos(Nowtime+i/10.0)*128*16;
if(temp0)
code1[0]=1;
else {code1[0]=0;temp=fabs(temp);}
if(temp=0 temp16) {dlm(0);dnm(temp,0,1);}
if(temp=16 temp32) {dlm(1);dnm(temp,16,1);}
if(temp=32 temp64) {dlm(2);dnm(temp,32,2);}
if(temp=64 temp128) {dlm(3);dnm(temp,64,4);}
if(temp=128 temp256) {dlm(4);dnm(temp,128,8);}
if(temp=256 temp512) {dlm(5);dnm(temp,256,16);}
if(temp=512 temp1024) {dlm(6);dnm(temp,512,32);}
if(temp=1024 temp2048) {dlm(7);dnm(temp,1024,64);}
for(int j=0;j8;j++)
{
printf(%d,code1[j]);
}
printf(\n);
ofstream fout(bianma.txt,ios::app); //写出编码到bianma.txt
for(j=0;j8;j++)
{
foutcode1[j];
}
foutendl;
ofstream fout1(out.txt,ios::app); //写出完整编码结果到out.txt
fout1系统时间:Nowtime 量化值:setw(10)cos(Nowtime+i/8.0)*128*16 编码:;
for(j=0;j8;j++)
{
fout1code1[j];
}
fout1endl;
}
Nowtime++;
}
printf(\n~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~\n\n);
printf(从键盘输入编码请按: 1\n从文件读取编码请按: 2\n);
scanf(%d,x);
if(x==1)
jiema2();
else
jiema1();
printf(\n----此程序1秒钟取10份,若想取8000份可自行更改----\n\n);
}
void dlm(int n) //段落码
{
switch(n)
{
case 0:code1[1]=0;code1[2]=0;code1[3]=0;break;
case 1:code1[1]=0;code1[2]=0;code1[3]=1;break;
case 2:code1[1]=0;code1[2]=1;code1[3]=0;break;
case 3:code1[1]=0;code1[2]=1;code1[3]=1;break;
case 4:code1[1]=1;code1[2]=0;code1[3]=0;break;
case 5:code1[1]=1;code1[2]=0;code1[3]=1;break;
case 6:code1[1]=1;code1[2]=1;code1[3]=0;break;
文档评论(0)