net.beadsproject.beads.core
Class TimeStamp

java.lang.Object
  extended by net.beadsproject.beads.core.TimeStamp

public class TimeStamp
extends java.lang.Object

TimeStamps store time with respect to the current AudioContext. Specifically, the TimeStamp stores a time step and an index into a buffer.


Field Summary
 AudioContext context
          The context.
 int index
          The index into the sample frame.
 long timeStep
          The time step (AudioContext's count of sample frames).
 
Constructor Summary
TimeStamp(AudioContext context, long timeInSamples)
          Instantiates a new TimeStamp with the given time step, context and buffer index.
TimeStamp(AudioContext context, long timeStep, int index)
          Instantiates a new TimeStamp with the given time step, context and buffer index.
 
Method Summary
static TimeStamp add(AudioContext ac, TimeStamp a, TimeStamp b)
           
 double getTimeMS()
          Gets the time of the TimeStamp in milliseconds.
 long getTimeSamples()
          Gets the time in samples.
 boolean isAfter(TimeStamp other)
           
 boolean isBefore(TimeStamp other)
           
 double since(TimeStamp oldest)
           
static TimeStamp subtract(AudioContext ac, TimeStamp a, TimeStamp b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

public final AudioContext context
The context.


timeStep

public final long timeStep
The time step (AudioContext's count of sample frames).


index

public final int index
The index into the sample frame.

Constructor Detail

TimeStamp

public TimeStamp(AudioContext context,
                 long timeStep,
                 int index)
Instantiates a new TimeStamp with the given time step, context and buffer index. Use AudioContext.generateTimeStamp(int) to generate a TimeStamp for the current time.

Parameters:
context - the AudioContext.
timeStep - the time step.
index - the index.

TimeStamp

public TimeStamp(AudioContext context,
                 long timeInSamples)
Instantiates a new TimeStamp with the given time step, context and buffer index. Use AudioContext.generateTimeStamp(int) to generate a TimeStamp for the current time.

Parameters:
context - the AudioContext.
timeStep - the time step.
index - the index.
Method Detail

getTimeMS

public double getTimeMS()
Gets the time of the TimeStamp in milliseconds.

Returns:
the time in milliseconds.

getTimeSamples

public long getTimeSamples()
Gets the time in samples.

Returns:
the time in samples.

since

public double since(TimeStamp oldest)

isBefore

public boolean isBefore(TimeStamp other)

isAfter

public boolean isAfter(TimeStamp other)

subtract

public static TimeStamp subtract(AudioContext ac,
                                 TimeStamp a,
                                 TimeStamp b)

add

public static TimeStamp add(AudioContext ac,
                            TimeStamp a,
                            TimeStamp b)