public class ID3v24FrameBodyAudioSeekPointIndex extends ID3v24FrameBody
An audio seek pointer index frame body is associated with an ID3v2.4 ASPI
frame
which is used to list the people who were involved
in the song. The audio seek pointer index frame body contains the following fields:
Field | Description | |
---|---|---|
1. | indexed data start | the byte offset of the indexed .mp3 audio data from the beginning of the .mp3 file. This is typically the start of the audio portion of the .mp3 file. |
2. | indexed data length | length (in bytes) of the .mp3 audio data being indexed. This is typically the size (in bytes) of the .mp3 file - the size of ID3v2.4 tag. |
3. | num index points | the number of index points. This specifies how many points within the .mp3 audio section you want create indexes for. |
4. | bits per index point | the number of bits used to store an index point (either 8 bits or 16 bits). Why this wasn't just defined as 16 bits you'll have to ask the crazy drunk monkeys who created the ID3v2.4 spec. |
5. | list of fraction at indexes | for each index point, the fraction at index is the numerator of the fraction representing a
relative position in the data. The denominator is 2 ^ bits per index point. Since the bits per index
point is either 8 or 16, the denominator is either 2 ^ 8 = 256 or 2 ^ 16 = 65536.
The fraction at index i is given by: f[i] = offset[i] / where: offset[i] = the offset (in bytes) of the frame whose start is soonest after the point for which the time offset = (i / The duration is obtained from the TLEN frame. |
There may only be one audio seek pointer index frame in an ID3v2.4 tag
.
Modifier and Type | Class and Description |
---|---|
static class |
ID3v24FrameBodyAudioSeekPointIndex.BitsPerIndexPoint
valid ID3v2.4 bits per index point values
|
buffer, dirty, frameType
nextNullTerminatorIndex, nullTerminatorIndex
Constructor and Description |
---|
ID3v24FrameBodyAudioSeekPointIndex()
The default constructor is called when creating a new frame.
|
ID3v24FrameBodyAudioSeekPointIndex(java.io.InputStream inputStream,
int frameBodySize)
This constructor is called when reading in an existing frame from an .mp3 file.
|
ID3v24FrameBodyAudioSeekPointIndex(int indexedDataStart,
int indexedDataLength,
ID3v24FrameBodyAudioSeekPointIndex.BitsPerIndexPoint bitsPerIndexPoint,
java.util.List<java.lang.Short> fractionAtIndexes)
This constructor is called when creating a new frame.
|
Modifier and Type | Method and Description |
---|---|
ID3v24FrameBodyAudioSeekPointIndex.BitsPerIndexPoint |
getBitsPerIndexPoint()
gets the number of bits used to store an index point (either 8 bits or 16 bits).
|
java.util.List<java.lang.Short> |
getFractionAtIndexes()
gets the list of fraction indexes for the indexed points.
|
int |
getIndexedDataLength()
gets the length (in bytes) of the .mp3 audio data being indexed.
|
int |
getIndexedDataStart()
gets the byte offset of the indexed .mp3 audio data from the beginning of the .mp3 file.
|
short |
getNumIndexPoints()
gets the number of index points.
|
void |
parse()
parses the raw bytes of the frame body and stores the parsed values in the frame's fields.
|
void |
setBitsPerIndexPoint(ID3v24FrameBodyAudioSeekPointIndex.BitsPerIndexPoint bitsPerIndexPoint) |
void |
setBuffer()
If the frame body's values have been modified, then resize the raw binary buffer and store the new values there.
|
void |
setFractionAtIndexes(java.util.List<java.lang.Short> fractionAtIndexes)
A fraction index represents the relative position within data, and is a fraction given by the following formula:
fraction index = offset / * 2 ^ where: time offset = (index point / You have an .mp3 file which is 1 minute and 20 seconds long, has a disk size of 200,000 bytes, and whose first 10,000 bytes are used for the ID3v2.4 tag. |
void |
setIndexedDataLength(int indexedDataLength)
sets the length (in bytes) of the .mp3 audio data being indexed.
|
void |
setIndexedDataStart(int indexedDataStart)
sets the byte offset of the indexed .mp3 audio data from the beginning of the .mp3 file.
|
java.lang.String |
toString()
gets a string representation of the audio seek pointer index frame body showing all of the frame's fields and their values.
|
getFrameType, getNextNullTerminator, getSize, isDirty, save, save
getNextNullTerminator, pricesToString, stringToBytes
bytesToInt, bytesToInt, bytesToShort, bytesToShort, bytesToSynchsafeInt, bytesToSynchsafeShort, formateDate, hex, hex, hex, intToBytes, littleEndianBytesToInt, pad, shortToBytes, synchsafeIntToBytes
public ID3v24FrameBodyAudioSeekPointIndex()
public ID3v24FrameBodyAudioSeekPointIndex(int indexedDataStart, int indexedDataLength, ID3v24FrameBodyAudioSeekPointIndex.BitsPerIndexPoint bitsPerIndexPoint, java.util.List<java.lang.Short> fractionAtIndexes)
indexedDataStart
- byte offset from the beginning of the .mp3 file.indexedDataLength
- length (in bytes) of the audio data being indexed.bitsPerIndexPoint
- the number of bits used to store an index point (either 8 bits or 16 bits).fractionAtIndexes
- list of fraction indexes for the indexed points. see setFractionAtIndexes(List)
for a fuller explanation.public ID3v24FrameBodyAudioSeekPointIndex(java.io.InputStream inputStream, int frameBodySize) throws java.io.IOException
inputStream
- input stream pointing to an audio seek pointer index frame body in the .mp3 file.frameBodySize
- size (in bytes) of the frame's body.java.io.IOException
- if there is an error while reading the frame body.public int getIndexedDataStart()
setIndexedDataStart(int)
public void setIndexedDataStart(int indexedDataStart)
indexedDataStart
- the byte offset of the indexed .mp3 audio data from the beginning of the .mp3 file.getIndexedDataStart()
public int getIndexedDataLength()
setIndexedDataLength(int)
public void setIndexedDataLength(int indexedDataLength)
indexedDataLength
- the length (in bytes) of the .mp3 audio data being indexed.getIndexedDataLength()
public short getNumIndexPoints()
getFractionAtIndexes()
public ID3v24FrameBodyAudioSeekPointIndex.BitsPerIndexPoint getBitsPerIndexPoint()
setBitsPerIndexPoint(BitsPerIndexPoint)
public void setBitsPerIndexPoint(ID3v24FrameBodyAudioSeekPointIndex.BitsPerIndexPoint bitsPerIndexPoint)
bitsPerIndexPoint
- the bitsPerIndexPoint to setpublic java.util.List<java.lang.Short> getFractionAtIndexes()
setFractionAtIndexes(List)
public void setFractionAtIndexes(java.util.List<java.lang.Short> fractionAtIndexes)
You have an .mp3 file which is 1 minute and 20 seconds long, has a disk size of 200,000 bytes, and whose first 10,000 bytes are used for the ID3v2.4 tag. You are going to create 15 index points for the audio portion of the .mp3 file. You want to calculate the fraction at index 6. Using these values, you then have: 1. indexed data start 10,000 bytes 2. indexed data end 200,000 bytes 3. indexed data length 190,000 bytes = 200,000 - 10,000 4. duration 1 minute and 20 seconds = 80 seconds = 80,000 ms 5. num index points 15 6. bits per index point 16 7. time offset[6] 6 / 15 * 80,000ms = 32,000ms 8. offset[6] is the offset (in bytes) of the mp3 frame (not to be confused with frames in an ID3v2.x tag) whose start occurs soonest after the time offset. this value will be calculated by the .mp3 player software. 8. fraction[6] offset[6] / indexed data length * 2 ^ bits per index point offset[6] / 190,000 * 65536 offset[6] * 0.34492631578947368421052631578947 The fraction calculated in step 8 is rounded down to the nearest integer.Don't worry if you don't understand all of this. The monkeys who made the ID3v2.4 spec did an exceptionally bad job with this frame, and their documentation has errors in it.
fractionAtIndexes
- the fractionAtIndexes to setpublic void parse() throws java.lang.IllegalArgumentException
parse
in class ID3v24FrameBody
java.lang.IllegalArgumentException
- if an invalid value is detected while parsing the frame body's raw bytes.public void setBuffer()
setBuffer
in class ID3v24FrameBody
public java.lang.String toString()
toString
in class java.lang.Object