Skip to content

Conversation

eugeneYz
Copy link

NAudio音频库录制的16k音频的 SubChunk1Size = 18 ,导致Line49报错
Console.WriteLine($"Invalid SubChunk1Size: {SubChunk1Size}. Expect 16");
此行改为
if (SubChunk1Size != 16 && SubChunk1Size != 18)

然后将 SkipMetaData方法改为如下,即可取出音频数据:

    private void SkipMetaData(BinaryReader reader)
    {
        var bs = reader.BaseStream;

        Int32 subChunk2ID = _header.SubChunk2ID;
        Int32 subChunk1Size = _header.SubChunk1Size;
        Int32 subChunk2Size = _header.SubChunk2Size;
        if (subChunk1Size == 16)
        {
            while (bs.Position != bs.Length && subChunk2ID != 0x61746164)
            {
                bs.Seek(subChunk2Size, SeekOrigin.Current);
                subChunk2ID = reader.ReadInt32();
                subChunk2Size = reader.ReadInt32();
            }
            _header.SubChunk2ID = subChunk2ID;
            _header.SubChunk2Size = subChunk2Size;
        }
        else
        {

                subChunk2Size = (int)(bs.Length - bs.Position);
            
        }

        _header.SubChunk2ID = subChunk2ID;
        _header.SubChunk2Size = subChunk2Size;
    }

@csukuangfj
Copy link
Collaborator

Looks like you have uploaded encrypted files. Could you fix that?

@csukuangfj
Copy link
Collaborator

@eugeneYz

@eugeneYz
Copy link
Author

Looks like you have uploaded encrypted files. Could you fix that?
Sorry about that,It seems that these codes can be only added manually.

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

Successfully merging this pull request may close these issues.

2 participants