Waveform

Summary

Functions to generate a variety of waveforms

Class Methods

Waveform:Sine(time, frequency)

Returns the value of a sine wave at the given time

Returns: number (The value of the wave sampled at the given time)

Parameters:

NameTypeDefaultDescription

time

number

The time to sample the waveform at

frequency

number

The frequency of the wave

Example

value = Waveform.Sine(0, 6)

Waveform:Cosine(time, frequency)

Returns the value of a cosine wave at the given time

Returns: number (The value of the wave sampled at the given time)

Parameters:

NameTypeDefaultDescription

time

number

The time to sample the waveform at

frequency

number

The frequency of the wave

Example

value = Waveform.Cosine(0, 6)

Waveform:Triangle(time, frequency)

Returns the value of a triangle wave at the given time

Returns: number (The value of the wave sampled at the given time)

Parameters:

NameTypeDefaultDescription

time

number

The time to sample the waveform at

frequency

number

The frequency of the wave

Example

value = Waveform.Triangle(0, 6)

Waveform:Sawtooth(time, frequency)

Returns the value of a sawtooth wave at the given time

Returns: number (The value of the wave sampled at the given time)

Parameters:

NameTypeDefaultDescription

time

number

The time to sample the waveform at

frequency

number

The frequency of the wave

Example

value = Waveform.Sawtooth(0, 6)

Waveform:Square(time, frequency)

Returns the value of a square wave at the given time

Returns: number (The value of the wave sampled at the given time)

Parameters:

NameTypeDefaultDescription

time

number

The time to sample the waveform at

frequency

number

The frequency of the wave

Example

value = Waveform.Square(0, 6)

Waveform:Pulse(time, frequency, pulseWidth)

Returns the value of a pulse wave with a specified pulse width at the given time, frequency

Returns: number (The value of the wave sampled at the given time)

Parameters:

NameTypeDefaultDescription

time

number

The time to sample the waveform at

frequency

number

The frequency of the wave

pulseWidth

number

The width of the pulse

Example

value = Waveform.Pulse(0, 6, 0.2)

Waveform:Exponent(time, frequency)

Returns the value of an exponential wave at the given time

Returns: number (The value of the wave sampled at the given time)

Parameters:

NameTypeDefaultDescription

time

number

The time to sample the waveform at

frequency

number

The frequency of the wave

Example

value = Waveform.Exponent(0, 6)

Waveform:Power(time, frequency, power)

Returns the value of a power wave at the given time, frequency, and power

Returns: number (The value of the wave sampled at the given time)

Parameters:

NameTypeDefaultDescription

time

number

The time to sample the waveform at

frequency

number

The frequency of the wave

power

number

The power exponent of the wave

Example

value = Waveform.Power(0, 6, 2)

Waveform:Parabolic(time, frequency)

Returns the value of a parabolic wave at the given time

Returns: number (The value of the wave sampled at the given time)

Parameters:

NameTypeDefaultDescription

time

number

The time to sample the waveform at

frequency

number

The frequency of the wave

Example

value = Waveform.Parabolic(0, 6)

Waveform:ExponentialSawtooth(time, frequency, exponent)

Returns the value of an exponential sawtooth wave with the specified exponent at the given time, frequency

Returns: number (The value of the wave sampled at the given time)

Parameters:

NameTypeDefaultDescription

time

number

The time to sample the waveform at

frequency

number

The frequency of the wave

exponent

number

The exponent of the wave

Example

value = Waveform.ExponentialSawtooth(0, 6, 2)

Waveform:PerlinNoise(time, frequency)

Returns the value of a perlin noise function at the given time

Returns: number (The value of the wave sampled at the given time)

Parameters:

NameTypeDefaultDescription

time

number

The time to sample the waveform at

frequency

number

The frequency of the wave

Example

value = Waveform.PerlinNoise(0, 6)

Waveform:WhiteNoise()

Returns the value of a white noise function

Returns: number (The value of the wave sampled at the given time)

Example

value = Waveform.WhiteNoise()

Waveform:BrownNoise(previous)

Returns the value of a brown noise function

Returns: number (The value of the wave sampled at the given time)

Parameters:

NameTypeDefaultDescription

previous

number

The previous calculated value to feed back into the function

Example

value = Waveform.BrownNoise(previousValue)

Waveform:BlueNoise(previous)

Returns the value of a blue noise function

Returns: number (The value of the wave sampled at the given time)

Parameters:

NameTypeDefaultDescription

previous

number

The previous calculated value to feed back into the function

Example

value = Waveform.BlueNoise(previousValue)

Waveform:Sine(time, frequency, duration, sampleRate, amplitude)

Returns a sine wave with the given frequency, duration, and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

time

number

The time to start sampling the waveform at

frequency

number

The frequency of the wave

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:Sine(0, 440, 1, 44100, 0.5)

Waveform:Cosine(time, frequency, duration, sampleRate, amplitude)

Returns a cosine wave with the given frequency, duration, and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

time

number

The time to start sampling the waveform at

frequency

number

The frequency of the wave

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:Cosine(0, 440, 1, 44100, 0.5)

Waveform:Triangle(time, frequency, duration, sampleRate, amplitude)

Returns a triangle wave with the given frequency, duration, and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

time

number

The time to start sampling the waveform at

frequency

number

The frequency of the wave

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:Triangle(0, 440, 1, 44100, 0.5)

Waveform:Sawtooth(time, frequency, duration, sampleRate, amplitude)

Returns a sawtooth wave with the given frequency, duration, and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

time

number

The time to start sampling the waveform at

frequency

number

The frequency of the wave

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:Sawtooth(0, 440, 1, 44100, 0.5)

Waveform:Square(time, frequency, duration, sampleRate, amplitude)

Returns a square wave with the given frequency, duration, and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

time

number

The time to start sampling the waveform at

frequency

number

The frequency of the wave

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:Square(0, 440, 1, 44100, 0.5)

Waveform:Exponent(time, frequency, duration, sampleRate, amplitude)

Returns an exponential wave with the given frequency, duration, and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

time

number

The time to start sampling the waveform at

frequency

number

The frequency of the wave

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:Exponent(0, 440, 1, 44100, 0.5)

Waveform:Parabolic(time, frequency, duration, sampleRate, amplitude)

Returns a parabolic wave with the given frequency, duration, and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

time

number

The time to start sampling the waveform at

frequency

number

The frequency of the wave

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:Parabolic(0, 440, 1, 44100, 0.5)

Waveform:Pulse(time, frequency, pulseWidth, duration, sampleRate, amplitude)

Returns a pulse wave with the given frequency, pulse width, duration, and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

time

number

The time to start sampling the waveform at

frequency

number

The frequency of the wave

pulseWidth

number

The width of the pulse

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:Pulse(0, 440, 0.5, 1, 44100, 0.5)

Waveform:Power(time, frequency, power, duration, sampleRate, amplitude)

Returns a power wave with the given frequency, power, duration, and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

time

number

The time to start sampling the waveform at

frequency

number

The frequency of the wave

power

number

The power exponent of the wave

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:Power(0, 440, 0.5, 1, 44100, 0.5)

Waveform:ExponentialSawtoothWave(time, frequency, exponent, duration, sampleRate, amplitude)

Returns an exponential sawtooth wave with the given frequency, exponent, duration, and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

time

number

The time to start sampling the waveform at

frequency

number

The frequency of the wave

exponent

number

The exponent of the wave

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:ExponentialSawtooth(0, 440, 0.5, 1, 44100, 0.5)

Waveform:PerlinNoise(time, frequency, duration, sampleRate, amplitude)

Returns a perlin noise wave with the given frequency, duration, and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

time

number

The time to start sampling the waveform at

frequency

number

The frequency of the wave

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:PerlinNoise(0, 440, 1, 44100, 0.5)

Waveform:WhiteNoise(duration, sampleRate, amplitude)

Returns a white noise wave with the given duration and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:WhiteNoise(1, 44100, 0.5)

Waveform:BrownNoise(duration, sampleRate, amplitude)

Returns a brown noise wave with the given duration and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:BrownNoise(1, 44100, 0.5)

Waveform:BlueNoise(duration, sampleRate, amplitude)

Returns a blue noise wave with the given duration and sample rate

Returns: number[] (An array of float values)

Parameters:

NameTypeDefaultDescription

duration

number

The duration of samples to generate

sampleRate

number

The sample rate of the generated waveform

amplitude

number

1

The amplitude of the generated waveform

Example

wave = Waveform:BlueNoise(1, 44100, 0.5)

Last updated