Format
Formatting tools for your music files
Formatting tools for your music files in the Basolia library allow you to get information about your music file, such as getting a total duration, getting frame size and length, and getting ID3v2 metadata.
Audio information tools
The formatting tools include the audio information tools, which allows you to get information about a music file that you've opened using the OpenFile()
function.
Getting a duration
You can get a duration of the whole music file using either the samples count or the time span using one of the below functions:
Additionally, if you have a number of samples, such as what GetDuration()
returned, you can use one of the following functions:
Frame size and length
If you want to know the frame size of your music file and its length, you can use the two functions below:
Samples per frame
If you want to know the number of MPEG samples per single frame, you can use the below function:
Getting buffer size
To get the buffer size for your music file, you'll have to call the GetBufferSize()
function.
ID3v2, ID3v1, and ICY metadata
To gather the ID3v2, ID3v1, and ICY metadata, the two functions provide you information about the music file:
The ID3v2 metadata contains the following information:
Title
: Song titleArtist
: Song artistAlbum
: Song albumYear
: Song yearComment
: Song commentGenre
: Song genreComments
: A list of commentsTexts
: A list of extra textExtras
: A list of extrasPictures
: A list of pictures
The ID3v1 metadata contains the following information:
Tag
: Song tagTitle
: Song titleArtist
: Song artistAlbum
: Song albumYear
: Song yearComment
: Song commentGenre
: Song genre. You can get its index using theGenreIndex
property.
Frame information
To get the complete frame information about your music file, you need to call the GetFrameInfo()
function:
A single FrameInfo
instance returned by the above function contains the following information:
Version
: MPEG versionLayer
: Layer 1, 2, or 3Rate
: BitrateMode
: MPEG mode. You can get extended info using the ModeExt property.FrameSize
: MPEG frame sizeFlags
: Flags to indicate the originality of the songEmphasis
: The song emphasisBitRate
: Actual bitrateAbrRate
: Average bitrateVbr
: Variable bitrate mode
Format tools
In addition to the audio information tools, this library also ships the formatting tools that allow you to get format info for a song.
Getting format info
To get format information for a song, you can use the GetFormatInfo() function that allows you to get a bit rate, number of channels, and the encoding used in a song:
Getting list of supported formats
In addition to getting a single format information, you can also get a list of supported formats that are supported by the sound device. This can be achieved by calling the GetFormats()
function:
A single FormatInfo
instance contains three properties:
Rate
: A bit rateChannels
: Number of channels in a song fileEncoding
: Song encoding
Decode tools
In order for BassBoom to play songs, they must be decoded before the resulting audio data can be sent to the target device. BassBoom's Basolia offers decoding tools.
Manually decoding a frame
To manually decode a frame, you must use the DecodeFrame()
function. Most of the time, you don't need to call it; BassBoom's Basolia will automatically call it for you when playback is commenced.
Get/Set current decoder
If you want to get the current decoder or if you want to set the current decoder to something else, you need to use the Decoder
property.
Make sure that you're using a decoder that's supported for your device. Otherwise, you'll get an error saying that the required decoder is not supported.
Get current decoders
If you want to either get all the decoders that are implemented in the distributed version of MPG123 library, or if you want to get all the decoders that your system can use, you'll need to use the GetDecoders
function.
Last updated