To:steve<br> 我刚刚注册到大富翁,以前我一直用同学(GanQuan)的账号;<br> 我用acm压缩语音的过程如下;<br><br> 说明: 我是先采集一段语音数据到what.bin文件,为方便起见,我直接用<br> 某个CODEC所支持的pcm格式采集,这样就不需要acmFormatSuggest了吧!<br> <br> 压缩过程:<br> HACMDRIVER hadforUse; <br> acmDriverOpen(&hadforUse, hadidUse, 0); <br> <br> acmStreamOpen(&hstr, <br> <br> hadforUse,<br> <br> pwfPcm, //与我的采集格式一样;<br><br> pwfDst, <br><br> NULL, <br><br> NULL,<br><br> 0, <br><br> ACM_STREAMOPENF_NONREALTIME);<br><br> <br> DWORD dwRes21Bytes=pwfPcm->nAvgBytesPerSec;<br><br> BYTE *pRes21Data=new BYTE[dwRes21Bytes];<br> <br> DWORD dwDst21Bytes = pwfDst->nAvgBytesPerSec;<br><br> dwDst21Bytes = dwDst21Bytes * 3 / 2;<br> <br> BYTE* pDst21Data = new BYTE [dwDst21Bytes]; <br> <br> FILE *fp1,*fp2;<br> fp1=fopen("what.bin","rb");<br> fp2=fopen("what1.bin","wb");<br> <br> //开始转换;<br> while(!feof(fp1))<br> {<br> <br> memset(pRes21Data,0,dwRes21Bytes); <br> memset(pDst21Data,0,dwDst21Bytes);<br> <br><br> fread(pRes21Data,1,dwRes21Bytes,fp1);<br> <br> ACMSTREAMHEADER strhdr; <br><br> memset(&strhdr, 0, sizeof(strhdr));<br><br> strhdr.cbStruct = sizeof(strhdr);<br><br> strhdr.pbSrc = pRes21Data; <br><br> strhdr.cbSrcLength =dwRes21Bytes;<br> <br> strhdr.pbDst = pDst21Data;<br><br> strhdr.cbDstLength = dwDst21Bytes; <br><br> acmStreamPrepareHeader(hstr, &strhdr, 0); <br><br> acmStreamConvert(hstr, &strhdr, 0); <br> <br> double f=((double)dwRes21Bytes)/((double)strhdr.cbDstLength); <br> <br> char buf5[100];<br> sprintf(buf5,"the ratio is %f",f);<br> AfxMessageBox(buf5);<br> <br><br> fwrite(pDst21Data,1,strhdr.cbDstLength,fp2);<br><br><br> acmStreamUnprepareHeader(hstr, &strhdr, 0); <br><br> }<br><br><br> acmStreamClose(hstr, 0);<br> <br><br> acmDriverClose(hadforUse, 0);<br> <br> fclose(fp1);<br> fclose(fp2);<br> fp1=NULL;<br> fp2=NULL;<br><br><br> delete pRes21Data;<br> delete pDst21Data;<br><br>