BASS.NET API for the Un4seen BASS Audio LibraryBassBASS_ChannelGetTags Method BASS.NET API for the Un4seen BASS Audio Library
Retrieves the requested tags/headers from a channel, if they are available.

Namespace: Un4seen.Bass
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.12.0
Syntax

[DllImportAttribute("bass.dll", CharSet = CharSet.Unicode)]
public static IntPtr BASS_ChannelGetTags(
	int handle,
	BASSTag tags
)

Parameters

handle
Type: SystemInt32
The channel handle...a HMUSIC or HSTREAM.
tags
Type: Un4seen.BassBASSTag
The tags/headers wanted... one of the following (see BASSTag):
BASS_TAG_ID3ID3v1 tags. A pointer to a 128 byte block is returned. See www.id3.org for details of the block's structure.
BASS_TAG_ID3V2ID3v2 tags. A pointer to a variable length block is returned. See www.id3.org for details of the block's structure. ID3v2 tags are supported at both the start and end of the file.
BASS_TAG_LYRICS3Lyrics3v2 tag. A single string is returned, containing the Lyrics3v2 information. See www.id3.org/Lyrics3v2 for details of its format.
BASS_TAG_APEAPE (v1 or v2) tags. A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null. Each string is in the form of "key=value", or "key=value1/value2/..." if there are multiple values.
BASS_TAG_APE_BINARY+ tag number (0=first). APEv2 binary tag. A pointer to a BASS_TAG_APE_BINARY structure is returned.
BASS_TAG_OGGOGG comments, only available when streaming an OGG file. A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null.
BASS_TAG_MP4MP4/iTunes metadata. A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null.
BASS_TAG_MFMedia Foundation metadata. A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null.
BASS_TAG_VENDOROGG encoder. A single UTF-8 string is returned.
BASS_TAG_HTTPHTTP headers, only available when streaming from a HTTP server. A pointer to a series of null-terminated strings is returned, the final string ending with a double null.
BASS_TAG_ICYICY (Shoutcast) tags. A pointer to a series of null-terminated strings is returned, the final string ending with a double null.
BASS_TAG_METAShoutcast metadata. A single null-terminated string containing the current stream title and url (usually omitted). The format of the string is: StreamTitle='xxx';StreamUrl='xxx';
BASS_TAG_RIFF_INFORIFF/WAVE 'INFO' tags. A pointer to a series of null-terminated ANSI strings is returned, the final string ending with a double null. The tags are in the form of 'XXXX=text', where 'XXXX' is the chunk ID.
BASS_TAG_RIFF_DISPRIFF/WAVE 'DISP' chunk text (CF_TEXT) tag. A single string is returned.
BASS_TAG_RIFF_BEXTRIFF/BWF "bext" chunk tags. A pointer to a BASS_TAG_BEXT structure is returned.
BASS_TAG_RIFF_CARTRIFF/BWF "cart" chunk tags. A pointer to a BASS_TAG_CART structure is returned.
BASS_TAG_WAVEFORMATWAVE "fmt" chunk contents. A pointer to a WAVEFORMATEX structure is returned. As well as WAVE files, this is also provided by Media Foundation codecs.
BASS_TAG_CA_CODECCoreAudio codec information. A pointer to a BASS_TAG_CACODEC structure is returned.
BASS_TAG_MUSIC_NAMEMOD music title (a single null-terminated ANSI String).
BASS_TAG_MUSIC_MESSAGEMOD message text (a single null-terminated ANSI String).
BASS_TAG_MUSIC_INST+ instrument number (0=first). MOD instrument name (a single null-terminated ANSI String).
BASS_TAG_MUSIC_SAMPLE+ sample number (0=first). MOD sample name (a single null-terminated ANSI String).
BASS_TAG_MUSIC_ORDERSMOD music order list. A pointer to a byte array is returned, with each byte being the pattern number played at that order position. Pattern number 254 is "+++" (skip order) and 255 is "---" (end song).
Other tags may be supported by Add-Ons, see the documentation.

Return Value

Type: IntPtr
If succesful, a pointer to the data of the tags/headers is returned, else Zero is returned. Use BASS_ErrorGetCode to get the error code.
Remarks

Some tags (eg. ID3v1) are located at the end of the file, so when streaming a file from the internet, the tags will not be available until the download is complete. A BASS_SYNC_DOWNLOAD sync can be set via BASS_ChannelSetSync(Int32, BASSSync, Int64, SYNCPROC, IntPtr), to be informed of when the download is complete. A BASS_SYNC_META sync can be used to be informed of new Shoutcast metadata, and a BASS_SYNC_OGG_CHANGE sync for when a new logical bitstream begins in a chained OGG stream, which generally brings new OGG tags.

In a chained OGG file containing multiple bitstreams, each bitstream will have its own tags. To get the tags from a particular one, BASS_ChannelSetPosition(Int32, Int64, BASSMode) can be first used to seek to it.

When a Media Foundation codec is in use, the BASS_TAG_WAVEFORMAT tag can be used to find out what the source format is, eg. via the WAVEFORMATEX structure's wFormatTag member. Some typical wFormatTag examples are: 0x0161 = WMA, 0x0162 = WMA pro, 0x0163 = WMA lossless, 0x1610 = AAC.

You might also use one of these overloads to directly get specific tags: BASS_ChannelGetTagsBWF(Int32), BASS_ChannelGetTagsCA(Int32), BASS_ChannelGetTagsID3V1(Int32), BASS_ChannelGetTagsID3V2(Int32), BASS_ChannelGetTagsAPE(Int32), BASS_ChannelGetTagsAPEBinary(Int32), BASS_ChannelGetTagsAPEPictures(Int32), BASS_ChannelGetTagsWMA(Int32), BASS_ChannelGetTagsMP4(Int32), BASS_ChannelGetTagsMF(Int32), BASS_ChannelGetTagsWAVEFORMAT(Int32), BASS_ChannelGetTagsFLACPictures(Int32), BASS_ChannelGetTagsFLACCuesheet(Int32), BASS_ChannelGetTagsOGG(Int32), BASS_ChannelGetTagsDSDArtist(Int32), BASS_ChannelGetTagsDSDTitle(Int32), BASS_ChannelGetTagsDSDComments(Int32), BASS_ChannelGetTagsHTTP(Int32), BASS_ChannelGetTagsICY(Int32), BASS_ChannelGetTagsRIFF(Int32), BASS_ChannelGetTagsMETA(Int32), BASS_ChannelGetTagLyrics3v2(Int32), BASS_ChannelGetMusicName(Int32), BASS_ChannelGetMusicSample(Int32, Int32), BASS_ChannelGetMusicInstrument(Int32, Int32), BASS_ChannelGetMusicMessage(Int32), BASS_ChannelGetMidiTrackText(Int32, Int32).

In addition you might also use the BassTags class, which provides extended TAG reading support.

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not valid.
BASS_ERROR_NOTAVAILThe requested tags are not available.

Examples

Getting OGG Tags:
VB
Dim channel As Integer = Bass.BASS_StreamCreateFile("test.ogg", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT)
Dim tag As IntPtr = Bass.BASS_ChannelGetTags(channel, BASSTag.BASS_TAG_OGG)
Dim tags As String() = Utils.IntPtrToArrayNullTermUtf8(tag)
If Not (tags Is Nothing) Then
  Dim tag As String
  For Each tag In  tags
    Console.Writeln("Tag: {0}" + ControlChars.Lf, tag)
  Next tag
End If
int channel = Bass.BASS_StreamCreateFile("test.ogg", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT);
IntPtr tag = Bass.BASS_ChannelGetTags(channel, BASSTag.BASS_TAG_OGG);
string[] tags = Utils.IntPtrToArrayNullTermUtf8(tag);
if (tags != null)
{
  foreach (string tag in tags)
    Console.Writeln("Tag: {0}\n", tag);
}
Getting MOD Music Instruments:
VB
Dim p As IntPtr = BASS_ChannelGetTags(handle, CType(BASSTag.BASS_TAG_MUSIC_INST + instrument, BASSTag))
If p <> IntPtr.Zero Then
  Dim instr As String = Utils.IntPtrAsStringAnsi(p)
End If
IntPtr p = BASS_ChannelGetTags(handle, (BASSTag)(BASSTag.BASS_TAG_MUSIC_INST + instrument));
if (p != IntPtr.Zero)
  string instr = Utils.IntPtrAsStringAnsi(p);
See Also

Reference