TickSource < TypeName >

  • TypeName: "bpm" | "hertz"

Uses TickSignal to track elapsed ticks with complex automation curves.

Hierarchy

Constructor

new TickSource (
frequency?:undefined | number

The initial frequency that the signal ticks at

) => TickSource
new TickSource (
options?:Partial<TickSourceOptions >
) => TickSource

Properties

blockTime #

readonly Seconds

The number of seconds of 1 processing block (128 samples)

context #

BaseContext

The context belonging to the node.

debug #

boolean

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

disposed #

readonly 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.

frequency #

TickSignal<TypeName >

The frequency the callback function should be invoked.

name #

string

sampleTime #

readonly Seconds

The duration in seconds of one sample.

seconds #

Seconds

The time since ticks=0 that the TickSource has been running. Accounts for tempo curves

state #

readonly PlaybackState

Returns the playback state of the source, either "started", "stopped" or "paused".

ticks #

Ticks

The number of times the callback was invoked. Starts counting at 0 and increments after the callback was invoked. Returns -1 when stopped.

static version #

string

The version number semver

Methods

cancel #

Cancel start/stop/pause and setTickAtTime events scheduled after the given time.

cancel (
time:Time

When to clear the events after

) => this

dispose #

Clean up

dispose ( ) => this

forEachTickBetween #

Invoke the callback event at all scheduled ticks between the start time and the end time

forEachTickBetween (
startTime:number ,

The beginning of the search range

endTime:number ,

The end of the search range

callback:(when,ticks) => void

The callback to invoke with each tick

) => this

get #

Get the object's attributes.


import { Oscillator } from "tone";
const osc = new Oscillator();
console.log(osc.get());
// returns {"type" : "sine", "frequency" : 440, ...etc}
get ( ) => TickSourceOptions

static getDefaults #

Returns all of the default options belonging to the class.

getDefaults ( ) => TickSourceOptions

getSecondsAtTime #

Return the elapsed seconds at the given time.

getSecondsAtTime (
time:Time

When to get the elapsed seconds

) => Seconds
The number of elapsed seconds

getStateAtTime #

Returns the scheduled state at the given time.

getStateAtTime (
time:Time

The time to query.

) => PlaybackState

getTicksAtTime #

Get the elapsed ticks at the given time

getTicksAtTime (
time?:Time

When to get the tick value

) => Ticks
The number of ticks

getTimeOfTick #

Get the time of the given tick. The second argument is when to test before. Since ticks can be set (with setTicksAtTime) there may be multiple times for a given tick value.

getTimeOfTick (
tick:Ticks ,

The tick number.

before= this.now():number

When to measure the tick value from.

) => Seconds
The time of the tick

immediate #

Return the current time of the Context clock without any lookAhead.

immediate ( ) => Seconds

now #

Return the current time of the Context clock plus the lookAhead.

now ( ) => Seconds

pause #

Pause the clock. Pausing does not reset the tick counter.

pause (
time:Time

The time when the clock should stop.

) => this

set #

Set multiple properties at once with an object.


import { Filter } from "tone";
const filter = new Filter();
// set values using an object
filter.set({
	frequency: 300,
	type: "highpass"
});
set ( ) => this

setTicksAtTime #

Set the clock's ticks at the given time.

setTicksAtTime (
ticks:Ticks ,

The tick value to set

time:Time

When to set the tick value

) => this

start #

Start the clock at the given time. Optionally pass in an offset of where to start the tick counter from.

start (
time:Time ,

The time the clock should start

offset?:Ticks

The number of ticks to start the source at

) => this

stop #

Stop the clock. Stopping the clock resets the tick counter to 0.

stop (
time:Time

The time when the clock should stop.

) => this

toFrequency #

Convert the input to a frequency number

toFrequency (
freq:Frequency
) => Hertz

toSeconds #

Convert the incoming time to seconds

toSeconds (
time?:Time
) => Seconds

toString #

Convert the class to a string


import { Oscillator } from "tone";
const osc = new Oscillator();
console.log(osc.toString());
toString ( ) => string

toTicks #

Convert the input time into ticks

toTicks (
time?:Time | TimeClass
) => Ticks