In my project I have to get a numeric vector of audio signal wave from MP3 file. Using MATLAB and "audioread" function.
The code is very basic:
[x, Faudio] = audioread('patient01.MP3');
Here x is a desired waveform and Faudio - sample rate found by the function.
But there are different waveforms achieved from the same MP3 file when making this operation in Matlab installed in Windows and in Linux.
An exemplary MP3 file and two MAT figures of vector x from Linux and from Windows for comparison are attached by the link:
https://limewire.com/d/1aypP#Y5DPmXIw52
The waveform achieved in Linux is correct - it is a heart beat waveform and an HR values calculated from it, were verified by an external reference.
How can you explain it and what are your recommendations?
In Windows it was checked at different PCs with different Matlab releases - from 2022 to 2024. It is fully repeatable.
Since building a waveform is dependent on an accurate sample rate, I'm guessing that the discrepency is due to the limitations described in the documentation for audioread
(emphasis mine):
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.
I suggest creating a single WAV file and using that on both operating systems to see if there is still a difference. Depending on how you create the file you may experience a similar issue caused by an underlying framework, where the resulting form isn't an exact match to your target, but the result of audioread
should at least be the same on both systems at that point.