打印

AT89C51SND1C播放WAV文件的相关问题

[复制链接]
2944|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
黄发乾|  楼主 | 2008-2-16 18:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在AT89C51SND1C的datasheet中对音频部分有如下解释:
The data converter block converts the audio stream input from the 16-bit parallel format to a serial format. For accepting all PCM formats and I2S format, JUST4:0 bits in AUDCON0 register are used to shift the data output point. As shown in Figure 13-4, these bits allow MSB justification by setting JUST4:0 = 00000, LSB justification by setting JUST4:0 = 10000, I2S Justification by setting JUST4:0 = 00001, and more than 16-bit LSB justification by filling the low significant
bits with logic 0.

In voice or sound playing mode, the audio stream comes from the C51 core through an audio buffer. The data is in 8-bit format and is sampled at 8 kHz. The audio buffer adapts the sample format and rate. The sample format is extended to 16 bits by filling the LSB to 00h. Rate is adapted to the DAC rate by duplicating the data using DUP1:0 bits in AUDCON1 register according to Table 73.

The audio buffer interfaces to the C51 core through three flags: the sample request flag (SREQ in AUDSTA register), the under-run flag (UNDR in AUDSTA register) and the busy flag (AUBUSY in AUDSTA register). SREQ and UNDR can generate an interrupt request as explained in Section "Interrupt Request", page 76. The buffer size is 8 Bytes large. SREQ is set when the samples number switches from 4 to 3 and reset when the samples number switches from 4 to 5; UNDR is set when the buffer becomes empty signaling that the audio interface ran out of samples; and AUBUSY is set when the buffer is full.

问题1:audio buffer是16位的,如果WAV文件是按8位采样,扩展成16位,用程序实现,还是硬件自动完成?
问题2:16位数据是先写低8位还是先写高8位?
问题3:如何播放单声道wav文件?好像at89c51snd1c默认按双声道处理.
问题4:"DUP1:0"到底是什么意思?DAC的速度与此有什么关系?

相关帖子

沙发
huangqi412| | 2008-2-17 00:02 | 只看该作者

好象00有一个mp3例程的,你找下吧

使用特权

评论回复
板凳
黄发乾|  楼主 | 2008-2-17 08:49 | 只看该作者

AT89C51SND1C对wav与mp3的处理方式不同

不同之一:只有voice才有DUP1:0的设置,mp3没有这一项.

使用特权

评论回复
地板
黄发乾|  楼主 | 2008-2-17 16:24 | 只看该作者

AT89C51SND1C播放WAV文件应注意的三个问题!

调试结果总结如下:
1.若输出数据选择为I2S格式,必须保证数据按二进制补码编码.当WAV文件数据的采样位数为8位,由于8位的采样按无符号存储,采样值从0到255(00H-FFH),所以必须在原始数据基础上加上80H的偏移量,即采样值范围变为-128到127(80H-FFH),改成带符号数.当采样位数为16位,由WAV文件格式知,16位采样按带符号存储,不必另做处理.
2.若输出数据规定为16位,对于8位采样的WAV数据,必须自行在低8位填充0以扩展成要求的16位格式,audio buffer不会自动做这种处理.
3.写AUDDAT的字节顺序与DAC要求的顺序一致,对于I2S格式,高字节在先,低字节在后.

使用特权

评论回复
5
黄发乾|  楼主 | 2008-2-18 11:03 | 只看该作者

勘误“AT89C51SND1C播放WAV文件应注意的三个问题!”

仔细阅读AT89C51SND1C datasheet,结合调试结果,发现SND1C播放WAV文件在I2S数据格式条件下仅支持8位采样。如果我的这种说法错误,请批评指正。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3

主题

11

帖子

1

粉丝