首页 > 编程知识 正文

pcm编码怎么计算,pcm编译码的特性

时间:2023-05-03 05:09:24 阅读:166656 作者:2802

PCM编码过程:符号位、段落代码、段落内代码。 符号简单,段内编码成为自由的耳机后,可以自己看到段内编码的下图! [段内码对照表] (https://img-blog.csdn img.cn/20200813143627759.png? x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10, text _ a hr0 CHM6ly9ibg9nlmnzzg 4u bmv0L3 dlaazg t _ 70 # pic _ center (importnumpyasnpdefpcm _ encode ) x ) :# )全部包含在int项中的无错误处理x=list(x ) n=len(x ) x ) for i in range(n ) n ) :try:x(I )=int (x ) I ) )输入except :打印'数字s () n,8 ) )输出for i in range(n ) n ) : #符号位ifx ) I ) 0:out ) I,0 )=0)建立段落位ifABS(x(I ) 0,0,1,0 elif ABS ) ) ) step,home=0,0,1,1,16 elif ABS [ x [ I ] ] 64: out[i,1],out [ I,2],oout ) 64elifABS[x[I]]2563360out[i,1]、out[i,2]、out 128elifABS(x[I] ) 512: out[i,1]、out [ I ] 0,1,16,256 step,home=1,1,0,32,512 else : out[i,1],out[i,2],out [ I,3],step,home=1,1 1024 #段内部代码sub=int(ABS(x(I )- home )自由耳机_str=自由耳机(int ) sub/step ) ) 2: ) RES=[ 0,0,0, 0]#尤其重要。防止在编码过程中由于长度不够而导致的-1错误的免for now in的耳机_str:RES.append(now ) mylen=len ) RES ) out(I,4 ) int ) RES[mylen-2],int(RES[mylen-1] ) #print(step,' **** ) (sub,' **** ) ) ) )7# # type ) out ) ) out ) return out PCM解码import numpy as np#解码处理defPCM_decode ) ins ) 336666 1) forIinrange(n ) 333666==1:sign=1else3360sign=-1#段落位确定if ins [ I ] [1]==0: if==0: step,home=2 1,0 else : step,home=32else3360step,home=2,32 else 360 step 64 elif ins [ I ]==0: if ins [ I ] [3]==03360 step,home=8,128 else 360 home=64,1024 #段内码new code=[ ins [ I ] [4] *8ins [ I ] [5] *4ins [ I ] [6] *2ins [ I ] [7]

结果如下。

code=PCM_encode(['1522 ',25] ) class ' list ' class ' numpy.nd array ' [1.1.1.1.1.0.1.1] ) 1

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。