FX Class: Roll

Interactive example

Roll Demo
100%
All controls are available across their full ranges. This allows for extreme settings which may cause undesirable audio artifacts such as static, distortion or buzzing.

Overview

The Roll effect a loops the incoming audio synchronized to the current tempo, independently from the player outputting it.

bpm controls the tempo between 40 and 250 beats per minute, while the beats property controls the length of the loops from 1/64 to 4 beats.

The wet property controls the mix of the effect with the original audio between 0 and 1.

One instance allocates around 1600 kb memory.


Implementation example

class SuperpoweredRollProcessor extends SuperpoweredWebAudio.AudioWorkletProcessor {
// Called when the AudioWorklet is ready to start processing audio
onReady() {
this.roll = new this.Superpowered.Roll(
44100 // The initial sample rate in Hz.
96000 // The max samplerate that the roll may need to go up to
);
this.roll.enabled = true;
}
// Runs before the node is destroyed.
// Clean up memory and objects here (such as free allocated linear memory or destruct Superpowered objects).
onDestruct() {
this.roll.destruct();
}
// The shape of the message we pass from our main thread is up to you
onMessageFromMainScope(message) {
// Here is an example of how to apply changes to the Three Band EQ instance
if (typeof message.bpm !== 'undefined') this.roll.bits = message.bpm;
if (typeof message.beats !== 'undefined') this.roll.beats = message.beats;
if (typeof message.wet !== 'undefined') this.roll.wet = message.wet;
}
// This is the process loop which is passed pointers to buffers
// from the WebAudio API (inputBuffer and outputBuffer), with the buffersize (128 samples when running as a native AudioWorklet)
processAudio(inputBuffer, outputBuffer, buffersize) {
// Ensure the samplerate is in sync on every audio processing callback
this.roll.samplerate = this.samplerate;
// Render the output buffers
if (!this.roll.process(inputBuffer.pointer, outputBuffer.pointer, buffersize)) {
for (let n = 0; n < buffersize * 2 ; n++) outputBuffer.array[n] = inputBuffer.array[n];
}
}
}
#include "SuperpoweredRoll.h"
void initRollEffect() {
const unsigned int sampleRate = 44100;
const unsigned int maxSampleRate = 88200;
roll = new Superpowered::Roll(sampleRate, maxSampleRate);
roll->enabled = true;
}
void configureEffect() {
roll->wet = 0.5;
roll->bpm = 128;
roll->beats = 1;
}
void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames, unsigned int samplerate) {
// Ensure the samplerate is in sync on every audio processing callback
roll->samplerate = samplerate;
// Render the output buffers
bool outputChanged = roll->process(interleavedInput, interleavedOutput, numberOfFrames);
...
}

Properties

beats

PROPERTY
The loop length of the effect in beats.
TypeMinMaxDefault
Number
0.015625 (1/64)41

beats

PROPERTY
The loop length of the effect in beats.
TypeMinMaxDefault
float
0.015625 (1/64)41

bpm

PROPERTY
The bpm of the current audio.
TypeMinMaxDefault
Number
4025040

bpm

PROPERTY
The bpm of the current audio.
TypeMinMaxDefault
float
4025040

wet

PROPERTY
The dominance of the effect.
TypeMinMaxDefault
Number
011

wet

PROPERTY
The dominance of the effect.
TypeMinMaxDefault
float
011
Inherited from FX Class

enabled

PROPERTY
Turns the effect on/off. The actual switch will happen on the next process() call for smooth, audio-artifact free operation.
TypeMinMaxDefault
Boolean
false

enabled

PROPERTY
Turns the effect on/off. The actual switch will happen on the next process() call for smooth, audio-artifact free operation.
TypeMinMaxDefault
bool
false

samplerate

PROPERTY
The sample rate of the audio context, you must update if it changes.
TypeMinMaxDefault
Number

samplerate

PROPERTY
The sample rate of the audio context, you must update if it changes.
TypeMinMaxDefault
unsigned int

Methods

  • constructor

    METHOD
    Creates a Roll instance.
    Parameters
    NameTypeDescription
    samplerateNumberThe initial sample rate in Hz.
    maximumSamplerateNumberThe maximum sample rate in Hz to support. The higher the larger the memory usage.
    Returns
    TypeDescription
    Superpowered.RollThe constructed instance.
  • constructor

    METHOD
    Creates a Roll instance.
    Parameters
    NameTypeDefaultDescription
    samplerateunsigned intThe initial sample rate in Hz.
    maximumSamplerateunsigned int96000The maximum sample rate in Hz to support. The higher the larger the memory usage.
    Returns
    TypeDescription
    Superpowered::RollThe constructed instance.
Inherited from FX Class
  • destruct

    METHOD
    Destructor to free Linear Memory.
    Parameters
    None
    Returns
    None
  • process

    METHOD
    Processes/renders the audio. Always call it in the audio processing callback, regardless if the effect is enabled or not for smooth, audio-artifact free operation. It's never blocking for real-time usage.
    Parameters
    NameTypeDescription
    inputNumber (pointer in Linear Memory)32-bit interleaved stereo input.
    outputNumber (pointer in Linear Memory)32-bit interleaved stereo output.
    numberOfFramesNumberNumber of frames to process. Recommendations for best performance: multiply of 4, minimum 64.
    Returns
    TypeDescription
    BooleanIf process() returns with true, the contents of output are replaced with the audio output. If process() returns with false, it indicates silence. The contents of output are not changed in this case (not overwritten with zeros).
  • process

    METHOD
    Processes/renders the audio. Always call it in the audio processing callback, regardless if the effect is enabled or not for smooth, audio-artifact free operation. It's never blocking for real-time usage. You can change all effect properties on any thread, concurrently with process().
    Parameters
    NameTypeDefaultDescription
    inputfloat *32-bit interleaved stereo input.
    outputfloat *32-bit interleaved stereo output.
    numberOfFramesunsigned intNumber of frames to process. Recommendations for best performance: multiply of 4, minimum 64.
    Returns
    TypeDescription
    boolIf process() returns with true, the contents of output are replaced with the audio output. If process() returns with false, it indicates silence. The contents of output are not changed in this case (not overwritten with zeros).
v1.0.6