Author Topic: Cart Chunk Tags Exception  (Read 530 times)

Chris Reeve

  • Guest
Cart Chunk Tags Exception
« on: 3 Nov '23 - 12:28 »
Hi All,

i've got some code to read cart chunk tags:

Code: [Select]
    Bass.Init();
    // var stream = Bass.CreateStream(@"C:\Powershell\2 Unlimited - Maximum Overdrive.wav");
    var stream = Bass.CreateStream(@"C:\Powershell\MYR10569.wav");   

    IntPtr tagpointer= Bass.ChannelGetTags(stream, TagType.RiffCart);       
    //IntPtr tagpointer = Bass.ChannelGetTags(stream, TagType.RiffCart);

   
        if (tagpointer != IntPtr.Zero)
        {
        CartTag cart = (CartTag)Marshal.PtrToStructure(tagpointer, typeof(CartTag));
   
        string tagText=cart.Artist;
        Console.WriteLine($"Artist: {tagText}");
        }

This works for a new file to which i've added a 2048 byte cart chunk data, but for a big set of my existing wavs,  i get an exception error when i process them.

Code: [Select]
CartTag cart = (CartTag)Marshal.PtrToStructure(tagpointer, typeof(CartTag));
Exception has occurred: CLR/System.ExecutionEngineException
An unhandled exception of type 'System.ExecutionEngineException' occurred in System.Private.CoreLib.dll
<Cannot evaluate the exception stack trace>

I think this is because something in my wav file isn't of the correct format (although they work elsewhere), or the cartchunk is too long for bass (12k)

Ian @ un4seen

  • Administrator
  • Posts: 25614
Re: Cart Chunk Tags Exception
« Reply #1 on: 3 Nov '23 - 13:03 »
Please upload (or link) an affected WAV file to have a look at here:

   ftp.un4seen.com/incoming/

Also confirm that "CartTag" is defined identically to the TAG_CART struct in the BASS.H file.

Chris Reeve

  • Guest
Re: Cart Chunk Tags Exception
« Reply #2 on: 3 Nov '23 - 15:02 »
I've updated the file - i'll check the structure.

Thanks

Ian @ un4seen

  • Administrator
  • Posts: 25614
Re: Cart Chunk Tags Exception
« Reply #3 on: 3 Nov '23 - 16:33 »
The uploaded file looks fine, so hopefully you can find an explanation for the problem in the CartTag stuff. I think the most likely place for issues is in processing of the variable-length "TagText" field. That contains a null-terminated string, so you should stop reading at the first null (0) character you find in it.

radio42

  • Posts: 4833
Re: Cart Chunk Tags Exception
« Reply #4 on: 4 Nov '23 - 11:20 »
When using Bass.Net you might directly use the BASS_TAG_GetFromFile method.
It also contains a BASS_TAG_CART struct.

Chris Reeve

  • Guest
Re: Cart Chunk Tags Exception
« Reply #5 on: 4 Nov '23 - 13:01 »
Thanks for your pointers. I've taken another look this morning..

I've tracked the issue down to the PostTimer Section. In two that are identical, I can take a non-working file and set the bytes for this section to 0, and the code works.

I'm now working out whether the timer names make a differences to how this code is processed or not.