org.farng.mp3.id3
Class FrameBodyASPI

java.lang.Object
  extended by org.farng.mp3.AbstractMP3FileItem
      extended by org.farng.mp3.AbstractMP3FragmentBody
          extended by org.farng.mp3.id3.AbstractID3v2FrameBody
              extended by org.farng.mp3.id3.FrameBodyASPI
All Implemented Interfaces:
MP3MetadataContainer

public class FrameBodyASPI
extends AbstractID3v2FrameBody

4.30.   Audio seek point index

   Audio files with variable bit rates are intrinsically difficult to
   deal with in the case of seeking within the file. The ASPI frame
   makes seeking easier by providing a list a seek points within the
   audio file. The seek points are a fractional offset within the audio
   data, providing a starting point from which to find an appropriate

   point to start decoding. The presence of an ASPI frame requires the
   existence of a TLEN frame, indicating the duration of the file in
   milliseconds. There may only be one 'audio seek point index' frame in
   a tag.

     <Header for 'Seek Point Index', ID: "ASPI">
     Indexed data start (S)         $xx xx xx xx
     Indexed data length (L)        $xx xx xx xx
     Number of index points (N)     $xx xx

     Bits per index point (b)       $xx

   Then for every index point the following data is included;

     Fraction at index (Fi)          $xx (xx)

   'Indexed data start' is a byte offset from the beginning of the file.
   'Indexed data length' is the byte length of the audio data being
   indexed. 'Number of index points' is the number of index points, as
   the name implies. The recommended number is 100. 'Bits per index
   point' is 8 or 16, depending on the chosen precision. 8 bits works

   well for short files (less than 5 minutes of audio), while 16 bits is
   advantageous for long files. 'Fraction at index' is the numerator of
   the fraction representing a relative position in the data. The
   denominator is 2 to the power of b.

   Here are the algorithms to be used in the calculation. The known data
   must be the offset of the start of the indexed data (S), the offset
   of the end of the indexed data (E), the number of index points (N),
   the offset at index i (Oi). We calculate the fraction at index i
   (Fi).

   Oi is the offset of the frame whose start is soonest after the point
   for which the time offset is (i/N * duration).

   The frame data should be calculated as follows:

     Fi = Oi/L * 2^b    (rounded down to the nearest integer)

   Offset calculation should be calculated as follows from data in the
   frame:

     Oi = (Fi/2^b)*L    (rounded up to the nearest integer)

Version:
$Revision: 3 $
Author:
Eric Farng

Constructor Summary
FrameBodyASPI()
          Creates a new FrameBodyASPI object.
FrameBodyASPI(FrameBodyASPI copyObject)
          Creates a new FrameBodyASPI object.
FrameBodyASPI(int dataStart, int dataLength, int indexPoints, int bitsPerPoint, short[] fraction)
          Creates a new FrameBodyASPI object.
FrameBodyASPI(java.io.RandomAccessFile file)
          Creates a new FrameBodyASPI object.
 
Method Summary
 void equals()
          This method is not yet supported.
 java.lang.String getIdentifier()
           
 int getSize()
          Returns the estimated size in bytes of this object if it was to be written to file.
 void read(java.io.RandomAccessFile file)
          Read the data from the given file into this object.
protected  void setupObjectList()
          Create the order of MP3Object objects that this body expects.
 java.lang.String toString()
          Calls toString for all MP3Object objects and creates a string with a new line character.
 void write(java.io.RandomAccessFile file)
          Write the contents of this object to the file at the position it is currently at.
 
Methods inherited from class org.farng.mp3.id3.AbstractID3v2FrameBody
equals, readHeader, writeHeader
 
Methods inherited from class org.farng.mp3.AbstractMP3FragmentBody
appendToObjectList, getBriefDescription, getDescription, getObject, getObjectListIterator, has6ByteHeader, isSubsetOf, iterator, setObject
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FrameBodyASPI

public FrameBodyASPI()
Creates a new FrameBodyASPI object.


FrameBodyASPI

public FrameBodyASPI(FrameBodyASPI copyObject)
Creates a new FrameBodyASPI object.


FrameBodyASPI

public FrameBodyASPI(int dataStart,
                     int dataLength,
                     int indexPoints,
                     int bitsPerPoint,
                     short[] fraction)
Creates a new FrameBodyASPI object.


FrameBodyASPI

public FrameBodyASPI(java.io.RandomAccessFile file)
              throws java.io.IOException,
                     InvalidTagException
Creates a new FrameBodyASPI object.

Throws:
java.io.IOException
InvalidTagException
Method Detail

getIdentifier

public java.lang.String getIdentifier()
Specified by:
getIdentifier in class AbstractMP3FileItem

getSize

public int getSize()
Description copied from class: AbstractMP3FragmentBody
Returns the estimated size in bytes of this object if it was to be written to file. This is not guaranteed to be accurate 100% of the time.

Overrides:
getSize in class AbstractMP3FragmentBody
Returns:
estimated size in bytes of this object

equals

public void equals()
This method is not yet supported.

Throws:
java.lang.UnsupportedOperationException - This method is not yet supported

setupObjectList

protected void setupObjectList()
Description copied from class: AbstractMP3FragmentBody
Create the order of MP3Object objects that this body expects. This method needs to be overwritten.

Specified by:
setupObjectList in class AbstractMP3FragmentBody

read

public void read(java.io.RandomAccessFile file)
          throws java.io.IOException,
                 InvalidTagException
Description copied from class: AbstractMP3FragmentBody
Read the data from the given file into this object. The file needs to have its file pointer in the correct location.

Overrides:
read in class AbstractMP3FragmentBody
Parameters:
file - file to read from
Throws:
java.io.IOException - on any I/O error
InvalidTagException - if there is any error in the data format.

toString

public java.lang.String toString()
Description copied from class: AbstractMP3FragmentBody
Calls toString for all MP3Object objects and creates a string with a new line character.

Overrides:
toString in class AbstractMP3FragmentBody
Returns:
description string

write

public void write(java.io.RandomAccessFile file)
           throws java.io.IOException
Description copied from class: AbstractMP3FragmentBody
Write the contents of this object to the file at the position it is currently at.

Overrides:
write in class AbstractMP3FragmentBody
Parameters:
file - destination file
Throws:
java.io.IOException - on any I/O error