Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load mp3 correctly #33

Open
manuelpezzera opened this issue Mar 19, 2024 · 0 comments
Open

Unable to load mp3 correctly #33

manuelpezzera opened this issue Mar 19, 2024 · 0 comments

Comments

@manuelpezzera
Copy link

Hello,
I have a problem with loading a couple of mp3 files.
They are the same track, just exported with different parameters.

In track 1, the audio is extremely sped up and with a wrong length. In track 2, on the other hand, the audio is fine but the duration is wrong (it should be about 45 seconds instead it is almost 6 minutes).

The code I am using is as follows:
var mpgFile = new NLayer.MpegFile(path);
var samples = new float[mpgFile.Length];
mpgFile.ReadSamples(samples, 0, (int)mpgFile.Length);
clip = AudioClip.Create("clip-mp3", samples.Length, mpgFile.Channels, mpgFile.SampleRate, false);
clip.SetData(samples, 0);

I'm using Unity and the last two lines are for creating the audio clip, but I think the problem is earlier, in reading the samples.

Here are the two tracks: Tracks.zip

Thank you in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant