Skip to content

Unable to load mp3 correctly #33

Open
@manuelpezzera

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions