Source Class: Advanced Audio Player

Interactive example

Advanced Audio Player Demo
100%
Superpowered WebAssembly Audio SDK v2.6.1

Overview

The Superpowered Advanced Audio Player is an extremely flexible, high performance and feature rich method of audio playback across all platforms. Here a taste of what's possible:

  • Time-stretching and pitch shifting,
  • Beat and tempo sync,
  • Scratching,
  • Tempo bend,
  • Looping,
  • Slip mode,
  • Fast seeking (cached points),
  • Momentum and jog wheel handling,
  • Zero latency, real-time operation.

In short, the Superpowered Advanced Audio Player is the BEST way to accurately play back audio on the web!

You should note that there are some slight unavoidable differences between the JS and C++ implementation in contrast to it's native C++ version.

When using the WebAssembly library you cannot:

  • Directly read files from the file system, due to Javascript sandbox security design. You must load audio from decoded audio buffers in the AudioInMemory format, please see SuperpoweredTrackLoader to see our background worker for help that with that.
  • Open streaming HLS audio urls.

The AdvancedAudioPlayer can be used in a real-time audio processing context or offline processing.

  • Time-stretching and pitch shifting,
  • Beat and tempo sync,
  • Scratching,
  • Tempo bend,
  • Looping,
  • Slip mode,
  • Fast seeking (cached points),
  • Momentum and jog wheel handling,
  • Zero latency, real-time operation,
  • Low memory usage,
  • Thread safety (all methods are thread-safe),
  • Direct iPod music library access.

You may find our loading audio guides useful for more code examples


Supported file formats

The AdvancedAudioPlayer supports playback of the following audio file formats:

  • Stereo or mono PCM WAV and AIFF (16-bit int, 24-bit int, 32-bit int or 32-bit IEEE float).
  • MP3: MPEG-1 Layer III (sample rates: 32000 Hz, 44100 Hz, 48000 Hz). MPEG-2 Layer III is not supported (mp3 with sample rates below 32000 Hz).
  • AAC or HE-AAC in M4A container (iTunes) or ADTS container (.aac).
  • Native Instruments STEMS.
  • Stereo or mono PCM WAV and AIFF (16-bit int, 24-bit int, 32-bit int or 32-bit IEEE float).
  • MP3: MPEG-1 Layer III (sample rates: 32000 Hz, 44100 Hz, 48000 Hz). MPEG-2 Layer III is not supported (mp3 with sample rates below 32000 Hz).
  • AAC or HE-AAC in M4A container (iTunes) or ADTS container (.aac).
  • ALAC/Apple Lossless (on iOS only).
  • HTTP Live Streaming (HLS): VOD/live/event streams, AAC-LC/MP3 in audio files or MPEG-TS audio. Support for byte ranges and AES-128 encryption.
  • Native Instruments STEMS.

Time-stretching and pitch-shifting

The AdvancedAudioPlayer conveniently exposes an internal instance of the Superpowered TimeStretching class, giving you time and pitch manipulation directly from the player. The timeStretching property should be set to true for this.

playbackRate allows control of the speed of the playback in the time domain, while pitchShiftCents allows control of the pitch in the frequency domain. Use them to control speed and pitch individually, but do not use them together to achieve vinyl sound (just turn off timeStretching for that case).

Cents divide each musical note (half step or semitone) on the keyboard into 100. A full octave is represented by 1200 cents. To shift up one note (halfstep or semitone) would be +100. To shift down two notes would be -200.

Setting formantCorrection between 0.0 and 1.0 will adjust the intensity of formant correction that is applied to treat some vocal distortion caused with the application of pitch shifting.

The internal time-stretching algorithm can be changed with timeStretchingSound which internally is referencing the sound property of the Superpowered TimeStretching class, meaning the following values are available:

  • 0 - best to save CPU with slightly lower audio quality.
  • 1 - best for DJ apps, modern and "complete" music.
  • 2 - best for instrumental loops and single instruments.

The rate limits of time stretching are set in the AdvancedAudioPlayer constructor parameters. The lower limit defaults to 0.501 and the upper limit defaults to 2.0. If playbackRate goes above or below these values, then the audio will audibly slow down or speed up.

Pitch bend

On top of the time-stretching and pitch shifting metioned above, you can also apply temporary pitch bends to the audio being played. This is akin to a pitch adjustment slider on a turntable.

Use the pitchBend() method to start the pitch bend, use getCurrentPitchBendPercent() to get the current value and use endContinuousPitchBend() to cancel any pitch bends currently taking effect.

We've put together a little example of that working in practise which you might find useful.


Quantum and Phase

This class is capable of synchronizing with quantum and phase, which is also the primary synchronization concept of Ableton Link and other standards. It means that complete loops can be synchronized too, not just individual beats.

Quantum is the "loop size" in this environment, in other words it's the timespan the player is synchronizing to. Quantum can have any arbitrary value, but the most common practice is setting quantum to the beat length of the loop. For example, if quantum is set to 4, then the quantum length is four beats.

Phase is the position inside the quantum as a percentage, therefore it can have values from 0 (the beginning of the quantum) to 1 (the end of the quantum). For example, if quantum is set to 4, then 0 phase means the beginning of the first beat, 0.25 is the second beat, 0.5 is the third beat and 0.75 is the fourth beat.


Implementation example

import {SuperpoweredWebAudio, SuperpoweredTrackLoader} from 'your superpowered code location path';
class YourCustomProcessor extends SuperpoweredWebAudio.AudioWorkletProcessor {
...
// onReady is called by the Superpowered WebAudioManager when its ready to start processing audio.
onReady() {
// Here we create an instance of the AdvancedAudioPlayer which will use later to play the decoded audio buffer.
this.player = new this.Superpowered.AdvancedAudioPlayer(this.samplerate, 2, 2, 0, 0.501, 2, false);
}
// Runs before the node is destroyed.
// Clean up memory and objects here (such as free allocated linear memory or destruct Superpowered objects).
onDestruct() {
this.player.destruct();
}
// Called from within this class.
loadAudio(url) {
// Notice that we pass in a reference to 'this',
// which is used to call the onMessageFromMainScope callback within this call instance when loaded.
// The fetching and decoding of the audio takes place on dedicated workers, spawned from the main thread. This prevents any blocking.
this.Superpowered.downloadAndDecode(url, this);
}
// SuperpoweredTrackLoader calls this when its finished loading and decoding audio.
onMessageFromMainScope(message) {
if (message.SuperpoweredLoaded) {
const buffer = message.SuperpoweredLoaded.buffer; // ArrayBuffer with the downloaded and decoded audio in AudioInMemory format.
const url = message.SuperpoweredLoaded.url; // The original url of the audio file fetched.
// Once we have the pointer to the buffer, we pass the decoded audio into the AAP instance.
this.player.openMemory(this.Superpowered.arrayBufferToWASM(buffer), false, false);
// Play the audio once loaded. (optional of course).
this.player.play();
}
}
processAudio(inputBuffer, outputBuffer, buffersize, parameters) {
// Ensure the samplerate is in sync on every audio processing callback
this.player.outputSamplerate = this.samplerate;
// Generate the output buffers
if (!this.player.processStereo(outputBuffer.pointer, false, buffersize, 1)) {
this.Superpowered.memorySet(outputBuffer.pointer, 0, buffersize * 8); // 8 bytes for each frame (1 channel is 4 bytes)
}
}

Loading audio

The downloading and decoding of an external asset can be triggered from any worker or worklet, just import SuperpoweredTrackLoader from the library helper files and use it like this:

this.Superpowered.downloadAndDecode('./music/track.mp3', self.onmessage);
self.onmessage = function(message) {
if (message.SuperpoweredLoaded) {
let buffer = message.SuperpoweredLoaded.buffer; // ArrayBuffer with the downloaded and decoded audio in AudioInMemory format.
let url = message.SuperpoweredLoaded.url; // The url of the audio file ('./music/track.mp3' in this example).
// Player example loading the contents of the buffer:
this.player.openMemory(this.Superpowered.arrayBufferToWASM(message.SuperpoweredLoaded.buffer), false, false);
}
}

Additional pseudo code examples

// Creates a player instance.
let player = new Superpowered.AdvancedAudioPlayer(
48000, // The initial sample rate of the player output in hz.
2, // How many positions can be cached in the memory. Jumping to a cached point happens with zero latency. Loops are automatically cached.
2, // The number of seconds to buffer internally for playback and cached points. Minimum 2, maximum 60. Default: 2.
0, // The number of seconds of silence in the negative direction, before the beginning of the track.
0.501, // Will not time-stretch but resample below this playback rate. Default: 0.501f (the recommended value for low CPU load on older mobile devices, such as the first iPad). Will be applied after changing playbackRate or scratching. Default: 0.501f
2, // Will not time-stretch but resample above this playback rate. Default: 2.0f (the recommended value for low CPU load on older mobile devices, such as the first iPad). Will be applied after changing playbackRate or scratching.
false // If true and a Native Instruments STEMS file is loaded, output 4 stereo channels. Default: false (stereo master mix output).
);
player.outputSamplerate = 48000; // The player output sample rate in Hz.
player.timeStretching = true; // Enable/disable time-stretching. Default: true.
player.formantCorrection = false; // Amount of formant correction, between 0 (none) and 1 (full). Default: 0.
player.originalBPM = 120.3; // The original bpm of the current music. There is no auto-bpm detection inside, this must be set to a correct value for syncing. Maximum 300. A value below 20 will be automatically set to 0. Default: 0 (no bpm value known).
player.fixDoubleOrHalfBPM = false; // If true and playbackRate is above 1.4f or below 0.6f, it will sync the tempo as half or double. Default: false.
player.firstBeatMs = 50.24; // Tells where the first beat is (the beatgrid starts). Must be set to a correct value for syncing. Default: 0.
player.defaultQuantum = 4; // Sets the quantum for quantized synchronization. Example: 4 means 4 beats.
player.syncToBpm = 130.14; // A bpm value to sync with. Use 0.0f for no syncing.
player.syncToMsElapsedSinceLastBeat = 89.445; // The number of milliseconds elapsed since the last beat on audio the player has to sync with. Use -1.0 to ignore.
player.syncToPhase = 0.2344; // Used for quantized synchronization. The phase to sync with.
player.syncToQuantum = 8; // Used for quantized synchronization. The quantum to sync with.
player.pitchShiftCents = 0; // Pitch shift cents, from -2400 (two octaves down) to 2400 (two octaves up). Use values representing notes (multiply of 100), between -1200 and 1200 for low CPU load. Default: 0 (no pitch shift).
player.loopOnEOF = true; // If true, jumps back and continues playback. If false, playback stops. Default: false.
player.reverseToForwardAtLoopStart = true; // If this is true with playing backwards and looping, then reaching the beginning of the loop will change playback direction to forwards. Default: false.
player.timeStretchingSound = 1; // The sound parameter of the internal TimeStretching instance.
player.playbackRate = 1.05; // The playback rate. Must be positive and above 0.00001. Default: 1.
Superpowered.AdvancedAudioPlayer.MaxPlaybackRate; // The maximum playback rate or scratching speed: 20.
// Opens a memory location in Superpowered AudioInMemory format, with playback paused.
// Playback rate, pitchShift, timeStretching and syncMode are NOT changed if you open a new file.
player.openMemory(
pointer, // Pointer to a location in WebAssembly Linear Memory. Data in the Superpowered AudioInMemory format.
false, // If true, the player will set the position to skip the initial digital silence of the audio file (up to 10 seconds).
false // If true, the player will check the length of the digital silence at the end of the audio file.
);
// Opens a memory location, with playback paused.
// Playback rate, pitchShift, timeStretching and syncMode are NOT changed if you open a new file.
player.openPCM16AudioInMemory(
pointer, // Pointer to 16-bit integer numbers, raw stereo interleaved pcm audio.
44100, // The sample rate in Hz. Valid from 8192 to 384000.
1000000, // The duration of the audio in frames.
false, // If true, the player will set the position to skip the initial digital silence of the audio file (up to 10 seconds).
false // If true, the player will check the length of the digital silence at the end of the audio file.
);
// Returns with the latest player event. This method should be used in a periodically running code, at one place only, because it returns a specific event just once per open() call.
let event = player.getLatestEvent();
// If getLatestEvent returns with OpenFailed, retrieve the error code or HTTP status code here.
let ec = player.getOpenErrorCode();
// Player events.
Superpowered.AdvancedAudioPlayer.PlayerEvent_None; // Open was not called yet.
Superpowered.AdvancedAudioPlayer.PlayerEvent_Opening; // Trying to open the content.
Superpowered.AdvancedAudioPlayer.PlayerEvent_OpenFailed; // Failed to open the content.
Superpowered.AdvancedAudioPlayer.PlayerEvent_Opened; // Successfully opened the content, playback can start.
// Returns with a human readable error string.
let pointer = Superpowered.AdvancedAudioPlayer.statusCodeToString(
ec // The error code.
)
// Returns true if end-of-file has been reached recently (will never indicate end-of-file if loopOnEOF is true). This method should be used in a periodically running code at one place only, because it returns a specific end-of-file event just once.
let eof = player.eofRecently();
player.syncMode = Superpowered.AdvancedAudioPlayer.SyncMode_TempoAndBeat; // The current sync mode (off, tempo, or tempo+beat). Default: off.
// Synchronization modes.
Superpowered.AdvancedAudioPlayer.SyncMode_None; // No synchronization.
Superpowered.AdvancedAudioPlayer.SyncMode_Tempo; // Sync tempo only.
Superpowered.AdvancedAudioPlayer.SyncMode_TempoAndBeat; // Sync tempo and beat.
// Indicates if the player is waiting for data (such as waiting for a network download).
let waiting = player.isWaitingForBuffering();
// Returns with the length of the digital silence at the beginning of the file if open...() was called with skipSilenceAtBeginning = true, 0 otherwise.
let start = player.getAudioStartMs();
// Returns with the length of the digital silence at the end of the file if open...() was called with measureSilenceAtEnd = true, 0 otherwise.
let end = player.getAudioEndMs();
// The current playhead position in milliseconds. Not changed by any pending setPosition() or seek() call, always accurate regardless of time-stretching and other transformations.
let ms = player.getPositionMs();
// The current position in milliseconds, immediately updated after setPosition() or seek(). Use this for UI display.
let ms = player.getDisplayPositionMs();
// Similar to getDisplayPositionMs(), but as a percentage (0 to 1).
let p = player.getDisplayPositionPercent();
// Similar to getDisplayPositionMs(), but as seconds elapsed.
let sec = player.getDisplayPositionSeconds();
// The position in milliseconds where the player will continue playback after slip mode ends.
let ms = player.afterSlipModeWillJumpBackToPositionMs();
// The duration of the current track in milliseconds. Returns UINT_MAX for live streams.
let durms = player.getDurationMs();
// The duration of the current track in seconds. Returns UINT_MAX for live streams.
let dursec = player.getDurationSeconds();
// Starts playback immediately without any synchronization.
player.play();
// Starts beat or tempo synchronized playback.
player.playSynchronized();
// Starts playback at a specific position. isPlaying() will return false and the position will not be updated until this function succeeds starting playback at the specified position.
// You can call this in a real-time thread (audio processing callback) with a continuously updated time for a precise on-the-fly launch.
player.playSynchronizedToPosition(
123454 // Start position in milliseconds.
);
// Pause playback. There is no need for a "stop" method, this player is very efficient with the battery and has no significant "stand-by" processing.
player.pause(
0, // Momentum in seconds. 0 means to pause immediately.
0 // Enable slip mode for a specific amount of time, or 0 to not slip.
);
// Toggle play/pause (no synchronization).
player.togglePlayback();
// Indicates if the player is playing or paused.
let playing = player.isPlaying();
// Simple seeking to a percentage.
player.seek(
0.1 // The position in percentage.
);
// Precise seeking.
player.setPosition(
1000, // Position in milliseconds.
false, // If true, stops playback.
true, // If the value above is false, makes a beat-synced start possible.
false, // If true and using quantized synchronization, will use the defaultQuantum instead of the syncToQuantum.
false // Wait or start immediately when synchronized.
);
// Caches a position for zero latency seeking.
player.cachePosition(
2000, // Position in milliseconds.
255, // Position identification number. Use this to provide a custom identifier, so you can overwrite the same point later. Use 255 for a point with no identifier.
);
// Processes audio, stereo version. If the return value is true, the buffer has audio output from the player. If false, then the contents of buffer were not changed (typically happens when the player is paused).
// Duration may change to a more precise value after this, because some file formats have no precise duration information.
let notSilence = player.processStereo(
outputPointer, // Pointer to floating point numbers. 32-bit interleaved stereo input/output buffer. Should be numberOfFrames * 8 + 64 bytes big.
false, // If true, the player output will be mixed with the contents of buffer. If false, the contents of buffer will be overwritten with the player output.
128, // The number of frames requested.
1 // Volume. 0 is silence, 1 is "original volume". Changes are automatically smoothed between consecutive processes.
);
// Processes audio, 8 channels version. If the return value is true, the buffer has audio output from the player. If false, then the contents of buffer were not changed (typically happens when the player is paused).
// Duration may change to a more precise value after this, because some file formats have no precise duration information.
let notSilence = player.process8Channels(
outputPointer0, // Pointer to floating point numbers. 32-bit interleaved stereo input/output buffer for the 1st stereo channels. Should be numberOfFrames * 8 + 64 bytes big.
outputPointer1, // Pointer to floating point numbers. 32-bit interleaved stereo input/output buffer for the 2nd stereo channels. Should be numberOfFrames * 8 + 64 bytes big.
outputPointer2, // Pointer to floating point numbers. 32-bit interleaved stereo input/output buffer for the 3rd stereo channels. Should be numberOfFrames * 8 + 64 bytes big.
outputPointer3, // Pointer to floating point numbers. 32-bit interleaved stereo input/output buffer for the 4th stereo channels. Should be numberOfFrames * 8 + 64 bytes big.
false, // If true, the player output will be added to the contents of buffers. If false, the contents of buffers will be overwritten with the player output.
128, // The number of frames requested.
1, // Volume for buffer0. 0 is silence, 1 is "original volume". Changes are automatically smoothed between consecutive processes.
1, // Volume for buffer1. 0 is silence, 1 is "original volume". Changes are automatically smoothed between consecutive processes.
1, // Volume for buffer2. 0 is silence, 1 is "original volume". Changes are automatically smoothed between consecutive processes.
1 // Volume for buffer3. 0 is silence, 1 is "original volume". Changes are automatically smoothed between consecutive processes.
);
// Returns true if a STEMS file was loaded (and the player was initialized with enableStems == true).
let stems = player.isStems();
// Performs the last stage of STEMS processing, the master compressor and limiter. Works only if a STEMS file was loaded.
player.processSTEMSMaster(
input // Pointer to floating point numbers. 32-bit interleaved stereo input buffer.
output // Pointer to floating point numbers. 32-bit interleaved stereo output buffer.
128, // The number of frames to process.
1 // Volume. 0 is silence, 1 is "original volume". Changes are automatically smoothed between consecutive processes.
);
// Returns with a stem's name if a STEMS file was loaded, NULL otherwise.
let pointer = player.getStemName(
0 // The index of the stem.
);
// Returns with a stem's color if a STEMS file was loaded, NULL otherwise.
let pointer = player.getStemColor(
0 // The index of the stem.
);
// The current bpm of the track (as changed by the playback rate).
let bpm = player.getCurrentBpm();
// How many milliseconds have elapsed since the last beat.
let ms = player.getMsElapsedSinceLastBeat();
// Which beat has just happened. Possible values:
// 0 : unknown
// 1 - 1.999: first beat
// 2 - 2.999: second beat
// 3 - 3.999: third beat
// 4 - 4.999: fourth beat
let i = player.getBeatIndex();
// Returns with the current phase for quantized synchronization.
let phase = player.getPhase();
// Returns with the current quantum for quantized synchronization.
let quantum = player.getQuantum();
// Returns with the distance (in milliseconds) to a specific quantum and phase for quantized synchronization.
let ms = player.getMsDifference(
0.5, // The phase to calculate against.
4 // The quantum to calculate against.
);
// If the player is waiting to a synchronization event (such as synchronized playback start or restarting a loop), the return value indicates the time remaining in milliseconds (continously updated). 0 means not waiting to such event.
let ms = player.getMsRemainingToSyncEvent();
// Loop from a start point to some length.
player.loop(
0, // Loop from this milliseconds.
1100, // Loop length in milliseconds.
true, // If the playhead is within the loop, jump to the start or not.
1, // Position identifier. Looping caches startMs, therefore you can specify an identifier (or set to 255 if you don't care).
true, // Beat-synced start (true) or immediate (false).
0, // Number of times to loop. 0 means: until exitLoop() is called.
false, // If true and using quantized synchronization, will use the defaultQuantum instead of the syncToQuantum.
false // Wait (true) or start immediately (false) when synchronized.
);
// Loop between a start and end points.
player.loopBetween(
0, // Loop from this milliseconds.
4000, // Loop to this milliseconds.
true, // If the playhead is within the loop, jump to the start or not.
1, // Position identifier. Looping caches startMs, therefore you can specify an identifier (or set to 255 if you don't care).
true, // Beat-synced start (true) or immediate (false).
0, // Number of times to loop. 0 means: until exitLoop() is called.
false, // If true and using quantized synchronization, will use the defaultQuantum instead of the syncToQuantum.
false // Wait (true) or start immediately (false) when synchronized.
);
// Exit from the current loop.
player.exitLoop(
false // If true, synchronized start or re-synchronization after the loop exit.
);
// Indicates if looping is enabled.
let looping = player.isLooping();
// Returns true if a position is inside the current loop.
let inside = player.msInLoop(
150 // The position in milliseconds.
);
// Returns with the position of the closest beat.
let ms = player.closestBeatMs(
6002, // The position in milliseconds where to find the closest beat.
0 // Set to 1-4 to retrieve the position of a specific beat index relative to ms, or 0 for any beat index.
);
// Returns with the beat index of the closest beat.
let bi = player.closestBeatIndex(
50 // The position in milliseconds where to find the closest beat.
);
// Sets playback direction.
player.setReverse(
false, // True: reverse. False: forward.
0 // Enable slip mode for a specific amount of time, or 0 to not slip.
);
// If true, the player is playing backwards.
let rev = player.isReverse();
// Starts on changes pitch bend (temporary playback rate change).
player.pitchBend(
0.1, // The maximum playback rate range for pitch bend, should be between 0.01 and 0.3 (1% and 30%).
false, // Use time-stretching for pitch bend or not (false makes it "audible").
true, // True: faster, false: slower.
500 // How long to maintain the pitch bend state in milliseconds. A value >= 1000 will hold until endContinuousPitchBend is called.
);
// Ends pitch bend.
player.endContinuousPitchBend();
// Returns with the distance (in milliseconds) to the beatgrid while using pitch bend for correction.
let ms = player.getBendOffsetMs();
// Reset the pitch bend offset to the beatgrid to zero.
player.resetBendMsOffset();
// Indicates if returning from scratching or reverse playback will maintain the playback position as if the player had never entered into scratching or reverse playback.
let slip = player.isPerformingSlip();
// "Virtual jog wheel" or "virtual turntable" handling.
player.jogTouchBegin(
300, // Sets the sensitivity of the virtual wheel. Use around 2300 for pixel-perfect touchscreen waveform control.
Superpowered.AdvancedAudioPlayer.Jogmode_Scratch, // Jog wheel mode (scratching, pitch bend, or parameter set in the 0-1 range).
1000, // Enables slip mode for a specific amount of time for scratching, or 0 to not slip.
);
// A jog wheel should send some "ticks" with the movement. A waveform's movement in pixels for example.
player.jogTick(
600, // The ticks value.
true, // Use time-stretching for pitch bend or not (false makes it "audible").
0.1, // The maximum playback rate change for pitch bend, should be between 0.01f and 0.3f (1% and 30%).
20, // How long to maintain the pitch bend state in milliseconds. A value >= 1000 will hold until endContinuousPitchBend is called.
false, // True: if there was no jogTouchBegin, turn to JogMode_Parameter mode. False: if there was no jogTouchBegin, turn to JogMode_PitchBend mode.
);
// Call this when the jog touch ends.
player.jogTouchEnd(
0, // The decelerating rate for momentum. Set to 0 for automatic.
true // Beat-synced start after decelerating.
);
// Direct turntable handling. Call this when scratching starts. This is an advanced method, use it only if not using the jogT... methods.
player.startScratch(
0, // Enable slip mode for a specific amount of time for scratching, or 0 to not slip.
true // Stop playback or not.
);
// Scratch movement. This is an advanced method, use it only if not using the jogT... methods.
player.scratch(
1.1, // The current speed (pitch).
0.5 // Smoothing factor. Should be between 0.05 (max. smoothing) and 1.0 (no smoothing).
);
// Ends scratching. This is an advanced method, use it only if not using the jogT... methods.
player.endScratch(
true // Return to the previous playback state (direction, speed) or not.
);
// Indicates if the player is in scratching mode.
let scratching = player.isScratching();
// If jog wheel mode is JogMode_Parameter, returns with the current parameter typically in the range of -1 to 1, or less than -1000000.0 if there was no jog wheel movement. processStereo or processMulti updates this value, therefore we recommend reading it after those calls were made, in the same thread.
let p = player.getJogParameter();
// Jog Wheel Mode, to be used with the jogT... methods.
Superpowered.AdvancedAudioPlayer.Jogmode_Scratch; // Jog wheel controls scratching.
Superpowered.AdvancedAudioPlayer.Jogmode_PitchBend; // Jog wheel controls pitch bend.
Superpowered.AdvancedAudioPlayer.Jogmode_Parameter; // Jog wheel changes a parameter.
// Destructor (to free up memory).
player.destruct();

Please note that the player has an internal message queue to achieve thread safety without blocking, and the actual work is performed by the processStereo or processMulti methods. Therefore, those methods must be continously called in a real-time thread (such as the audio processing callback) to maintain operation, even if the player doesn't play anything!

void playMusic() {
player = new Superpowered::AdvancedAudioPlayer(44100, 0);
player->open("lycka.mp3");
player->play();
}
void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames, unsigned int samplerate) {
// Ensure the samplerate is in sync on every audio processing callback
player->outputSamplerate = samplerate;
// Check for latest events on the player
if (player->getLatestEvent() == Superpowered::AdvancedAudioPlayer::PlayerEvent_Opened) {
// Audio file has been opened
}
// Generate the output buffers
bool silence = !player->processStereo(interleavedOutput, false, numberOfFrames, volume);
}

Properties

defaultQuantum

PROPERTY
Sets the quantum for quantized synchronization. Example: 4 means 4 beats.
TypeMinMaxDefault
Number
1

defaultQuantum

PROPERTY
Sets the quantum for quantized synchronization. Example: 4 means 4 beats.
TypeMinMaxDefault
double
1

firstBeatMs

PROPERTY
The start position of the beatgrid in milliseconds. Must be set to a correct value for syncing.
TypeMinMaxDefault
Number
0

firstBeatMs

PROPERTY
The start position of the beatgrid in milliseconds. Must be set to a correct value for syncing.
TypeMinMaxDefault
double
0

fixDoubleOrHalfBPM

PROPERTY
If true and playbackRate is above 1.4 or below 0.6, it will sync the tempo as half or double.
TypeMinMaxDefault
Boolean
false

fixDoubleOrHalfBPM

PROPERTY
If true and playbackRate is above 1.4 or below 0.6, it will sync the tempo as half or double.
TypeMinMaxDefault
bool
false

formantCorrection

PROPERTY
Amount of formant correction.
TypeMinMaxDefault
Number
010

formantCorrection

PROPERTY
Amount of formant correction.
TypeMinMaxDefault
float
010

HLSAutomaticAlternativeSwitching

PROPERTY
If true, then the player will automatically switch between the HLS alternatives according to the available network bandwidth.
TypeMinMaxDefault
bool
true

HLSBufferingSeconds

PROPERTY
How many seconds ahead of the playback position to download.
TypeMinMaxDefault
int
HLSDownloadRemaining

HLSLiveLatencySeconds

PROPERTY
When connecting or reconnecting to a HLS live stream, the player will try to skip audio to maintain this latency. Default: -1 (the player wil not skip audio and the live stream starts at the first segment specified by the server).
TypeMinMaxDefault
char
-1

HLSMaximumDownloadAttempts

PROPERTY
How many times to retry if a HLS segment download fails. Default: 100.
TypeMinMaxDefault
int
0100

loopOnEOF

PROPERTY
If true, jumps back and continues playback. If false, playback stops.
TypeMinMaxDefault
Boolean
false

loopOnEOF

PROPERTY
If true, jumps back and continues playback. If false, playback stops.
TypeMinMaxDefault
bool
false

originalBPM

PROPERTY
The original bpm of the current music. There is no auto-bpm detection inside, this must be set to a correct value for syncing.
TypeMinMaxDefault
Number
A value below 20 will be automatically set to 0.3000 (no bpm value known)

originalBPM

PROPERTY
The original bpm of the current music. There is no auto-bpm detection inside, this must be set to a correct value for syncing.
TypeMinMaxDefault
double
A value below 20 will be automatically set to 0.3000 (no bpm value known)

outputSamplerate

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

outputSamplerate

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

pitchShiftCents

PROPERTY
Pitch shift cents, from -2400 (two octaves down) to 2400 (two octaves up). Low CPU load for multiples of 100 between -1200 and 1200.
TypeMinMaxDefault
Number
-240024000

pitchShiftCents

PROPERTY
Pitch shift cents, from -2400 (two octaves down) to 2400 (two octaves up). Low CPU load for multiples of 100 between -1200 and 1200.
TypeMinMaxDefault
int
-240024000

playbackRate

PROPERTY
The playback rate.
TypeMinMaxDefault
Number
0.00001MaxPlaybackRate1

playbackRate

PROPERTY
The playback rate.
TypeMinMaxDefault
double
0.00001MaxPlaybackRate1

reverseToForwardAtLoopStart

PROPERTY
If this is true with playing backwards and looping, then reaching the beginning of the loop will change playback direction to forwards.
TypeMinMaxDefault
Boolean
false

reverseToForwardAtLoopStart

PROPERTY
If this is true with playing backwards and looping, then reaching the beginning of the loop will change playback direction to forwards.
TypeMinMaxDefault
bool
false

syncMode

PROPERTY
The current sync mode (off, tempo, or tempo+beat). Default: off.
TypeMinMaxDefault
AdvancedAudioPlayer.SyncMode.SyncMode_None
AdvancedAudioPlayer.SyncMode.SyncMode_Tempo 
AdvancedAudioPlayer.SyncMode.SyncMode_TempoAndBeat
AdvancedAudioPlayer.SyncMode.SyncMode_None

syncMode

PROPERTY
The current sync mode (off, tempo, or tempo+beat). Default: off.
TypeMinMaxDefault
AdvancedAudioPlayer::SyncMode::SyncMode_None
AdvancedAudioPlayer::SyncMode::SyncMode_Tempo 
AdvancedAudioPlayer::SyncMode::SyncMode_TempoAndBeat
AdvancedAudioPlayer::SyncMode::SyncMode_None

syncToBpm

PROPERTY
A bpm value to sync with. Use 0 for no syncing.
TypeMinMaxDefault
Number
00

syncToBpm

PROPERTY
A bpm value to sync with. Use 0 for no syncing.
TypeMinMaxDefault
double
00

syncToMsElapsedSinceLastBeat

PROPERTY
The number of milliseconds elapsed since the last beat on audio the player has to sync with. Use -1.0 to ignore.
TypeMinMaxDefault
Number
-1

syncToMsElapsedSinceLastBeat

PROPERTY
The number of milliseconds elapsed since the last beat on audio the player has to sync with. Use -1.0 to ignore.
TypeMinMaxDefault
double
-1

syncToPhase

PROPERTY
Used for quantized synchronization. The phase to sync with between 0 and 1. Use -1 to ignore.
TypeMinMaxDefault
Number
-11-1

syncToPhase

PROPERTY
Used for quantized synchronization. The phase to sync with between 0 and 1. Use -1 to ignore.
TypeMinMaxDefault
double
-11-1

syncToQuantum

PROPERTY
Used for quantized synchronization. The quantum to sync with. Use -1 to ignore.
TypeMinMaxDefault
Number
-1

syncToQuantum

PROPERTY
Used for quantized synchronization. The quantum to sync with. Use -1 to ignore.
TypeMinMaxDefault
double
-1

timeStretching

PROPERTY
Enable/disable time-stretching.
TypeMinMaxDefault
Boolean
true

timeStretching

PROPERTY
Enable/disable time-stretching.
TypeMinMaxDefault
bool
true

timeStretchingSound

PROPERTY
The sound parameter of the internal TimeStretching instance.
TypeMinMaxDefault
0 (best to save CPU with slightly lower audio quality)
1 (best for DJ apps, modern and "complete" music)
2 (best for instrumental loops and single instruments)
1

timeStretchingSound

PROPERTY
The sound parameter of the internal TimeStretching instance.
TypeMinMaxDefault
0 (best to save CPU with slightly lower audio quality)
1 (best for DJ apps, modern and "complete" music)
2 (best for instrumental loops and single instruments)
1

Constants

  • Superpowered.AdvancedAudioPlayer

    CONSTANTS
    Constants in the main AdvancedAudioPlayer namespace.
    ValueDescription
    Jogmode_ParameterJog wheel changes a parameter.
    Jogmode_PitchBendJog wheel controls pitch bend.
    Jogmode_ScratchJog wheel controls scratching.
    PlayerEvent_NoneOpen was not called yet.
    PlayerEvent_OpenedSuccessfully opened the content, playback can start.
    PlayerEvent_OpenFailedFailed to open the content.
    PlayerEvent_OpeningTrying to open the content.
    PlayerEvent_ConnectionLostNetwork connection lost to the HLS stream or progressive download. Can only be "recovered" by a new open(). May happen after PlayerEvent_Opened has been delivered.
    PlayerEvent_ProgressiveDownloadFinishedThe content has finished downloading and is fully available locally. May happen after PlayerEvent_Opened has been delivered.
    SyncMode_NoneNo synchronization.
    SyncMode_TempoSync tempo only.
    SyncMode_TempoAndBeatSync tempo and beat.
    MaxPlaybackRateThe maximum playback rate or scratching speed: 20.
    HLSDownloadEverythingWill download everything after the playback position until the end.
    HLSDownloadRemainingDownloads everything from the beginning to the end, regardless the playback position.
  • Superpowered::AdvancedAudioPlayer

    CONSTANTS
    Constants in the main AdvancedAudioPlayer namespace.
    ValueDescription
    Jogmode_ParameterJog wheel changes a parameter.
    Jogmode_PitchBendJog wheel controls pitch bend.
    Jogmode_ScratchJog wheel controls scratching.
    PlayerEvent_NoneOpen was not called yet.
    PlayerEvent_OpenedSuccessfully opened the content, playback can start.
    PlayerEvent_OpenFailedFailed to open the content.
    PlayerEvent_OpeningTrying to open the content.
    PlayerEvent_ConnectionLostNetwork connection lost to the HLS stream or progressive download. Can only be "recovered" by a new open(). May happen after PlayerEvent_Opened has been delivered.
    PlayerEvent_ProgressiveDownloadFinishedThe content has finished downloading and is fully available locally. May happen after PlayerEvent_Opened has been delivered.
    SyncMode_NoneNo synchronization.
    SyncMode_TempoSync tempo only.
    SyncMode_TempoAndBeatSync tempo and beat.
    MaxPlaybackRateThe maximum playback rate or scratching speed: 20.
    HLSDownloadEverythingWill download everything after the playback position until the end.
    HLSDownloadRemainingDownloads everything from the beginning to the end, regardless the playback position.

Methods

  • constructor

    METHOD
    Creates an instance of the AdvancedAudioPlayer class.
    Parameters
    NameTypeDescription
    samplerateNumberThe initial sample rate in Hz.
    cachedPointCountNumberHow many positions can be cached in the memory. Jumping to a cached point happens with zero latency. Loops are automatically cached.
    internalBufferSizeSecondsNumber The number of seconds to buffer internally for playback and cached points. The value 0 enables "offline mode", where the player can not be used for real-time playback, but can process audio in an iteration. If not zero, the AdvancedAudioPlayer can only be used for real-time playback. Default: 2.
    negativeSecondsNumberThe number of seconds of silence in the negative direction, before the beginning of the track.
    minimumTimestretchingPlaybackRateNumberWill not time-stretch but resample below this playback rate. Default: 0.501f (the recommended value for low CPU load on older mobile devices, such as the first iPad). Will be applied after changing playbackRate or scratching.
    maximumTimestretchingPlaybackRateNumberWill not time-stretch but resample above this playback rate. Default: 2.0f (the recommended value for low CPU load on older mobile devices, such as the first iPad). Will be applied after changing playbackRate or scratching.
    enableStemsBooleanIf true and a Native Instruments STEMS file is loaded, output 4 stereo channels. Default: false (stereo master mix output).
    Returns
    TypeDescription
    Superpowered.AdvancedAudioPlayerThe constructed instance.
  • constructor

    METHOD
    Creates an instance of the AdvancedAudioPlayer class.
    Parameters
    NameTypeDefaultDescription
    samplerateunsigned intThe initial sample rate in Hz.
    cachedPointCountunsigned charHow many positions can be cached in the memory. Jumping to a cached point happens with zero latency. Loops are automatically cached.
    internalBufferSizeSecondsunsigned int2 The number of seconds to buffer internally for playback and cached points. The value 0 enables "offline mode", where the player can not be used for real-time playback, but can process audio in an iteration. If not zero, the AdvancedAudioPlayer can only be used for real-time playback. Default: 2.
    negativeSecondsunsigned int0The number of seconds of silence in the negative direction, before the beginning of the track.
    minimumTimestretchingPlaybackRatefloat0.501Will not time-stretch but resample below this playback rate. Default: 0.501f (the recommended value for low CPU load on older mobile devices, such as the first iPad). Will be applied after changing playbackRate or scratching.
    maximumTimestretchingPlaybackRatefloat2Will not time-stretch but resample above this playback rate. Default: 2.0f (the recommended value for low CPU load on older mobile devices, such as the first iPad). Will be applied after changing playbackRate or scratching.
    enableStemsboolfalseIf true and a Native Instruments STEMS file is loaded, output 4 stereo channels. Default: false (stereo master mix output).
    Returns
    TypeDescription
    Superpowered::AdvancedAudioPlayerThe constructed instance.
  • afterSlipModeWillJumpBackToPositionMs

    METHOD
    The position in milliseconds where the player will continue playback after slip mode ends.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • afterSlipModeWillJumpBackToPositionMs

    METHOD
    The position in milliseconds where the player will continue playback after slip mode ends.
    Parameters
    None
    Returns
    TypeDescription
    double
  • cachePosition

    METHOD
    Caches a position for zero latency seeking.
    Parameters
    NameTypeDescription
    msNumberPosition in milliseconds.
    pointIDNumberUse this to provide a custom identifier, so you can overwrite the same point later. Use 255 for a point with no identifier.
    Returns
    None
  • cachePosition

    METHOD
    Caches a position for zero latency seeking.
    Parameters
    NameTypeDefaultDescription
    msdoublePosition in milliseconds.
    pointIDunsigned charUse this to provide a custom identifier, so you can overwrite the same point later. Use 255 for a point with no identifier.
    Returns
    None
  • closestBeatIndex

    METHOD
    Returns with the beat index of the closest beat.
    Parameters
    NameTypeDescription
    msNumberThe position in milliseconds where to find the closest beat.
    Returns
    TypeDescription
    Number
  • closestBeatIndex

    METHOD
    Returns with the beat index of the closest beat.
    Parameters
    NameTypeDefaultDescription
    msdoubleThe position in milliseconds where to find the closest beat.
    Returns
    TypeDescription
    unsigned char
  • closestBeatMs

    METHOD
    Returns with the position of the closest beat.
    Parameters
    NameTypeDescription
    msNumberThe position in milliseconds where to find the closest beat.
    beatIndexNumberSet to 1-4 to retrieve the position of a specific beat index relative to ms, or 0 for any beat index.
    Returns
    TypeDescription
    Number
  • closestBeatMs

    METHOD
    Returns with the position of the closest beat.
    Parameters
    NameTypeDefaultDescription
    msdoubleThe position in milliseconds where to find the closest beat.
    beatIndexunsined char0Set to 1-4 to retrieve the position of a specific beat index relative to ms, or 0 for any beat index.
    Returns
    TypeDescription
    double
  • endContinuousPitchBend

    METHOD
    Ends pitch bend.
    Parameters
    None
    Returns
    None
  • endContinuousPitchBend

    METHOD
    Ends pitch bend.
    Parameters
    None
    Returns
    None
  • endScratch

    METHOD
    Ends scratching.
    Parameters
    NameTypeDescription
    returnToStateBeforeScratchBooleanReturn to the previous playback state (direction, speed) or not.
    Returns
    None
  • endScratch

    METHOD
    Ends scratching.
    Parameters
    NameTypeDefaultDescription
    returnToStateBeforeScratchboolReturn to the previous playback state (direction, speed) or not.
    Returns
    None
  • eofRecently

    METHOD
    Returns true if end-of-file has been reached just now or a few moments before (will never indicate end-of-file if loopOnEOF is true). This method should be used in a periodically running code at one place only, because it returns a specific end-of-file event just once. Best to be used in a UI loop.
    Parameters
    None
    Returns
    TypeDescription
    Boolean
  • eofRecently

    METHOD
    Returns true if end-of-file has been reached just now or a few moments before (will never indicate end-of-file if loopOnEOF is true). This method should be used in a periodically running code at one place only, because it returns a specific end-of-file event just once. Best to be used in a UI loop.
    Parameters
    None
    Returns
    TypeDescription
    bool
  • exitLoop

    METHOD
    Exit from the current loop.
    Parameters
    NameTypeDescription
    synchronisedStartBooleanSynchronized start or re-synchronization after the loop exit
    Returns
    None
  • exitLoop

    METHOD
    Exit from the current loop.
    Parameters
    NameTypeDefaultDescription
    synchronisedStartboolfalseSynchronized start or re-synchronization after the loop exit
    Returns
    None
  • getAudioEndMs

    METHOD
    Returns with the length of the digital silence at the end of the file if open... was called with measureSilenceAtEnd = true, 0 otherwise.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getAudioEndMs

    METHOD
    Returns with the length of the digital silence at the end of the file if open... was called with measureSilenceAtEnd = true, 0 otherwise.
    Parameters
    None
    Returns
    TypeDescription
    double
  • getAudioStartMs

    METHOD
    Returns with the length of the digital silence at the beginning of the file if open... was called with skipSilenceAtBeginning = true, 0 otherwise.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getAudioStartMs

    METHOD
    Returns with the length of the digital silence at the beginning of the file if open... was called with skipSilenceAtBeginning = true, 0 otherwise.
    Parameters
    None
    Returns
    TypeDescription
    double
  • getBeatIndex

    METHOD
    Which beat has just happened. Possible values: 0 : unknown, 1 - 1.999: first beat, 2 - 2.999: second beat, 3 - 3.999: third beat, 4 - 4.999: fourth beat
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getBeatIndex

    METHOD
    Which beat has just happened. Possible values: 0 : unknown, 1 - 1.999: first beat, 2 - 2.999: second beat, 3 - 3.999: third beat, 4 - 4.999: fourth beat
    Parameters
    None
    Returns
    TypeDescription
    float
  • getBendOffsetMs

    METHOD
    Returns with the distance (in milliseconds) to the beatgrid while using pitch bend for correction.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getBendOffsetMs

    METHOD
    Returns with the distance (in milliseconds) to the beatgrid while using pitch bend for correction.
    Parameters
    None
    Returns
    TypeDescription
    double
  • getBufferedEndPercent

    METHOD
    Returns with the end of the buffered part. Will always be 0 for non-network sources (such as local files).
    Parameters
    None
    Returns
    TypeDescription
    float
  • getBufferedStartPercent

    METHOD
    Returns with the beginning of the buffered part. Will always be 0 for non-network sources (such as local files).
    Parameters
    None
    Returns
    TypeDescription
    float
  • getCurrentBpm

    METHOD
    The current bpm of the track (as changed by the playback rate).
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getCurrentBpm

    METHOD
    The current bpm of the track (as changed by the playback rate).
    Parameters
    None
    Returns
    TypeDescription
    double
  • getCurrentHLSBPS

    METHOD
    For HLS only. Returns with the actual network throughput (for best stream selection).
    Parameters
    None
    Returns
    TypeDescription
    unsigned int
  • getCurrentPitchBendPercent

    METHOD
    Returns with the current pitch bend percent. Will be 1 if there is no pitch bend happening.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getCurrentPitchBendPercent

    METHOD
    Returns with the current pitch bend percent. Will be 1 if there is no pitch bend happening.
    Parameters
    None
    Returns
    TypeDescription
    float
  • getDisplayPositionMs

    METHOD
    The current position in milliseconds, immediately updated after setPosition or seek. Use this for UI display.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getDisplayPositionMs

    METHOD
    The current position in milliseconds, immediately updated after setPosition or seek. Use this for UI display.
    Parameters
    None
    Returns
    TypeDescription
    double
  • getDisplayPositionPercent

    METHOD
    Similar to getDisplayPositionMs, but as a percentage (0 to 1).
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getDisplayPositionPercent

    METHOD
    Similar to getDisplayPositionMs, but as a percentage (0 to 1).
    Parameters
    None
    Returns
    TypeDescription
    float
  • getDisplayPositionSeconds

    METHOD
    Similar to getDisplayPositionMs, but as seconds elapsed.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getDisplayPositionSeconds

    METHOD
    Similar to getDisplayPositionMs, but as seconds elapsed.
    Parameters
    None
    Returns
    TypeDescription
    int
  • getDurationMs

    METHOD
    The duration of the current track in milliseconds.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getDurationMs

    METHOD
    The duration of the current track in milliseconds. Returns UINT_MAX for live streams.
    Parameters
    None
    Returns
    TypeDescription
    unsigned int
  • getDurationSeconds

    METHOD
    The duration of the current track in seconds.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getDurationSeconds

    METHOD
    The duration of the current track in seconds. Returns UINT_MAX for live streams.
    Parameters
    None
    Returns
    TypeDescription
    unsigned int
  • getFullyDownloadedFilePath

    METHOD
    Returns with the full filesystem path of the locally cached file if the player is in the PlayerEvent_Opened_ProgressiveDownloadFinished state, NULL otherwise.
    Parameters
    None
    Returns
    TypeDescription
    const char *
  • getJogParameter

    METHOD
    If jog wheel mode is JogMode_Parameter, returns with the current parameter typically in the range of -1 to 1, or less than -1000000.0 if there was no jog wheel movement. processStereo or processMulti updates this value, therefore it's recommended to read it after those calls were made, in the same thread.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getJogParameter

    METHOD
    If jog wheel mode is JogMode_Parameter, returns with the current parameter typically in the range of -1 to 1, or less than -1000000.0 if there was no jog wheel movement. processStereo or processMulti updates this value, therefore it's recommended to read it after those calls were made, in the same thread.
    Parameters
    None
    Returns
    TypeDescription
    double
  • getLatestEvent

    METHOD
    Returns with the latest player event. This method should be used in a periodically running code, at one place only, because it returns a specific event just once per open call. Best to be used in a UI loop.
    Parameters
    None
    Returns
    TypeDescription
    Superpowered.AdvancedAudioPlayer.PlayerEvent
  • getLatestEvent

    METHOD
    Returns with the latest player event. This method should be used in a periodically running code, at one place only, because it returns a specific event just once per open call. Best to be used in a UI loop.
    Parameters
    None
    Returns
    TypeDescription
    Superpowered::AdvancedAudioPlayer::PlayerEvent
  • getMsDifference

    METHOD
    Returns with the distance (in milliseconds) to a specific quantum and phase for quantized synchronization.
    Parameters
    NameTypeDescription
    phaseNumberThe phase to calculate against.
    quantumNumberThe quantum to calculate against.
    Returns
    TypeDescription
    Number
  • getMsDifference

    METHOD
    Returns with the distance (in milliseconds) to a specific quantum and phase for quantized synchronization.
    Parameters
    NameTypeDefaultDescription
    phasedoubleThe phase to calculate against.
    quantumdoubleThe quantum to calculate against.
    Returns
    TypeDescription
    double
  • getMsElapsedSinceLastBeat

    METHOD
    How many milliseconds elapsed since the last beat.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getMsElapsedSinceLastBeat

    METHOD
    How many milliseconds elapsed since the last beat.
    Parameters
    None
    Returns
    TypeDescription
    double
  • getMsRemainingToSyncEvent

    METHOD
    If the player is waiting to a synchronization event (such as synchronized playback start or restarting a loop), the return value indicates the time remaining in milliseconds (continously updated). 0 means not waiting to such event.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getMsRemainingToSyncEvent

    METHOD
    If the player is waiting to a synchronization event (such as synchronized playback start or restarting a loop), the return value indicates the time remaining in milliseconds (continously updated). 0 means not waiting to such event.
    Parameters
    None
    Returns
    TypeDescription
    double
  • getOpenErrorCode

    METHOD
    If getLatestEvent returns with OpenFailed, retrieve the error code or HTTP status code here.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getOpenErrorCode

    METHOD
    If getLatestEvent returns with OpenFailed, retrieve the error code or HTTP status code here.
    Parameters
    None
    Returns
    TypeDescription
    int
  • getPhase

    METHOD
    Returns with the current phase for quantized synchronization, between 0 (beginning of the quantum) and 1 (end of the quantum).
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getPhase

    METHOD
    Returns with the current phase for quantized synchronization, between 0 (beginning of the quantum) and 1 (end of the quantum).
    Parameters
    None
    Returns
    TypeDescription
    double
  • getPositionMs

    METHOD
    The current playhead position in milliseconds. Not changed by any pending setPosition or seek call, always accurate regardless of time-stretching and other transformations.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getPositionMs

    METHOD
    The current playhead position in milliseconds. Not changed by any pending setPosition or seek call, always accurate regardless of time-stretching and other transformations.
    Parameters
    None
    Returns
    TypeDescription
    double
  • getQuantum

    METHOD
    Returns with the current quantum for quantized synchronization, such as 2 for two beats, 4 for four beats, etc...
    Parameters
    None
    Returns
    TypeDescription
    Number
  • getQuantum

    METHOD
    Returns with the current quantum for quantized synchronization, such as 2 for two beats, 4 for four beats, etc...
    Parameters
    None
    Returns
    TypeDescription
    double
  • getStemColor

    METHOD
    Returns with a stem's color if a STEMS file was loaded, NULL otherwise.
    Parameters
    NameTypeDescription
    indexNumberThe index of the stem.
    Returns
    TypeDescription
    Number (pointer in Linear Memory)Linear Memory pointer. You can use Superpowered.toString(this_pointer) to create a JavaScript string from it.
  • getStemColor

    METHOD
    Returns with a stem's color if a STEMS file was loaded, NULL otherwise.
    Parameters
    NameTypeDefaultDescription
    indexunsigned charThe index of the stem.
    Returns
    TypeDescription
    const char *The color as string.
  • getStemName

    METHOD
    Returns with a stem's name if a STEMS file was loaded, NULL otherwise.
    Parameters
    NameTypeDescription
    indexNumberThe index of the stem.
    Returns
    TypeDescription
    Number (pointer in Linear Memory)Linear Memory pointer. You can use Superpowered.toString(this_pointer) to create a JavaScript string from it.
  • getStemName

    METHOD
    Returns with a stem's name if a STEMS file was loaded, NULL otherwise.
    Parameters
    NameTypeDefaultDescription
    indexunsigned charThe index of the stem.
    Returns
    TypeDescription
    const char *The name.
  • isLooping

    METHOD
    Indicates if looping is enabled.
    Parameters
    None
    Returns
    TypeDescription
    Boolean
  • isLooping

    METHOD
    Indicates if looping is enabled.
    Parameters
    None
    Returns
    TypeDescription
    bool
  • isPerformingSlip

    METHOD
    Indicates if returning from scratching or reverse playback will maintain the playback position as if the player had never entered into scratching or reverse playback.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • isPerformingSlip

    METHOD
    Indicates if returning from scratching or reverse playback will maintain the playback position as if the player had never entered into scratching or reverse playback.
    Parameters
    None
    Returns
    TypeDescription
    boolean
  • isPlaying

    METHOD
    Indicates if the player is playing or paused.
    Parameters
    None
    Returns
    TypeDescription
    Boolean
  • isPlaying

    METHOD
    Indicates if the player is playing or paused.
    Parameters
    None
    Returns
    TypeDescription
    bool
  • isReverse

    METHOD
    If true, the player is playing backwards.
    Parameters
    None
    Returns
    TypeDescription
    Boolean
  • isReverse

    METHOD
    If true, the player is playing backwards.
    Parameters
    None
    Returns
    TypeDescription
    bool
  • isScratching

    METHOD
    Indicates if the player is in scratching mode.
    Parameters
    None
    Returns
    TypeDescription
    Boolean
  • isScratching

    METHOD
    Indicates if the player is in scratching mode.
    Parameters
    None
    Returns
    TypeDescription
    bool
  • isStems

    METHOD
    Returns true if a STEMS file was loaded (and the player was initialized with enableStems == true).
    Parameters
    None
    Returns
    TypeDescription
    Boolean
  • isStems

    METHOD
    Returns true if a STEMS file was loaded (and the player was initialized with enableStems == true).
    Parameters
    None
    Returns
    TypeDescription
    bool
  • isWaitingForBuffering

    METHOD
    Indicates if the player is waiting for data (such as waiting for a network download).
    Parameters
    None
    Returns
    TypeDescription
    Boolean
  • isWaitingForBuffering

    METHOD
    Indicates if the player is waiting for data (such as waiting for a network download).
    Parameters
    None
    Returns
    TypeDescription
    bool
  • jogTick

    METHOD
    A jog wheel should send some 'ticks' with the movement. A waveform's movement in pixels for example.
    Parameters
    NameTypeDescription
    valueNumberThe ticks value.
    bendStretchBooleanUse time-stretching for pitch bend or not (false makes it 'audible').
    bendMaxPercentNumberThe maximum playback rate change for pitch bend, should be between 0.01 and 0.3 (1% and 30%).
    bendHoldMsNumberHow long to maintain the pitch bend state. A value >= 1000 will hold until endContinuousPitchBend is called.
    parameterModeIfNoJogTouchBeginBooleanTrue: if there was no jogTouchBegin, turn to JogMode_Parameter mode. False: if there was no jogTouchBegin, turn to JogMode_PitchBend mode.
    Returns
    None
  • jogTick

    METHOD
    A jog wheel should send some 'ticks' with the movement. A waveform's movement in pixels for example.
    Parameters
    NameTypeDefaultDescription
    valueintThe ticks value.
    bendStretchboolUse time-stretching for pitch bend or not (false makes it 'audible').
    bendMaxPercentfloatThe maximum playback rate change for pitch bend, should be between 0.01 and 0.3 (1% and 30%).
    bendHoldMsunsigned intHow long to maintain the pitch bend state. A value >= 1000 will hold until endContinuousPitchBend is called.
    parameterModeIfNoJogTouchBeginboolTrue: if there was no jogTouchBegin, turn to JogMode_Parameter mode. False: if there was no jogTouchBegin, turn to JogMode_PitchBend mode.
    Returns
    None
  • jogTouchBegin

    METHOD
    'Virtual jog wheel' or 'virtual turntable' handling.
    Parameters
    NameTypeDescription
    ticksPerTurnNumberSets the sensitivity of the virtual wheel. Use around 2300 for pixel-perfect touchscreen waveform control.
    modeNumberJog wheel mode (scratching, pitch bend, or parameter set in the 0-1 range).
    scratchSlipMsNumberEnables slip mode for a specific amount of time for scratching, or 0 to not slip.
    Returns
    None
  • jogTouchBegin

    METHOD
    'Virtual jog wheel' or 'virtual turntable' handling.
    Parameters
    NameTypeDefaultDescription
    ticksPerTurnintSets the sensitivity of the virtual wheel. Use around 2300 for pixel-perfect touchscreen waveform control.
    modeSuperpowered::AdvancedAudioPlayer:JogModeJog wheel mode (scratching, pitch bend, or parameter set in the 0-1 range).
    scratchSlipMsunsigned int0Enables slip mode for a specific amount of time for scratching, or 0 to not slip.
    Returns
    None
  • jogTouchEnd

    METHOD
    Call this when the jog touch ends.
    Parameters
    NameTypeDescription
    decelerateNumberThe decelerating rate for momentum. Set to 0.0f for automatic.
    synchronisedStartBooleanBeat-synced start after decelerating.
    Returns
    None
  • jogTouchEnd

    METHOD
    Call this when the jog touch ends.
    Parameters
    NameTypeDefaultDescription
    deceleratefloatThe decelerating rate for momentum. Set to 0.0f for automatic.
    synchronisedStartboolBeat-synced start after decelerating.
    Returns
    None
  • loop

    METHOD
    Loop from a start point to some length.
    Parameters
    NameTypeDescription
    startMsNumberLoop from this milliseconds.
    lengthMsNumberLoop length in milliseconds.
    jumpToStartMsBooleanIf the playhead is within the loop, jump to startMs or not.
    pointIDNumberLooping caches startMs, therefore you can specify a pointID too (or set to 255 if you don't care).
    synchronisedStartBooleanBeat-synced start.
    numLoopsNumberNumber of times to loop. 0 means: until exitLoop is called.
    forceDefaultQuantumBooleanIf true and using quantized synchronization, will use the defaultQuantum instead of the syncToQuantum.
    preferWaitingforSynchronisedStartBooleanWait or start immediately when synchronized.
    Returns
    None
  • loop

    METHOD
    Loop from a start point to some length.
    Parameters
    NameTypeDefaultDescription
    startMsdoubleLoop from this milliseconds.
    lengthMsdoubleLoop length in milliseconds.
    jumpToStartMsboolIf the playhead is within the loop, jump to startMs or not.
    pointIDUnsigned charLooping caches startMs, therefore you can specify a pointID too (or set to 255 if you don't care).
    synchronisedStartboolBeat-synced start.
    numLoopsunsigned int0Number of times to loop. 0 means: until exitLoop is called.
    forceDefaultQuantumboolfalseIf true and using quantized synchronization, will use the defaultQuantum instead of the syncToQuantum.
    preferWaitingforSynchronisedStartboolfalseWait or start immediately when synchronized.
    Returns
    None
  • loopBetween

    METHOD
    Loop between a start and end points.
    Parameters
    NameTypeDescription
    startMsNumberLoop from this milliseconds.
    endMsNumberLoop to this milliseconds.
    jumpToStartMsBooleanIf the playhead is within the loop, jump to startMs or not.
    pointIDNumberLooping caches startMs, therefore you can specify a pointID too (or set to 255 if you don't care).
    synchronisedStartBooleanBeat-synced start.
    numLoopsNumberNumber of times to loop. 0 means: until exitLoop is called.
    forceDefaultQuantumBooleanIf true and using quantized synchronization, will use the defaultQuantum instead of the syncToQuantum.
    preferWaitingforSynchronisedStartBooleanWait or start immediately when synchronized.
    Returns
    None
  • loopBetween

    METHOD
    Loop between a start and end points.
    Parameters
    NameTypeDefaultDescription
    startMsdoubleLoop from this milliseconds.
    endMsdoubleLoop to this milliseconds.
    jumpToStartMsboolIf the playhead is within the loop, jump to startMs or not.
    pointIDUnsigned charLooping caches startMs, therefore you can specify a pointID too (or set to 255 if you don't care).
    synchronisedStartboolBeat-synced start.
    numLoopsunsigned int0Number of times to loop. 0 means: until exitLoop is called.
    forceDefaultQuantumboolfalseIf true and using quantized synchronization, will use the defaultQuantum instead of the syncToQuantum.
    preferWaitingforSynchronisedStartboolfalseWait or start immediately when synchronized.
    Returns
    None
  • msInLoop

    METHOD
    Returns true if a position is inside the current loop.
    Parameters
    None
    Returns
    TypeDescription
    Boolean
  • msInLoop

    METHOD
    Returns true if a position is inside the current loop.
    Parameters
    None
    Returns
    TypeDescription
    bool
  • onMediaserverInterrupt

    METHOD
    Apple's built-in codec may be used in some cases, such as decoding ALAC files. Call this after a media server reset or audio session interrupt to resume playback.
    Parameters
    None
    Returns
    None
  • open [1/2]

    METHOD
    Opens an audio file with playback paused. Playback rate, pitchShift, timeStretching and syncMode are NOT changed if you open a new file.
    Parameters
    NameTypeDefaultDescription
    pathconst char *Full file system path or progressive download path (http or https).
    customHTTPRequestSuperpowered::httpRequest *0If custom HTTP communication is required (such as sending http headers for authorization), pass a fully prepared http request object. The player will copy this object.
    skipSilenceAtBeginningboolfalseIf true, the player will set the position to skip the initial digital silence of the audio file (up to 10 seconds).
    measureSilenceAtEndboolfalseIf true, the player will check the length of the digital silence at the end of the audio file.
    Returns
    None
  • open [2/2]

    METHOD
    Opens an audio file with playback paused. Playback rate, pitchShift, timeStretching and syncMode are NOT changed if you open a new file.
    Parameters
    NameTypeDefaultDescription
    pathconst char *Full file system path or progressive download path (http or https).
    offsetintThe byte offset inside the path.
    lengthintThe byte length from the offset.
    customHTTPRequestSuperpowered::httpRequest *0If custom HTTP communication is required (such as sending http headers for authorization), pass a fully prepared http request object. The player will copy this object.
    skipSilenceAtBeginningboolfalseIf true, the player will set the position to skip the initial digital silence of the audio file (up to 10 seconds).
    measureSilenceAtEndboolfalseIf true, the player will check the length of the digital silence at the end of the audio file.
    Returns
    None
  • openHLS

    METHOD
    Opens a HTTP Live Streaming stream with playback paused. Playback rate, pitchShift, timeStretching and syncMode are NOT changed if you open a new one. Do not call openHLS in the audio processing thread.
    Parameters
    NameTypeDefaultDescription
    urlconst char *Stream URL.
    customHTTPRequestSuperpowered::httpRequest *0If custom HTTP communication is required (such as sending http headers for authorization), pass a fully prepared http request object. The player will copy this object.
    Returns
    None
  • openMemory

    METHOD
    Opens a memory location in Superpowered AudioInMemory format, with playback paused. This feature supports progressive loading via AudioInMemory::append (and the AudioInMemory doesn't even need to hold any data when openMemory is called). Playback rate, pitchShift, timeStretching and syncMode are NOT changed if you open a new file.
    Parameters
    NameTypeDescription
    pointerNumber (pointer in Linear Memory)Pointer to data in Superpowered AudioInMemory format, pointing to stereo interleaved 16-bit PCM audio inside.
    skipSilenceAtBeginningBooleanIf true, the player will set the position to skip the initial digital silence of the audio file (up to 10 seconds).
    measureSilenceAtEndBooleanIf true, the player will check the length of the digital silence at the end of the audio file.
    Returns
    None
  • openMemory

    METHOD
    Opens a memory location in Superpowered AudioInMemory format, with playback paused. This feature supports progressive loading via AudioInMemory::append (and the AudioInMemory doesn't even need to hold any data when openMemory is called). Playback rate, pitchShift, timeStretching and syncMode are NOT changed if you open a new file.
    Parameters
    NameTypeDefaultDescription
    pointervoid *Pointer to data in Superpowered AudioInMemory format, pointing to stereo interleaved 16-bit PCM audio inside.
    skipSilenceAtBeginningboolfalseIf true, the player will set the position to skip the initial digital silence of the audio file (up to 10 seconds).
    measureSilenceAtEndboolfalseIf true, the player will check the length of the digital silence at the end of the audio file.
    Returns
    None
  • openPCM16AudioInMemory

    METHOD
    Opens raw 16-bit sterteo PCM audio in memory, with playback paused. Playback rate, pitchShift, timeStretching and syncMode are NOT changed if you open a new file.
    Parameters
    NameTypeDescription
    pointerNumber (pointer in Linear Memory)Stereo interleaved 16-bit PCM audio.
    samplerateNumberThe sample rate in Hz. Valid from 8192 to 384000.
    durationFramesNumberThe duration of the audio in frames.
    skipSilenceAtBeginningBooleanIf true, the player will set the position to skip the initial digital silence of the audio file (up to 10 seconds).
    measureSilenceAtEndBooleanIf true, the player will check the length of the digital silence at the end of the audio file.
    Returns
    None
  • openPCM16AudioInMemory

    METHOD
    Opens raw 16-bit sterteo PCM audio in memory, with playback paused. Playback rate, pitchShift, timeStretching and syncMode are NOT changed if you open a new file.
    Parameters
    NameTypeDefaultDescription
    pointervoid *Stereo interleaved 16-bit PCM audio.
    samplerateunsigned intThe sample rate in Hz. Valid from 8192 to 384000.
    durationFramesunsigned intThe duration of the audio in frames.
    skipSilenceAtBeginningboolfalseIf true, the player will set the position to skip the initial digital silence of the audio file (up to 10 seconds).
    measureSilenceAtEndboolfalseIf true, the player will check the length of the digital silence at the end of the audio file.
    Returns
    None
  • pause

    METHOD
    Pause playback. There is no need for a 'stop' method, this player is very efficient with the battery and has no significant 'stand-by' processing.
    Parameters
    NameTypeDescription
    decelerateSecondsNumberOptional momentum. 0 means to pause immediately.
    slipMsNumberEnable slip mode for a specific amount of time, or 0 to not slip.
    Returns
    None
  • pause

    METHOD
    Pause playback. There is no need for a 'stop' method, this player is very efficient with the battery and has no significant 'stand-by' processing.
    Parameters
    NameTypeDefaultDescription
    decelerateSecondsfloat0Optional momentum. 0 means to pause immediately.
    slipMsunsigned int0Enable slip mode for a specific amount of time, or 0 to not slip.
    Returns
    None
  • pitchBend

    METHOD
    Starts on changes pitch bend (temporary playback rate change).
    Parameters
    NameTypeDescription
    maxPercentNumberThe maximum playback rate range for pitch bend, should be between 0.01f and 0.3f (1% and 30%).
    bendStretchNumberUse time-stretching for pitch bend or not (false makes it 'audible'). 1 or 0
    fasterNumberTrue (1): faster, false (0): slower.
    hostMsNumber
    Returns
    None
  • pitchBend

    METHOD
    Starts on changes pitch bend (temporary playback rate change).
    Parameters
    NameTypeDefaultDescription
    maxPercentfloatThe maximum playback rate range for pitch bend, should be between 0.01f and 0.3f (1% and 30%).
    bendStretchBooleanUse time-stretching for pitch bend or not (false makes it 'audible'). 1 or 0
    fasterBooleanTrue (1): faster, false (0): slower.
    hostMsunsigned int
    Returns
    None
  • play

    METHOD
    Starts playback immediately without any synchronization.
    Parameters
    None
    Returns
    None
  • play

    METHOD
    Starts playback immediately without any synchronization.
    Parameters
    None
    Returns
    None
  • playSynchronized

    METHOD
    Starts beat or tempo synchronized playback.
    Parameters
    None
    Returns
    None
  • playSynchronized

    METHOD
    Starts beat or tempo synchronized playback.
    Parameters
    None
    Returns
    None
  • playSynchronizedToPosition

    METHOD
    Starts playback at a specific position. isPlaying will return false and the position will not be updated until this function succeeds starting playback at the specified position. You can call this in a real-time thread (audio processing callback) with a continuously updated time for a precise on-the-fly launch.
    Parameters
    NameTypeDescription
    positionMsNumber
    Returns
    None
  • playSynchronizedToPosition

    METHOD
    Starts playback at a specific position. isPlaying will return false and the position will not be updated until this function succeeds starting playback at the specified position. You can call this in a real-time thread (audio processing callback) with a continuously updated time for a precise on-the-fly launch.
    Parameters
    NameTypeDefaultDescription
    positionMsdouble
    Returns
    None
  • process8Channels

    METHOD
    Outputs audio, 8 channels version.
    Parameters
    NameTypeDescription
    buffer0Number (pointer in Linear Memory)32-bit interleaved stereo input/output buffer for the 1st stereo channels. Should be numberOfFrames * 8 + 64 bytes big.
    buffer1Number (pointer in Linear Memory)32-bit interleaved stereo input/output buffer for the 1st stereo channels. Should be numberOfFrames * 8 + 64 bytes big.
    buffer2Number (pointer in Linear Memory)32-bit interleaved stereo input/output buffer for the 1st stereo channels. Should be numberOfFrames * 8 + 64 bytes big.
    buffer3Number (pointer in Linear Memory)32-bit interleaved stereo input/output buffer for the 1st stereo channels. Should be numberOfFrames * 8 + 64 bytes big.
    mixBooleanIf true, the player output will be mixed with the contents of buffer. If false, the contents of buffer will be overwritten with the player output.
    numberOfFramesNumberThe number of frames requested.
    volume0NumberVolume for buffer0. 0 is silence, 1 is 'original volume'. Changes are automatically smoothed between consecutive processes.
    volume1NumberVolume for buffer1. 0 is silence, 1 is 'original volume'. Changes are automatically smoothed between consecutive processes.
    volume2NumberVolume for buffer2. 0 is silence, 1 is 'original volume'. Changes are automatically smoothed between consecutive processes.
    volume3NumberVolume for buffer3. 0 is silence, 1 is 'original volume'. Changes are automatically smoothed between consecutive processes.
    Returns
    TypeDescription
    Booleantrue: buffers have audio output from the player. false: the contents of the buffers were not changed (typically happens when the player is paused).
  • process8Channels

    METHOD
    Outputs audio, 8 channels version.
    Parameters
    NameTypeDefaultDescription
    buffer0float *32-bit interleaved stereo input/output buffer for the 1st stereo channels. Should be numberOfFrames * 8 + 64 bytes big.
    buffer1float *32-bit interleaved stereo input/output buffer for the 1st stereo channels. Should be numberOfFrames * 8 + 64 bytes big.
    buffer2float *32-bit interleaved stereo input/output buffer for the 1st stereo channels. Should be numberOfFrames * 8 + 64 bytes big.
    buffer3float *32-bit interleaved stereo input/output buffer for the 1st stereo channels. Should be numberOfFrames * 8 + 64 bytes big.
    mixboolIf true, the player output will be mixed with the contents of buffer. If false, the contents of buffer will be overwritten with the player output.
    numberOfFramesunsigned intThe number of frames requested.
    volume0float1.0fVolume for buffer0. 0 is silence, 1 is 'original volume'. Changes are automatically smoothed between consecutive processes.
    volume1float1.0fVolume for buffer1. 0 is silence, 1 is 'original volume'. Changes are automatically smoothed between consecutive processes.
    volume2float1.0fVolume for buffer2. 0 is silence, 1 is 'original volume'. Changes are automatically smoothed between consecutive processes.
    volume3float1.0fVolume for buffer3. 0 is silence, 1 is 'original volume'. Changes are automatically smoothed between consecutive processes.
    Returns
    TypeDescription
    booltrue: buffers have audio output from the player. false: the contents of the buffers were not changed (typically happens when the player is paused).
  • processSTEMSMaster

    METHOD
    Performs the last stage of STEMS processing, the master compressor and limiter. Works only if a STEMS file was loaded.
    Parameters
    NameTypeDescription
    inputNumber (pointer in Linear Memory)32-bit interleaved stereo input buffer.
    outputNumber (pointer in Linear Memory)32-bit interleaved stereo output buffer.
    numberOfFramesNumberThe number of frames requested.
    volumeNumberOutput volume. 0 is silence, 1 is 'original volume'. Changes are automatically smoothed between consecutive processes.
    Returns
    None
  • processSTEMSMaster

    METHOD
    Performs the last stage of STEMS processing, the master compressor and limiter. Works only if a STEMS file was loaded.
    Parameters
    NameTypeDefaultDescription
    inputfloat *32-bit interleaved stereo input buffer.
    outputfloat *32-bit interleaved stereo output buffer.
    numberOfFramesunsigned intThe number of frames requested.
    volumefloat1.0fOutput volume. 0 is silence, 1 is 'original volume'. Changes are automatically smoothed between consecutive processes.
    Returns
    None
  • processStereo

    METHOD
    Outputs audio, stereo version.
    Parameters
    NameTypeDescription
    bufferNumber (pointer in Linear Memory)32-bit interleaved stereo input/output buffer. Should be numberOfFrames * 8 + 64 bytes big.
    mixBooleanIf true, the player output will be mixed with the contents of buffer. If false, the contents of buffer will be overwritten with the player output.
    numberOfFramesNumberThe number of frames requested.
    volumeNumber0 is silence, 1 is 'original volume'. Changes are automatically smoothed between consecutive processes.
    Returns
    TypeDescription
    Booleantrue: buffer has audio output from the player. false: the contents of buffer were not changed (typically happens when the player is paused).
  • processStereo

    METHOD
    Outputs audio, stereo version.
    Parameters
    NameTypeDefaultDescription
    bufferfloat *32-bit interleaved stereo input/output buffer. Should be numberOfFrames * 8 + 64 bytes big.
    mixboolIf true, the player output will be mixed with the contents of buffer. If false, the contents of buffer will be overwritten with the player output.
    numberOfFramesunsigned intThe number of frames requested.
    volumefloat1.0f0 is silence, 1 is 'original volume'. Changes are automatically smoothed between consecutive processes.
    Returns
    TypeDescription
    booltrue: buffer has audio output from the player. false: the contents of buffer were not changed (typically happens when the player is paused).
  • resetBendMsOffset

    METHOD
    Reset the pitch bend offset to the beatgrid to zero.
    Parameters
    None
    Returns
    TypeDescription
    Number
  • resetBendMsOffset

    METHOD
    Reset the pitch bend offset to the beatgrid to zero.
    Parameters
    None
    Returns
    TypeDescription
    double
  • scratch

    METHOD
    Scratch movement.
    Parameters
    NameTypeDescription
    pitchNumberThe current speed.
    smoothingNumberShould be between 0.05f (max. smoothing) and 1.0f (no smoothing).
    Returns
    None
  • scratch

    METHOD
    Scratch movement.
    Parameters
    NameTypeDefaultDescription
    pitchdoubleThe current speed.
    smoothingfloatShould be between 0.05f (max. smoothing) and 1.0f (no smoothing).
    Returns
    None
  • seek

    METHOD
    Simple seeking to a percentage.
    Parameters
    NameTypeDescription
    percentNumber
    Returns
    None
  • seek

    METHOD
    Simple seeking to a percentage.
    Parameters
    NameTypeDefaultDescription
    percentdouble
    Returns
    None
  • setPosition

    METHOD
    Precise seeking.
    Parameters
    NameTypeDescription
    msNumberPosition in milliseconds.
    andStopBooleanIf true, stops playback.
    synchronisedStartBooleanIf andStop is false, makes a beat-synced start possible.
    forceDefaultQuantumBooleanIf true and using quantized synchronization, will use the defaultQuantum instead of the syncToQuantum.
    preferWaitingforSynchronisedStartBooleanWait or start immediately when synchronized.
    Returns
    None
  • setPosition

    METHOD
    Precise seeking.
    Parameters
    NameTypeDefaultDescription
    msdoublePosition in milliseconds.
    andStopboolIf true, stops playback.
    synchronisedStartboolIf andStop is false, makes a beat-synced start possible.
    forceDefaultQuantumboolfalseIf true and using quantized synchronization, will use the defaultQuantum instead of the syncToQuantum.
    preferWaitingforSynchronisedStartboolfalseWait or start immediately when synchronized.
    Returns
    None
  • setReverse

    METHOD
    Sets playback direction.
    Parameters
    NameTypeDescription
    reverseNumberTrue: reverse. False: forward.
    slipMsNumberEnable slip mode for a specific amount of time, or 0 to not slip.
    Returns
    None
  • setReverse

    METHOD
    Sets playback direction.
    Parameters
    NameTypeDefaultDescription
    reverseBooleanTrue: reverse. False: forward.
    slipMsunsigned int0Enable slip mode for a specific amount of time, or 0 to not slip.
    Returns
    None
  • startScratch

    METHOD
    Direct turntable handling. Call this when scratching starts.
    Parameters
    NameTypeDescription
    decelerateNumberThe decelerating rate for momentum. Set to 0.0f for automatic.
    synchronisedStartBooleanBeat-synced start after decelerating.
    Returns
    None
  • startScratch

    METHOD
    Direct turntable handling. Call this when scratching starts.
    Parameters
    NameTypeDefaultDescription
    deceleratefloatThe decelerating rate for momentum. Set to 0.0f for automatic.
    synchronisedStartboolBeat-synced start after decelerating.
    Returns
    None
  • togglePlayback

    METHOD
    Toggle play/pause (no synchronization).
    Parameters
    None
    Returns
    None
  • togglePlayback

    METHOD
    Toggle play/pause (no synchronization).
    Parameters
    None
    Returns
    None
v1.0.33