gpt4 book ai didi

matlab - Audioread 和 Audioinfo 返回不同数量的总样本?

转载 作者:行者123 更新时间:2023-12-02 22:52:40 26 4
gpt4 key购买 nike

我在尝试在 MATLAB 中读取信号时遇到了一个小问题。
audioread函数将音频文件转换为其单独的样本。audioinfo函数检查音频文件并返回与信号相关的信息。

代码片段如下。

clear all;

%Read in the song
mySong = audioread('IowaFightSong.mp3');
%Get some information about the song
info = audioinfo('IowaFightSong.mp3')

我希望这两个函数具有相同数量的样本,但它们略有不同。
audioread返回一个长度为 3,043,056 的数组 audioinfo TotalSamples 值为 3,043,582

这 2 个值相差 526 个样本。

当我改为使用 MATLAB 的示例音频文件之一运行代码时
clear all

load handel.mat
audiowrite('handel.wav',y,Fs)

info = audioinfo('handel.wav')

y = audioread('handel.wav');
audioreadaudioinfo有相同的总样本,73,113。

我想知道是否有人可以解释这两个函数之间总样本的差异?

一个简单的解决方法是
clear all;

%Read in the song
mySong = audioread('IowaFightSong.mp3');
%Get some information about the song
info = audioinfo('IowaFightSong.mp3')

info.TotalSamples = length(mySong)
info.Duration = info.TotalSamples/info.SampleRate

最佳答案

limitations section对于 audioinfo说:

For MP3 and MPEG-4 AAC audio files on Windows 7 or later and Linux platforms, audioinfo might report fewer samples than expected. On Linux platforms, this is due to a limitation in the underlying GStreamer framework.



limitations section对于 audioread说:

For MP3, MPEG-4 AAC, and AVI audio files on Windows 7 or later and Linux platforms, audioread might read fewer samples than expected. On Windows 7 platforms, this is due to a limitation in the underlying Media Foundation framework. On Linux platforms, this is due to a limitation in the underlying GStreamer framework. If you require sample-accurate reading, work with WAV or FLAC files.



基本上,两者的 MP3 文件样本报告不准确,而 WAV 文件则没有,这就是 MATLAB 样本音频文件没有问题的原因。如建议的那样,如果准确的样本计数至关重要,您可能应该使用不同的格式。

关于matlab - Audioread 和 Audioinfo 返回不同数量的总样本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59143910/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com