TicksClass
class Unit ↳ extends TransportTimeClass<Ticks>
Ticks is a primitive type for encoding Time values.
Ticks can be constructed with or without the new keyword. Ticks can be passed
into the parameter of any method which takes time as an argument.
const t = Tone.Ticks("4n"); // a quarter note as ticksConstructor
Section titled “Constructor”new TicksClass(context: BaseContext, value?: TimeValue, units?: TimeBaseUnit)Parameters
-
context
BaseContextThe context associated with the time value. Used to compute Transport and context-relative timing.
-
value
TimeValueoptionalThe time value as a number, string or object
-
units
TimeBaseUnitoptionalUnit values
Properties
Section titled “Properties”defaultUnits
Section titled “defaultUnits”read-only
defaultUnits: TimeBaseUnitThe default units
Default: "i"
Methods
Section titled “Methods”fromType()
Section titled “fromType()”↳ inherited from TimeBase
fromType(type: TimeBaseClass<any, any>): thisCoerce a time type into this units type.
Parameters
-
type
TimeBaseClass<any, any>Any time type units
Returns this
quantize()
Section titled “quantize()”↳ inherited from Time
quantize(subdiv: Time, percent?: number): numberQuantize the time by the given subdivision. Optionally add a percentage which will move the time value towards the ideal quantized value by that percentage.
Tone.Time(21).quantize(2); // returns 22
Tone.Time(0.6).quantize("4n", 0.5); // returns 0.55Parameters
-
subdiv
TimeThe subdivision to quantize to
-
percent
numberoptional default1Move the time value towards the quantized value by a percentage.
Returns number
toBarsBeatsSixteenths()
Section titled “toBarsBeatsSixteenths()”↳ inherited from Time
toBarsBeatsSixteenths(): `${number}:${number}:${number}`Return the time encoded as Bars:Beats:Sixteenths.
Returns ${number}:${number}:${number}
toFrequency()
Section titled “toFrequency()”↳ inherited from TimeBase
toFrequency(): numberReturn the value in hertz
Returns number
toMidi()
Section titled “toMidi()”↳ inherited from Time
toMidi(): 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 | 127Return 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
toMilliseconds()
Section titled “toMilliseconds()”↳ inherited from TimeBase
toMilliseconds(): numberReturn the time in milliseconds.
Returns number
toNotation()
Section titled “toNotation()”↳ inherited from Time
toNotation(): SubdivisionConvert a Time to Notation. The notation values are will be the closest representation between 1m to 128th note.
// if the Transport is at 120bpm: Tone.Time(2).toNotation(); // returns "1m"
Returns Subdivision
toSamples()
Section titled “toSamples()”↳ inherited from TimeBase
toSamples(): numberReturn the time in samples
Returns number
toSeconds()
Section titled “toSeconds()”toSeconds(): numberReturn the time in seconds
Returns number
valueOf()
Section titled “valueOf()”↳ inherited from TimeBase
valueOf(): numberEvaluate the time value. Returns the time in seconds.
Returns number
Inherited members
Section titled “Inherited members”- From
Tone: debug, version, disposed, dispose(), toString(), getDefaults()