PCM data flow - 7 - Frame & Period

后面章节将分析 dma buffer 的管理,其中细节需要对音频数据相关概念有一定的了解。因此本章说明下音频数据中的几个重要概念:Sample:样本长度,音频数据最基本的单位,常见的有 8 位和 16 位;Channel:声道数,分为单声道 mono 和立体声 stereo;Frame:帧,构成一个完整的声音单元,Frame = Sample * channel;Rate:又称 sample
摘要由CSDN通过智能技术生成

后面章节将分析 dma buffer 的管理,其中细节需要对音频数据相关概念有一定的了解。因此本章说明下音频数据中的几个重要概念:

  • Sample:样本长度,音频数据最基本的单位,常见的有 8 位和 16 位;
  • Channel:声道数,分为单声道 mono 和立体声 stereo;
  • Frame:帧,构成一个完整的声音单元,Frame = Sample * channel
  • Rate:又称 sample rate,采样率,即每秒的采样次数,针对帧而言;
  • Period size:周期,每次硬件中断处理音频数据的帧数,对于音频设备的数据读写,以此为单位;
  • Buffer size:数据缓冲区大小,这里指 runtime 的 buffer size,而不是结构图 snd_pcm_hardware 中定义的 buffer_bytes_max;一般来说 buffer_size = period_size * period_count, period_count 相当于处理完一个 buffer 数据所需的硬件中断次数。

下面一张图直观的表示 buffer/period/frame/sample 之间的关系:
pcm_data_concept
这个 buffer 中有 16 个 period,每当 DMA 搬运完一个 period 的数据就会出生一次中断,因此搬运这个 buffer中的数据将产生 16 次中断。ALSA 为什么这样做?因为数据缓存区可能很大,一次传输可能会导致不可接受的延迟;为了解决这个问题,所以将缓存区拆分成多个周期 period,以周期 period 为单元传输数据。

7.1. Frames & Periods

敏感的读者会察觉到 period 和 buffer size 在 PCM 数据搬运中扮演着非常重要角色。下面引用两段来自 alsa 官网对 Period 的详细解释:
Period

The interval between interrupts from the hardware. This defines the input latency, since the CPU will not have any idea that there is data waiting until the audio interface interrupts it.
The audio interface has a “pointer” that marks the current position for read/write in its h/w buffer. The pointer circles around the buffer as long as the interface is running.
Typically, there are an integral number of periods per traversal of the h/w buffer, but not always. There is at least one card (ymfpci) that generates interrupts at a fixed rate indepedent of the buffer size (which can be changed), resulting in some “odd” effects compared to more traditional designs.
Note: h/w generally defines the interrupt in frames, though not always.
Alsa’s period size setting will affect how much work the CPU does. if you set the period size low, there will be more interrupts and the work that is done every interrupt will be done more often. So, if you don’t care about low latency, set the period size large as possible and you’ll have more CPU cycles for other things. The defaults that ALSA provides are in the middle of the range, typically.
(from an old AlsaDevel thread[1], quoting Paul Davis)
Retrieved from “

  • 9
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
PCM-CDMA-BPSK信号调制解调是一种常见的数字通信技术,它将PCM编码和CDMA多址接入技术与BPSK调制方式结合起来,实现了数据的传输和接收。下面我将介绍如何使用Matlab来实现PCM-CDMA-BPSK信号调制解调。 首先,我们需要使用Matlab编写PCM编码和CDMA多址接入技术的相关代码。PCM编码是将模拟信号转换为数字信号的过程,需要对信号进行采样、量化和编码。CDMA多址接入技术是一种通过码分多址技术来实现多用户间的并行传输的技术。我们可以编写Matlab代码来模拟PCM编码和CDMA多址接入技术的过程,并将其集成在一起。 其次,我们需要编写Matlab代码来实现BPSK调制。BPSK调制是一种基本的数字调制方式,它将二进制数字映射到正弦波和余弦波两个相位上。我们可以使用Matlab来生成BPSK调制信号,并将其与PCM编码和CDMA多址接入技术集成在一起。 最后,我们需要编写Matlab代码来实现PCM-CDMA-BPSK信号的解调过程。解调过程需要对接收到的信号进行解码、解扩和解调,最终得到原始的PCM编码信号。我们可以使用Matlab来模拟解调过程,并验证解调的准确性。 综上所述,我们可以使用Matlab来实现PCM-CDMA-BPSK信号调制解调。通过编写相关的Matlab代码,我们可以模拟整个信号调制解调过程,验证其正确性并进行性能分析。这样就可以在Matlab环境下方便地进行PCM-CDMA-BPSK信号调制解调的研究和开发工作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值