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
460 stars 61 forks source link

Cannot update wav metadata tags (riff_info) on windows 11 #238

Closed andurshakur closed 9 months ago

andurshakur commented 9 months ago

I am using version 5.12 of ATL on windows 11 and i am trying to update artist, title and album of a large number of tracks. It works very smoothly for flac files when using the code below but wav files does not get updated There are no exceptions raised i use the following code:

private static void SetTrackMusicProperties(ref Model.Track track)
{
    try
    {
        ATL.Track trackProperties = new ATL.Track(track.Drive + track.Location);
        trackProperties.Artist = track.Artist;
        trackProperties.Title = track.Title;
        trackProperties.Album = track.Artist;
        trackProperties.Save();        
    }
    catch (Exception e)
    {

        throw;
    }
}
nlogozzo commented 9 months ago

Could you upload the wav file here or provide a link to it?

andurshakur commented 9 months ago

i cannot upload wav files here but an example can be grabbed from here:

https://mega.nz/file/1YNUjCYJ#-8e0SeiuRM4aOEARYTSZi7LZY-6vpD-2LmWTTXUGk2o

it happens with all my wave files

Zeugma440 commented 9 months ago

I have no issue when tagging the WAV file you provided.

Have you tried enabling the ATL logger by calling new ConsoleLogger()?

andurshakur commented 9 months ago

great news! then i just need to sort out what my local issue is

i cant seem to find any logging options in atl itself in the debug window i do see this exception: Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll however it doesnt get caught in my try/catch and not 100% sure its related

edit: i found this code snippet in the docs (must have scrolled past it before) Receiving ATL logs in your app and i am seeing these log items come through

The process cannot access the file 'D:\tmp\mental\Alien Mental - Asio.wav' because it is being used by another process.

followed by

at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at ATL.AudioData.AudioDataManager.UpdateTagInFile(TagData theTag, TagType tagType, ProgressManager writeProgress)

the only way i am "touching" the files before are with Directory.GetFiles() and FileInfo could they be locking the file?

andurshakur commented 9 months ago

ok so apparently FileInfo DOES lock files until disposed so got a step further but it still doesnt seem to tag as expected i get this output now:

======================================== Found 1 regions

0 : 4->74659580(71,2 MB) IsBufferable = True

======================================== ------------ REGION 0 ------ ZONE id3 @74659580 Allocating 0 B newTagSize : 0 B

DONE

Found 1 regions

0 : 4->74659580(71,2 MB) IsBufferable = True

======================================== ------------ REGION 0 Buffering 71,2 MB ------ ZONE bext@74659580 Allocating 0 B newTagSize : 0 B ------ ZONE cue @74659580 Allocating 0 B newTagSize : 0 B ------ ZONE disp.0@74659580 Allocating 0 B newTagSize : 0 B ------ ZONE iXML@74659580 Allocating 0 B newTagSize : 0 B ------ ZONE LIST.adtl@74659580 Allocating 0 B newTagSize : 0 B ------ ZONE LIST.INFO@74659580 Allocating 0 B newTagSize : 0 B ------ ZONE smpl@74659580 Allocating 0 B newTagSize : 0 B

DONE

andurshakur commented 9 months ago

ok it actually works as expected now so the culprit was FileInfo! thank you very much for a great library and for your time! <3

andurshakur commented 9 months ago

"fun" sidenote is that apparently FileInfo does release filelocks on flac files before disposing of the fileinfo object (since it worked fine with all flac files from the beginning)