完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
在STM32上采集了有声音的和无声音的数据,经过压缩发现数据完全一样,没有压缩之前采集的数据不一样,用的是G711的压缩协议,有什么问题吗?程序有点看不懂,可否帮我解释一下,做好每句附上注释,嘿嘿!void ulaw_compress(lseg, linbuf, logbuf)
long lseg; short *linbuf; short *logbuf; { long n; /* samples's count */ short i; /* aux.var. */ short absno; /* absolute value of linear (input) sample */ short segno; /* segment (Table 2/G711, column 1) */ short low_nibble; /* low nibble of log companded sample */ short high_nibble; /* high nibble of log companded sample */ for (n = 0; n < lseg; n++) { /* -------------------------------------------------------------------- */ /* Change from 14 bit left justified to 14 bit right justified */ /* Compute absolute value; adjust for easy processing */ /* -------------------------------------------------------------------- */ absno = linbuf[n] < 0 /* compute 1's complement in case of */ ? ((~linbuf[n]) >> 2) + 33/* negative samples */ : ((linbuf[n]) >> 2) + 33;/* NB: 33 is the difference value */ /* between the thresholds for */ /* A-law and u-law. */ if (absno > (0x1FFF)) /* limitation to "absno" < 8192 */ absno = (0x1FFF); /* Determination of sample's segment */ i = absno >> 6; segno = 1; while (i != 0) { segno++; i >>= 1; } /* Mounting the high-nibble of the log-PCM sample */ high_nibble = (0x0008) - segno; /* Mounting the low-nibble of the log PCM sample */ low_nibble = (absno >> segno) /* right shift of mantissa and */ & (0x000F); /* masking away leading '1' */ low_nibble = (0x000F) - low_nibble; /* Joining the high-nibble and the low-nibble of the log PCM sample */ logbuf[n] = (high_nibble << 4) | low_nibble; /* Add sign bit */ if (linbuf[n] >= 0) logbuf[n] = logbuf[n] | (0x0080); } } 第二个问题是如何去判断语音的停顿呢?有声音和无声音如何区别,通过程序如何实现,查的一些资料说是通过声音的能量来判断,在数据里又是如何显示的呢? |
|
相关推荐 |
|
只有小组成员才能发言,加入小组>>
12131 浏览 2 评论
4466 浏览 3 评论
3696 浏览 5 评论
9524 浏览 47 评论
4499 浏览 9 评论
706浏览 0评论
507浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 08:53 , Processed in 0.537207 second(s), Total 104, Slave 83 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号