c - libsndfile 中框架和项目之间的区别?

标签 c audio-processing libsndfile

我正在编写一个处理音频文件的软件。我正在使用 libsndfile 库来读取 wave 文件数据,我遇到了一个他们的文档没有解决的疑问:读取项目的函数和读取帧的函数有什么区别?或者,换句话说,如果我交换 sf_read_shortsf_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/

相关文章:

c - Linux 读取 strace 记录的系统调用 - 如何理解指向缓冲区值的指针?

swift - 是否可以使用 Swift 的 AudioKit API 计算 MFCC 向量?

python - 准确地将两个音符相互混合

c - 无需查找即可写入的音频文件格式

java - libsox 或 libsndfile 是否有 javax.sound 接口(interface)?

c - 如何可视化内存中带有位域的 C 结构体的布局?

C:我不断收到错误消息:预期表达式

c - 在没有这个标志的系统上模拟 O_NOFOLLOW 的好方法是什么?

audio - XAudio2 遮挡处理

c - 音频延迟使其工作