我正在编写一个处理音频文件的软件。我正在使用 libsndfile 库来读取 wave 文件数据,我遇到了一个他们的文档没有解决的疑问:读取项目的函数和读取帧的函数有什么区别?或者,换句话说,如果我交换 sf_read_short
和 sf_readf_short
是否会得到相同的结果?
我在一些问题中读到一个音频帧等于一个样本,所以我认为 libsndfile 调用的项目可能是同一件事。在我的测试中,它们似乎是一样的。
最佳答案
我也很担心,找到了答案。
Q12 : I'm looking at sf_read*. What are items? What are frames?
An item is a single sample of the data type you are reading; ie a single short value for sf_read_short or a single float for sf_read_float. For a sound file with only one channel, a frame is the same as a item (ie a single sample) while for multi channel sound files, a single frame contains a single item for each channel.
Here are two simple, correct examples, both of which are assumed to be working on a stereo file, first using items:
#define CHANNELS 2 short data [CHANNELS * 100] ; sf_count items_read = sf_read_short (file, data, 200) ; assert (items_read == 200) ;
and now readng the exact same amount of data using frames:
#define CHANNELS 2 short data [CHANNELS * 100] ; sf_count frames_read = sf_readf_short (file, data, 100) ; assert (frames_read == 100) ;
这是复制粘贴自: libsndfile FAQ , 第 12 题。
关于c - libsndfile 中框架和项目之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22889766/