marytts.unitselection.data
Class TimelineReader.Index

java.lang.Object
  extended by marytts.unitselection.data.TimelineReader.Index
Enclosing class:
TimelineReader

public static class TimelineReader.Index
extends java.lang.Object

Simple helper class to read the index part of a timeline file. The index points to datagrams at or before a certain point in time. Note: If no datagram starts at the exact index time, it makes sense to point to the previous datagram rather than the following one. If one would store the location of the datagram which comes just after the index position (the currently tested datagram), there would be a possibility that a particular time request falls between the index and the datagram: time axis ---------------------------------> INDEX <-- REQUEST | ---------------> DATAGRAM This would require a subsequent backwards time hopping, which is impossible because the datagrams are a singly linked list. By registering the location of the previous datagram, any time request will find an index which points to a datagram falling BEFORE or ON the index location: time axis ---------------------------------> INDEX <-- REQUEST | DATAGRAM <--- Thus, forward hopping is always possible and the requested time can always be reached.

Author:
sacha

Constructor Summary
TimelineReader.Index(int idxInterval, java.util.Vector<TimelineReader.IdxField> indexFields)
          Constructor which builds a new index with a specific index interval and a given sample rate.
 
Method Summary
 long dump(java.io.RandomAccessFile rafIn)
          Method which writes an index to a RandomAccessFile
 TimelineReader.IdxField getIdxField(int i)
           
 TimelineReader.IdxField getIdxFieldBefore(long timePosition)
          Returns the index field that comes immediately before or straight on the requested time.
 int getIdxInterval()
          The interval, in samples, between two index entries.
 int getNumIdx()
          The number of index entries.
 void load(java.io.DataInput rafIn)
          Method which loads an index from a data input (random access file or data input stream).
 void print()
          Method which writes an index to stdout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimelineReader.Index

public TimelineReader.Index(int idxInterval,
                            java.util.Vector<TimelineReader.IdxField> indexFields)
                     throws java.lang.IllegalArgumentException,
                            java.lang.NullPointerException
Constructor which builds a new index with a specific index interval and a given sample rate. Fundamental guarantee: Once created, the index is guaranteed to contain a positive index interval and monotonously rising byte and time pointers.

Parameters:
idxInterval - the index interval, in samples. Must be a positive number.
indexFields - the actual index data. Must not be null.
Throws:
java.lang.IllegalArgumentException - if the index data given is not well-formed.
java.lang.NullPointerException - if indexFields are null.
Method Detail

load

public void load(java.io.DataInput rafIn)
          throws java.io.IOException,
                 MaryConfigurationException
Method which loads an index from a data input (random access file or data input stream).

Parameters:
rafIn - data input from which to read the index. Must not be null, and read position must be at start of index.
Throws:
java.io.IOException - if there is a problem reading.
MaryConfigurationException - if the index is not well-formed.

dump

public long dump(java.io.RandomAccessFile rafIn)
          throws java.io.IOException
Method which writes an index to a RandomAccessFile

Throws:
java.io.IOException

print

public void print()
Method which writes an index to stdout


getNumIdx

public int getNumIdx()
The number of index entries.


getIdxInterval

public int getIdxInterval()
The interval, in samples, between two index entries.

Returns:

getIdxField

public TimelineReader.IdxField getIdxField(int i)

getIdxFieldBefore

public TimelineReader.IdxField getIdxFieldBefore(long timePosition)
Returns the index field that comes immediately before or straight on the requested time.

Parameters:
timePosition - the non-negative time
Returns:
an index field representing the index position just before or straight on the requested time.
Throws:
java.lang.IllegalArgumentException - if the given timePosition is negtive