4

I am learning about the AIFF format and according to wiki these files can contain an ID3 chunk. But most of tools I have tried so far do not seem to support aiff files. Are there any libraries (preferably java or C#) capable of parsing/reading ID3 chunks within aiff files?

Leigh
  • 28,765
  • 10
  • 55
  • 103

3 Answers3

2

Taglib# will do this. It's a .NET wrapped version of the taglib library (which supports reading AIFF tags). It's maintained by the developers of the Banshee Media Player:

http://download.banshee.fm/taglib-sharp/

If you want to read more on Taglib in general, here's the TagLib site: http://developer.kde.org/~wheeler/taglib.html

I took a file in iTunes, converted it to AIFF, placed it in my root C:\ folder and renamed it to Sample.aif. Here's the code I used to read it:

TagLib.File file = TagLib.File.Create(@"C:\Sample.aif");
string album = file.Tag.Album;
string title = file.Tag.Title;

Seems to work just fine, TagLib reports that it is an ID3v2 tag.

JacobJ
  • 3,677
  • 3
  • 28
  • 32
  • Silly question, any idea how it reads AIFF files? TagLib.File.Create("c:/myFile.auiff") throws an `UnsupportedFormatException`. – Leigh Jul 23 '11 at 19:08
  • @Leigh - do you know how that file was created? I'm not familiar with an "auiff" extension and I suspect there is something funky about that file. If you can provide a way of testing these files, I can reflect through TagLib#'s code and see where it is failing and throwing that exception. – JacobJ Jul 23 '11 at 19:57
  • Sorry, the "u" was a typo. It is just a regular "*.aiff" file. I had tried renaming to ".aif", but no luck. I will see if I can figure out how to register the mime type. – Leigh Jul 23 '11 at 20:03
  • Try this instead: "TagLib.File file = TagLib.File.Create(@"C:\Sample.auiff", "audio/x-aiff", TagLib.ReadStyle.None);" - that forces it to read it as a AIFF. – JacobJ Jul 23 '11 at 20:10
  • Here's the code for where you're getting the exception if it helps you at all: http://taglib-sharp.sourcearchive.com/documentation/2.0.3.7plus-pdfsg-1build1/classTagLib_1_1File_adc6efe9d12a7509c96083b6fb42a51ee.html#adc6efe9d12a7509c96083b6fb42a51ee – JacobJ Jul 23 '11 at 20:14
  • Yes, now I get an exception: {"The type initializer for 'TagLib.FileTypes' threw an exception."}. Maybe I scrambled something. – Leigh Jul 23 '11 at 20:23
  • Yes, I definitely am. The test I did was to take a file from iTunes (an MP3 or AAC file) and use iTunes to convert it to an AIFF (use "Import Settings" on the General tab of the config dialog). iTunes will take the file and save it as an AIFF with ID3 tags. I used that file to test reading AIFF tags with taglib. – JacobJ Jul 23 '11 at 20:46
  • @Leigh let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/1768/discussion-between-jacobj-and-leigh) – JacobJ Jul 23 '11 at 20:47
  • The library is working perfectly. Thanks! The mistakes were on my side. Bounty to be awarded as soon as SO lets me ;) – Leigh Jul 24 '11 at 01:20
  • 1
    For the record, TagLib# is a port, not a wrapper. Is .aiff the default extention for AIFF files in iTunes? If so, it should be added to TagLib#'s file type detection code. – Brian Nickel Jul 29 '11 at 22:10
0

not sure but did you try http://www.codeproject.com/KB/cs/Do_Anything_With_ID3.aspx

Yahia
  • 69,653
  • 9
  • 115
  • 144
0

Look at this link. This is from naudio. From what I could see on my mobile's small screen, it seems it may help you.

https://naudio.svn.codeplex.com/svn/NAudio/Wave/WaveStreams/AiffFileReader.cs

Vijay Gill
  • 1,508
  • 1
  • 14
  • 16
  • Thanks, but I do not see anything that specifically pertains to the ID3 chunk. Did I miss something? – Leigh Jul 21 '11 at 23:16
  • I am sure I saw some method in there to read header of the file. May be my brain is fried by now. Sorry if I created unwanted noise. – Vijay Gill Jul 21 '11 at 23:24
  • Okay. I will have another look around later when my brain is fresher. – Leigh Jul 21 '11 at 23:41