Skip to content

Channel

rech edited this page Jun 15, 2026 · 1 revision

Description

Allow for creation of value channels.

Remarks

This class is only for channel creation, and is NOT actually a channel.

Methods


keyframe()

Description

Create a key channel.

Parameters

_

Return types

KeyChannel

Remarks

_

Example

local channel = Channel.keyframe()

constant(val)

Description

Creates a constant value channel.

Parameters

Name Type Description
val number The constant value

Return types

ValueChannel

Remarks

_

Example

Scene.track.colorA = Channel.constant(127)

fft(freqBandMin, freqBandMax, min, max, smoothness, scalar)

Description

Create a FFT (Fast Fourier Transform) channel, that calculates the loudness of currently playing audio within the frequency band.

Parameters

Name Type Description
freqBandMin number The minimum frequency band to sample
freqBandMax number The maximum frequency band to sample
min number minimum value output
max number Maximum value output
smoothness number Smoothness of return value over time (0-1)
scalar number value output multiplier

Return types

ValueChannel

Remarks

freqBandMin and freqBandMax are in the unit of frequency bands, not hertz. By default the audio is sampled in 256 frequency bands.

Internally the channel tries its best to make sure output stays consistent with different FFT resolution. However the output value range can still be quite unpredictable, therefore the min and max parameters are not guaranteed to be accurate. Please use scalar to manually tune the channel if you run into trouble with this.

Example

local channel = Channel.fft(0, 30, 0, 1, 0.5, 1)

random(seed, min, max)

Description

Creates a channel that returns random value everytime.

Parameters

Name Type Description
seed number The randomizer's seed
min number minimum value output
max number max value output

Return types

ValueChannel

Remarks

Although you can set the randomizer's seed, the behaviour is still unpredictable because it's unclear how much time the randomizer has generated values at any point in time.

This channel also returns different values at the same timing point.

Example

sprite.colorR = Channel.random(0, 200, 255)

noise(frequency, min, max, offset, octave)

Description

Creates a perlin noise channel.

Parameters

Name Type Description
frequency ValueChannel The perlin noise's frequency
min ValueChannel Minimum value output
max ValueChannel max value output
offset ValueChannel How much to offset the noise by
octave ValueChannel The perlin noise's octave value

Return types

ValueChannel

Remarks

This channel is not actually random, although it may appear so. Two different perlin noise channels will return the same value, which may not be what you're trying to do. Use the offset param to mitigate this.

Multiple octave perlin noise essentially behaves like multiple perlin noises added on top of each other. The output value range is not well defined in this case, so min and max may not be accurate for octaves higher than 1.

Example

track.translationX = Channel.noise(Channel.constant(10), Channel.constant(-1), Channel.constant(1), Channel.constant(0), Channel.constant(1))

sine(period, min, max, offset)

Description

Creates a sine wave channel.

Parameters

Name Type Description
period ValueChannel Looping duration
min ValueChannel Minimum value output
max ValueChannel max value output
offset ValueChannel How much to offset the wave by

Return types

ValueChannel

Remarks

The formula used to calculate this is min + (max-min) * sin(2*pi*(timing+offset)/period)

Example

sprite.colorA = Channel.sine(Channel.constant(2000), Channel.constant(180), Channel.constant(255), Channel.constant(0))

saw(easing, period, min, max, offset)

Description

Creates a saw wave channel with easing method used at each interval.

Parameters

Name Type Description
easing string The easing to use
period ValueChannel Looping duration
min ValueChannel minimum value output
max ValueChannel max value output
offset ValueChannel How much to offset the wave by

Return types

ValueChannel

Remarks

For each duration, the value starts at max, then transition to min according to the provided easing.

Example

sprite.colorA = Channel.saw("l", Channel.constant(2000), Channel.constant(255), Channel.constant(0), Channel.constant(0))

cos(period, min, max, offset)

Description

Creates a periodic cosine channel.

Parameters

Name Type Description
period ValueChannel Looping duration
min ValueChannel Minimum value output
max ValueChannel max value output
offset ValueChannel How much to offset the wave by

Return types

ValueChannel

Remarks

_

Example

local channel = Channel.cos(Channel.constant(2000), Channel.constant(180), Channel.constant(255), Channel.constant(0))

exp(num, exp)

Description

Creates an exponential channel.

Parameters

Name Type Description
num ValueChannel The base value
exp ValueChannel The exponent

Return types

ValueChannel

Remarks

_

Example

local channel = Channel.exp(Channel.constant(2), Channel.constant(3))

min(channelA, channelB)

Description

Creates a channel that take the min of two other channels.

Parameters

Name Type Description
channelA ValueChannel The first channel
channelB ValueChannel The second channel

Return types

ValueChannel

Remarks

_

Example

local keyChannel = Channel.keyframe()
sprite.colorA = Channel.min(Channel.constant(255), keyChannel)

max(channelA, channelB)

Description

Creates a channel that take the max of two other channels.

Parameters

Name Type Description
channelA ValueChannel The first channel
channelB ValueChannel The second channel

Return types

ValueChannel

Remarks

_

Example

local keyChannel = Channel.keyframe()
sprite.translationZ = Channel.max(Channel.constant(0), keyChannel)

clamp(channelValue, channelMin, channelMax)

Description

Creates a channel that limits the value of a channel between two other.

Parameters

Name Type Description
channelValue ValueChannel The value channel
channelMin ValueChannel The lower bound channel
channelMax ValueChannel The upper bound channel

Return types

ValueChannel

Remarks

_

Example

local keyChannel = Channel.keyframe()
sprite.colorA = Channel.clamp(keyChannel, Channel.constant(50), Channel.constant(200))

condition(control, threshold, ifAbove, ifEqual, ifBelow)

Description

Creates a conditional channel.

Parameters

Name Type Description
control ValueChannel The control channel
threshold ValueChannel The threshold value
ifAbove ValueChannel Value to return when control > threshold
ifEqual ValueChannel Value to return when control == threshold
ifBelow ValueChannel Value to return when control < threshold

Return types

ValueChannel

Remarks

_

Example

local cond = Channel.condition(Context.currentCombo, Channel.constant(100), Channel.constant(1), Channel.constant(0.5), Channel.constant(0))

Clone this wiki locally