Zeugma440 / atldotnet

Fully managed, portable and easy-to-use C# library to read and edit audio data and metadata (tags) from various audio formats, playlists and CUE sheets
MIT License
440 stars 60 forks source link

Ambisonic bwav files cannot be written and don't throw an exception #247

Closed drunkenQCat closed 5 months ago

drunkenQCat commented 5 months ago

The problem

I recorded some wav file with Zoom h3 vr, When I want to edit its metadata, I found that nothing happened. So I tried to debug the code, I found that in file saving process, the stream of file thrown such Excption:

Handle = “((System.IO.FileStream)stream).Handle”caused Exception type “System.ObjectDisposedException”

Environment

Details

If necessary, describe the problem you have been experiencing in more detail. here is a file head of the ambisonics file:ambisonics file head.txt

Don't forget to include ATL.Logging.Log and/or console output ATL_LOG.log

Code To Reproduce Issue [ Good To Have ]

    public async Task WriteMetaData()
    {

        ATL.Logging.LogDelegator.SetLog(ref atlLog);
        atlLog.Register(Instance);
        Task WriteSingleBwf(FileInfo bwf, SlateLogItem item)
        {
            Track tr = new(bwf.FullName);
            var originalNote = "";
            try
            {
                originalNote = tr.AdditionalFields["ixml.Note"];
            }
            catch
            {
                originalNote = "";
            }

            var editedNote = item.scnNote + "," + item.shtNote + originalNote;
            WriteAdditional(tr, "ixml.SCENE", item.scn + "-" + item.sht);
            WriteAdditional(tr, "ixml.TAKE", item.tk.ToString());
            WriteAdditional(tr, "ixml.NOTE", editedNote);
            WriteAdditional(tr, "ixml.CIRCLED", (item.okTk == TkStatus.ok) ? "TRUE" : "FALSE");
            WriteAdditional(tr, "ixml.TAKE_TYPE", (item.okTk == TkStatus.bad) ? "NO_GOOD" : "DEFAULT");
            WriteAdditional(tr, "ixml.WILD_TRACK", (item.tkNote.Contains("wild")) ? "TRUE" : "FALSE");
            // WriteTrackList(tr, item.trackList);
            tr.Description = item.tkNote;
            tr.Title = item.shtNote;
            tr.Save();
            Console.WriteLine($"{tr.Path} loaded");
            return Task.CompletedTask;
        }

        List<Task> taskList = new();
        foreach (var item in LogList)
        {
            foreach (var bwf in item.bwfList)
            {
                taskList.Add(WriteSingleBwf(bwf, item));
            }
        }

        await Task.WhenAll(taskList);
    }
    void WriteAdditional(Track tr, string tag, string content)
    {
        if (tr.AdditionalFields.ContainsKey(tag)) tr.AdditionalFields[tag] = content;
        else tr.AdditionalFields.Add(tag, content);
    }

Please remember that with sample code it's easier to reproduce the bug and it's much faster to fix it.

Zeugma440 commented 5 months ago

Hi and thanks for your detailed feedback!

These files having extra information in their header shouldn't cause any issue.

According to the log, it looks like there's an encoding issue within the file you produced.

Could you please upload it using a 3rd party host (e.g. dropbox, mega) so that I can test it myself?

If you don't want to post it here you can send it to me using [my github username] at (hotmail) dot com

drunkenQCat commented 5 months ago

sure, I've uploaded it on google drive and sent the link by email. thx for your concerning.

Zeugma440 commented 5 months ago

Got it, thanks. Looks like I didn't anticipate iXML chunks to be padded with 0xFF bytes. Everything work fine now~

Zeugma440 commented 5 months ago

Fix is available in today's v5.17.

Please close the issue if it's OK on your side.

drunkenQCat commented 5 months ago

Marvelous~ it just works! sincerely thank you!