Audio Werkzeuge Bibliothek (AWB)
Read and write meta tags (like artist, title, album, genre, ...) from many different audio formats, and gather information about the audio file (like duration, bitrate, samplerate). AudioWerkzeugeBibliothek comes with a very simple usage for basic information, but it also contains powerful features for an in-depth access to almost all kind of meta data.
Note: "Audio Werkzeuge Bibliothek" translates to "Audio Tools Library", which is a collection of classes with the same purpose. Although the AWB uses some parts of the ATL, this is not an official successor.
Also on Github, AudioWerkzeugeBibliothek on Github.
Features
Supported Tag formats
- ID3Tag, Version 1 and 1.1 (mp3, ape, mpc, ofr, tta, wv)
- ID3Tag, Version 2.2, 2.3 and 2.4 (mp3)
- Apev2Tags (mp3, ape, mpc, ofr, tta, wv)
- Vorbis Comments (ogg, flac, opus)
- QuickTime Metadata (mp4, m4a)
- WindowsMediaAudio (wma, read-only)
Additional features
- Read and write cover art in ID3v2, Apev2, Flac, Vorbis
- Detect duration, samplerate, bitrate and channels in the following file types:
Mp3, Ogg-Vorbis (*.ogg), Flac (*.flac), Monkeys Audio (*.ape), Musepack (*.mpc), Wavpack (*.wv), OptimFrog (*.ofr), True Audio (*.tta), Windows Media Audio (*.wma), Wave files (*.wav) - Full Uniode support (in Delphi 2007 and earlier TNT Unicode Controls are needed for Unicode filenames, see config.inc)
- Wide Tag support, e.g. Lyrics and "Private Frames" in ID3v2, direct access to ID3v2-Frames, access to arbitrary values in Ogg-Vorbis and Apev2. If you want to store a mp3-file inside the Apev2tag of an OptimFrog-file, you can do it with the methods in these classes. It is probably not a good idea, but it is possible...
Overview
For beginners, the usage of this library is super easy. Just use the factory to create an object of type TBaseAudioFile
to display some of the properties, let the user edit some of the values and update the file. Thats all. Works on all supported file formats - mp3, ogg, flac, m4a, it doesn't matter. Same code for all.
var
MainAudioFile: TBaseAudioFile;
// ...
MainAudioFile := AudioFileFactory.CreateAudioFile(aFileName);
MainAudioFile.ReadFromFile(aFileName);
EditTitle.Text := MainAudioFile.Title;
// ... und zum Bearbeiten
MainAudioFile.Title := EditTitle.Text;
MainAudioFile.UpdateFile;
If the named properties provided (such as artist, title and others) are not sufficient, there is the AudioFile.GetTagList method (new in version 3 of this library). This allows you to list and edit all data elements in a file.
lvMetaTags.Clear; // a ListView on the Form
TagItems := TTagItemList.Create;
try
MainAudioFile.GetTagList(TagItems);
for i := 0 to TagItems.Count - 1 do begin
newListItem := lvMetaTags.Items.Add;
newListItem.Data := TagItems[i];
newListItem.Caption := cTagTypes[TagItems[i].TagType];
newListItem.SubItems.Add(TagItems[i].Key);
newListItem.SubItems.Add(TagItems[i].Description);
newListItem.SubItems.Add(TagItems[i].GetText(tmReasonable));
end;
finally
TagItems.Free;
end;
To edit an element from this list, you can use the following code:
editItem := TTagItem(lvMetaTags.Selected.Data);
editValue := editItem.GetText(tmReasonable);
if InputQuery('Edit Item', 'New value:', editValue) then begin
if editValue = '' then
MainAudioFile.DeleteTagItem(editItem)
else
TTagItem(editItem).SetText(editValue, tmReasonable);
end;
Most metadata container allow more than one picture, aka "Cover Art". If you want to display the cover art, you need to get a list of all picture tag items first. However, in most cases, there is only one image embedded into the metadata. You can display it with a few lines of code.
var
stream: TMemoryStream;
Mime: AnsiString;
PicType: TPictureType;
Description: UnicodeString
// ...
stream := TMemoryStream.Create;
try
if MainAudioFile.GetPicture(stream, Mime, PicType, Description) then begin
Stream.Position := 0;
// Modern versions of Delphi also recognize the graphic type when using LoadFromStream
// For older versions, you may have to adapt the code depending on the mimetype.
Image1.Picture.LoadFromStream(Stream);
end;
finally
stream.Free;
end;
For further details and features, please refer to the included demo projects or the readme on Github.
Lizenz
LGPL or MPL.
The Audio Werkzeuge Bibliothek (AWB) contains parts of the Audio Tools Library (ATL). This is covered only under the terms of the LGPL. As I personally want to allow the usage of the AWB in closed source software, I tried to contact the developers of the ATL for permission to relicense this under a dual license scheme. I've got no answer.
As the ATL project seems to be dead for a couple of years, the used parts from the ATL are not that large (mostly getting audio data from the more exotic formats), I decided to distribute the AWB under my preferred dual license scheme without expicit permission from the ATL team. Dear ATL-developers: I hope, this is OK for you...