java.lang.Object
games.stendhal.client.sound.facade.Time
All Implemented Interfaces:
Cloneable

public class Time extends Object implements Cloneable
A time class that helps converting different time units to and from samples per sample rate

internally this class will calculate in nanosecond resolution only

Author:
silvio
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Enumeration of different time units
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Time​(long nanos)
     
    Time​(long samples, int sampleRate)
    Creates an instance of the Time class from a given number of samples and a sample rate
    Time​(long value, Time.Unit unit)
    Creates an instance of the Time class from a time value and a time unit
  • Method Summary

    Modifier and Type
    Method
    Description
     
    double
     
    double
     
    double
     
    long
     
    double
    getInSamples​(int sampleRate)
    Calculates the number of samples for a given sample rate that would fit into this time range
    double
     
    void
    set​(long samples, int sampleRate)
     
    void
    set​(long value, Time.Unit unit)
     

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Time

      public Time()
    • Time

      public Time(long nanos)
    • Time

      public Time(long value, Time.Unit unit)
      Creates an instance of the Time class from a time value and a time unit
      Parameters:
      value - the time value
      unit - the time unit (e.g. NANO, MILLI, SEC, ...)
    • Time

      public Time(long samples, int sampleRate)
      Creates an instance of the Time class from a given number of samples and a sample rate
      Parameters:
      samples -
      sampleRate -
  • Method Details

    • set

      public final void set(long value, Time.Unit unit)
    • set

      public final void set(long samples, int sampleRate)
    • getInNanoSeconds

      public long getInNanoSeconds()
    • getInMilliSeconds

      public double getInMilliSeconds()
    • getInSeconds

      public double getInSeconds()
    • getInMinutes

      public double getInMinutes()
    • getInHours

      public double getInHours()
    • getInSamples

      public double getInSamples(int sampleRate)
      Calculates the number of samples for a given sample rate that would fit into this time range
      Parameters:
      sampleRate - any sample rate
      Returns:
      number of samples
    • clone

      public Time clone()
      Overrides:
      clone in class Object