Documentation
    Preparing search index...

    Class TimeBaseClass<Type, Unit>Abstract

    TimeBase is a flexible encoding of time which can be evaluated to and from a string.

    Type Parameters

    • Type extends number
    • Unit extends string

    Hierarchy (View Summary)

    Index
    • Type Parameters

      • Type extends number
      • Unit extends string

      Parameters

      • context: BaseContext

        The context associated with the time value. Used to compute Transport and context-relative timing.

      • Optionalvalue: TimeValue

        The time value as a number, string or object

      • Optionalunits: Unit

        Unit values

      Returns TimeBaseClass<Type, Unit>

    _expressions: TimeExpression<Type>

    All of the conversion expressions

    _units?: Unit

    The units of time

    _val?: TimeValue

    The value of the units

    context: BaseContext
    debug: boolean

    Set this debug flag to log all events that happen in this class.

    defaultUnits: Unit

    The default units

    name: string

    The name of the class

    version: string

    The version number semver

    • get disposed(): boolean

      Indicates if the instance was disposed. 'Disposing' an instance means that all of the Web Audio nodes that were created for the instance are disconnected and freed for garbage collection.

      Returns boolean

    • Return the value of the beats in the current units

      Parameters

      • beats: number

      Returns Type

    • Returns the value of a frequency in the current units

      Parameters

      • freq: number

      Returns Type

    • Return the bpm

      Returns number

    • All of the time encoding expressions

      Returns TimeExpression<Type>

    • Return the PPQ or 192 if Transport is not available

      Returns number

    • Return the timeSignature

      Returns number

    • With no arguments, return 'now'

      Returns Type

    • Return the current time in whichever context is relevant

      Returns Type

    • Returns the value of a second in the current units

      Parameters

      • seconds: number

      Returns Type

    • Returns the value of a tick in the current time units

      Parameters

      • ticks: number

      Returns Type

    • disconnect and dispose.

      Returns this

    • Coerce a time type into this units type.

      Parameters

      Returns this

    • Prints the outputs to the console log for debugging purposes. Prints the contents only if either the object has a property called debug set to true, or a variable called TONE_DEBUG_CLASS is set to the name of the class.

      Parameters

      • ...args: any[]

      Returns void

      const osc = new Tone.Oscillator();
      // prints all logs originating from this oscillator
      osc.debug = true;
      // calls to start/stop will print in the console
      osc.start();
    • Return the value in hertz

      Returns number

    • Return the value as a Midi note

      Returns
          | 0
          | 1
          | 2
          | 3
          | 4
          | 5
          | 6
          | 7
          | 8
          | 9
          | 10
          | 11
          | 12
          | 13
          | 14
          | 15
          | 16
          | 17
          | 18
          | 19
          | 20
          | 21
          | 22
          | 23
          | 24
          | 25
          | 26
          | 27
          | 28
          | 29
          | 30
          | 31
          | 32
          | 33
          | 34
          | 35
          | 36
          | 37
          | 38
          | 39
          | 40
          | 41
          | 42
          | 43
          | 44
          | 45
          | 46
          | 47
          | 48
          | 49
          | 50
          | 51
          | 52
          | 53
          | 54
          | 55
          | 56
          | 57
          | 58
          | 59
          | 60
          | 61
          | 62
          | 63
          | 64
          | 65
          | 66
          | 67
          | 68
          | 69
          | 70
          | 71
          | 72
          | 73
          | 74
          | 75
          | 76
          | 77
          | 78
          | 79
          | 80
          | 81
          | 82
          | 83
          | 84
          | 85
          | 86
          | 87
          | 88
          | 89
          | 90
          | 91
          | 92
          | 93
          | 94
          | 95
          | 96
          | 97
          | 98
          | 99
          | 100
          | 101
          | 102
          | 103
          | 104
          | 105
          | 106
          | 107
          | 108
          | 109
          | 110
          | 111
          | 112
          | 113
          | 114
          | 115
          | 116
          | 117
          | 118
          | 119
          | 120
          | 121
          | 122
          | 123
          | 124
          | 125
          | 126
          | 127

    • Return the time in milliseconds.

      Returns number

    • Return the time in samples

      Returns number

    • Return the value in seconds

      Returns number

    • Convert the class to a string

      Returns string

      const osc = new Tone.Oscillator();
      console.log(osc.toString());
    • Convert the value into ticks

      Returns number

    • Evaluate the time value. Returns the time in seconds.

      Returns Type

    • Returns all of the default options belonging to the class.

      Returns BaseToneOptions