High performance advanced audio player with: More...
#include "SuperpoweredAdvancedAudioPlayer.h"
Public Member Functions | |
AdvancedAudioPlayer (unsigned int samplerate, unsigned char cachedPointCount, unsigned int internalBufferSizeSeconds=2, unsigned int negativeSeconds=0) | |
Creates a player instance with the current sample rate value. More... | |
~AdvancedAudioPlayer () | |
void | cachePosition (double ms, unsigned char pointID=255) |
Caches a position for zero latency seeking. More... | |
double | closestBeatMs (double ms, unsigned char *beatIndex=0) |
void | endContinuousPitchBend () |
Ends pitch bend. More... | |
void | endScratch (bool returnToStateBeforeScratch) |
Ends scratching. More... | |
bool | eofRecently () |
void | exitLoop (bool synchronisedStart=false) |
Exit from the current loop. More... | |
double | getAudioStartMs () |
float | getBeatIndex () |
double | getBendOffsetMs () |
float | getBufferedEndPercent () |
float | getBufferedStartPercent () |
double | getCurrentBpm () |
unsigned int | getCurrentHLSBPS () |
double | getDisplayPositionMs () |
float | getDisplayPositionPercent () |
int | getDisplayPositionSeconds () |
unsigned int | getDurationMs () |
unsigned int | getDurationSeconds () |
const char * | getFullyDownloadedFilePath () |
PlayerEvent | getLatestEvent () |
double | getMsDifference (double phase, double quantum) |
double | getMsElapsedSinceLastBeat () |
int | getOpenErrorCode () |
double | getPhase () |
double | getPositionMs () |
double | getQuantum () |
const char * | getStemColor (unsigned char index) |
const char * | getStemName (unsigned char index) |
double | getWaitingForSyncStartMs () |
double | getWillSyncMs () |
bool | isLooping () |
bool | isPerformingSlip () |
bool | isPlaying () |
bool | isReverse () |
bool | isScratching () |
bool | isStems () |
bool | isWaitingForBuffering () |
void | jogTick (int value, bool bendStretch, float bendMaxPercent, unsigned int bendHoldMs, bool parameterModeIfNoJogTouchBegin) |
A jog wheel should send some "ticks" with the movement. More... | |
void | jogTouchBegin (int ticksPerTurn, JogMode mode, unsigned int scratchSlipMs=0) |
"Virtual jog wheel" or "virtual turntable" handling. More... | |
void | jogTouchEnd (float decelerate, bool synchronisedStart) |
Call this when the jog touch ends. More... | |
bool | loop (double startMs, double lengthMs, bool jumpToStartMs, unsigned char pointID, bool synchronisedStart, unsigned int numLoops=0, bool forceDefaultQuantum=false, bool preferWaitingforSynchronisedStart=false) |
Loop from a start point to some length. More... | |
bool | loopBetween (double startMs, double endMs, bool jumpToStartMs, unsigned char pointID, bool synchronisedStart, unsigned int numLoops=0, bool forceDefaultQuantum=false, bool preferWaitingforSynchronisedStart=false) |
Loop between a start and end points. More... | |
bool | msInLoop (double ms) |
void | onMediaserverInterrupt () |
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. More... | |
void | open (const char *path, Superpowered::httpRequest *customHTTPRequest=0, bool skipSilenceAtBeginning=false) |
Opens an audio file with playback paused. More... | |
void | open (const char *path, int offset, int length, Superpowered::httpRequest *customHTTPRequest=0, bool skipSilenceAtBeginning=false) |
Opens an audio file with playback paused. More... | |
void | openHLS (const char *url, Superpowered::httpRequest *customHTTPRequest=0) |
Opens a HTTP Live Streaming stream with playback paused. More... | |
void | pause (float decelerateSeconds=0, unsigned int slipMs=0) |
Pause playback. More... | |
void | pitchBend (float maxPercent, bool bendStretch, bool faster, unsigned int holdMs) |
Starts on changes pitch bend (temporary playback rate change). More... | |
void | play () |
Starts playback immediately without any synchronization. More... | |
void | playSynchronized () |
Starts beat or tempo synchronized playback. More... | |
void | playSynchronizedToPosition (double positionMs) |
Starts playback at a specific position. More... | |
bool | processMulti (float **buffers, bool mix, unsigned int numberOfFrames, float *volumes, double *jogParameter=0) |
Processes audio, multi-channel version. More... | |
void | processSTEMSMaster (float *input, float *output, unsigned int numberOfFrames, float volume=1.0f) |
Performs the last stage of STEMS processing, the master compressor and limiter. More... | |
bool | processStereo (float *buffer, bool mix, unsigned int numberOfFrames, float volume=1.0f, double *jogParameter=0) |
Processes audio, stereo version. More... | |
void | resetBendMsOffset () |
Reset the pitch bend offset to the beatgrid to zero. More... | |
void | scratch (double pitch, float smoothing) |
Scratch movement. More... | |
void | seek (double percent) |
Simple seeking to a percentage. More... | |
void | setPosition (double ms, bool andStop, bool synchronisedStart, bool forceDefaultQuantum=false, bool preferWaitingforSynchronisedStart=false) |
Precise seeking. More... | |
void | setReverse (bool reverse, unsigned int slipMs=0) |
Sets playback direction. More... | |
void | startScratch (unsigned int slipMs, bool stopImmediately) |
Direct turntable handling. More... | |
void | togglePlayback () |
Toggle play/pause (no synchronization). More... | |
Static Public Member Functions | |
static const char * | getTempFolderPath () |
static void | setTempFolder (const char *path) |
Set the folder to store for temporary files. More... | |
static const char * | statusCodeToString (int code) |
Public Attributes | |
double | defaultQuantum |
Sets the quantum for quantized synchronization. Example: 4 means 4 beats. More... | |
bool | enableStems |
If true and a Native Instruments STEMS file is loaded, output 4 stereo channels. Default: false (stereo master mix output). More... | |
double | firstBeatMs |
Tells where the first beat is (the beatgrid starts). Must be set to a correct value for syncing. Default: 0. More... | |
bool | fixDoubleOrHalfBPM |
If true and playbackRate is above 1.4f or below 0.6f, it will sync the tempo as half or double. Default: false. More... | |
bool | HLSAutomaticAlternativeSwitching |
If true, then the player will automatically swtich between the HLS alternatives according to the available network bandwidth. Default: true. More... | |
int | HLSBufferingSeconds |
How many seconds ahead of the playback position to download. Default value: HLS_DOWNLOAD_REMAINING. More... | |
char | HLSLiveLatencySeconds |
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). More... | |
int | HLSMaximumDownloadAttempts |
How many times to retry if a HLS segment download fails. Default: 100. More... | |
bool | loopOnEOF |
If true, jumps back and continues playback. If false, playback stops. Default: false. More... | |
float | maximumTimestretchingPlaybackRate |
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. More... | |
float | minimumTimestretchingPlaybackRate |
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. More... | |
double | originalBPM |
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). More... | |
unsigned int | outputSamplerate |
The player output sample rate in Hz. More... | |
int | pitchShiftCents |
Pitch shift cents, from -1200 (one octave down) to 1200 (one octave up). Use values representing notes (multiply of 100) for low CPU load. Default: 0 (no pitch shift). More... | |
double | playbackRate |
The playback rate. Must be positive and above 0.00001. Default: 1. More... | |
bool | reverseToForwardAtLoopStart |
If this is true with playing backwards and looping, then reaching the beginning of the loop will change playback direction to forwards. Default: false. More... | |
SyncMode | syncMode |
The current sync mode (off, tempo, or tempo+beat). Default: off. More... | |
double | syncToBpm |
A bpm value to sync with. Use 0.0f for no syncing. More... | |
double | syncToMsElapsedSinceLastBeat |
The number of milliseconds elapsed since the last beat on audio the player has to sync with. Use -1.0 to ignore. More... | |
double | syncToPhase |
Used for quantized synchronization. The phase to sync with. More... | |
double | syncToQuantum |
Used for quantized synchronization. The quantum to sync with. More... | |
bool | timeStretching |
Enable/disable time-stretching. Default: true. More... | |
Static Public Attributes | |
static const int | HLSDownloadEverything |
Will download everything after the playback position until the end. More... | |
static const int | HLSDownloadRemaining |
Downloads everything from the beginning to the end, regardless the playback position. More... | |
static const float | MaxPlaybackRate |
The maximum playback rate or scratching speed: 20. More... | |
Private Member Functions | |
AdvancedAudioPlayer (const AdvancedAudioPlayer &) | |
AdvancedAudioPlayer & | operator= (const AdvancedAudioPlayer &) |
Private Attributes | |
PlayerInternals * | internals |
PlayerSwap * | swap |
High performance advanced audio player with:
Superpowered::AdvancedAudioPlayer::AdvancedAudioPlayer | ( | unsigned int | samplerate, |
unsigned char | cachedPointCount, | ||
unsigned int | internalBufferSizeSeconds = 2 , |
||
unsigned int | negativeSeconds = 0 |
||
) |
Creates a player instance with the current sample rate value.
samplerate | The initial sample rate of the player output in hz. |
cachedPointCount | How many positions can be cached in the memory. Jumping to a cached point happens with zero latency. Loops are automatically cached. |
internalBufferSizeSeconds | The number of seconds to buffer internally for playback and cached points. Minimum 2, maximum 60. Default: 2. |
negativeSeconds | The number of seconds of silence in the negative direction, before the beginning of the track. |
Superpowered::AdvancedAudioPlayer::~AdvancedAudioPlayer | ( | ) |
|
private |
void Superpowered::AdvancedAudioPlayer::cachePosition | ( | double | ms, |
unsigned char | pointID = 255 |
||
) |
Caches a position for zero latency seeking.
ms | Position in milliseconds. |
pointID | Use this to provide a custom identifier, so you can overwrite the same point later. Use 255 for a point with no identifier. |
double Superpowered::AdvancedAudioPlayer::closestBeatMs | ( | double | ms, |
unsigned char * | beatIndex = 0 |
||
) |
ms | The position in milliseconds where to find the closest beat. |
beatIndex | Pointer to a beat index value. Set to NULL if beat index is not important. Set to 0 to retrieve the beat index of the position. Set to 1-4 to retrieve the position of a specific beat index. |
void Superpowered::AdvancedAudioPlayer::endContinuousPitchBend | ( | ) |
Ends pitch bend.
void Superpowered::AdvancedAudioPlayer::endScratch | ( | bool | returnToStateBeforeScratch | ) |
Ends scratching.
returnToStateBeforeScratch | Return to the previous playback state (direction, speed) or not. |
bool Superpowered::AdvancedAudioPlayer::eofRecently | ( | ) |
void Superpowered::AdvancedAudioPlayer::exitLoop | ( | bool | synchronisedStart = false | ) |
Exit from the current loop.
synchronisedStart | Synchronized start or re-synchronization after the loop exit. |
double Superpowered::AdvancedAudioPlayer::getAudioStartMs | ( | ) |
float Superpowered::AdvancedAudioPlayer::getBeatIndex | ( | ) |
double Superpowered::AdvancedAudioPlayer::getBendOffsetMs | ( | ) |
float Superpowered::AdvancedAudioPlayer::getBufferedEndPercent | ( | ) |
float Superpowered::AdvancedAudioPlayer::getBufferedStartPercent | ( | ) |
double Superpowered::AdvancedAudioPlayer::getCurrentBpm | ( | ) |
unsigned int Superpowered::AdvancedAudioPlayer::getCurrentHLSBPS | ( | ) |
double Superpowered::AdvancedAudioPlayer::getDisplayPositionMs | ( | ) |
float Superpowered::AdvancedAudioPlayer::getDisplayPositionPercent | ( | ) |
int Superpowered::AdvancedAudioPlayer::getDisplayPositionSeconds | ( | ) |
unsigned int Superpowered::AdvancedAudioPlayer::getDurationMs | ( | ) |
unsigned int Superpowered::AdvancedAudioPlayer::getDurationSeconds | ( | ) |
const char* Superpowered::AdvancedAudioPlayer::getFullyDownloadedFilePath | ( | ) |
PlayerEvent Superpowered::AdvancedAudioPlayer::getLatestEvent | ( | ) |
double Superpowered::AdvancedAudioPlayer::getMsDifference | ( | double | phase, |
double | quantum | ||
) |
phase | The phase to calculate against. |
quantum | The quantum to calculate against. |
double Superpowered::AdvancedAudioPlayer::getMsElapsedSinceLastBeat | ( | ) |
int Superpowered::AdvancedAudioPlayer::getOpenErrorCode | ( | ) |
double Superpowered::AdvancedAudioPlayer::getPhase | ( | ) |
double Superpowered::AdvancedAudioPlayer::getPositionMs | ( | ) |
double Superpowered::AdvancedAudioPlayer::getQuantum | ( | ) |
const char* Superpowered::AdvancedAudioPlayer::getStemColor | ( | unsigned char | index | ) |
const char* Superpowered::AdvancedAudioPlayer::getStemName | ( | unsigned char | index | ) |
|
static |
double Superpowered::AdvancedAudioPlayer::getWaitingForSyncStartMs | ( | ) |
double Superpowered::AdvancedAudioPlayer::getWillSyncMs | ( | ) |
bool Superpowered::AdvancedAudioPlayer::isLooping | ( | ) |
bool Superpowered::AdvancedAudioPlayer::isPerformingSlip | ( | ) |
bool Superpowered::AdvancedAudioPlayer::isPlaying | ( | ) |
bool Superpowered::AdvancedAudioPlayer::isReverse | ( | ) |
bool Superpowered::AdvancedAudioPlayer::isScratching | ( | ) |
bool Superpowered::AdvancedAudioPlayer::isStems | ( | ) |
bool Superpowered::AdvancedAudioPlayer::isWaitingForBuffering | ( | ) |
void Superpowered::AdvancedAudioPlayer::jogTick | ( | int | value, |
bool | bendStretch, | ||
float | bendMaxPercent, | ||
unsigned int | bendHoldMs, | ||
bool | parameterModeIfNoJogTouchBegin | ||
) |
A jog wheel should send some "ticks" with the movement.
A waveform's movement in pixels for example.
value | The icks value. |
bendStretch | Use time-stretching for pitch bend or not (false makes it "audible"). |
bendMaxPercent | The maximum playback rate change for pitch bend, should be between 0.01f and 0.3f (1% and 30%). |
bendHoldMs | How long to maintain the pitch bend state. A value >= 1000 will hold until endContinuousPitchBend is called. |
parameterModeIfNoJogTouchBegin | True: if there was no jogTouchBegin, turn to JogMode_Parameter mode. False: if there was no jogTouchBegin, turn to JogMode_PitchBend mode. |
void Superpowered::AdvancedAudioPlayer::jogTouchBegin | ( | int | ticksPerTurn, |
JogMode | mode, | ||
unsigned int | scratchSlipMs = 0 |
||
) |
"Virtual jog wheel" or "virtual turntable" handling.
ticksPerTurn | Sets the sensitivity of the virtual wheel. Use around 2300 for pixel-perfect touchscreen waveform control. |
mode | Jog wheel mode (scratching, pitch bend, or parameter set in the 0-1 range). |
scratchSlipMs | Enables slip mode for a specific amount of time for scratching, or 0 to not slip. |
void Superpowered::AdvancedAudioPlayer::jogTouchEnd | ( | float | decelerate, |
bool | synchronisedStart | ||
) |
Call this when the jog touch ends.
decelerate | The decelerating rate for momentum. Set to 0.0f for automatic. |
synchronisedStart | Beat-synced start after decelerating. |
bool Superpowered::AdvancedAudioPlayer::loop | ( | double | startMs, |
double | lengthMs, | ||
bool | jumpToStartMs, | ||
unsigned char | pointID, | ||
bool | synchronisedStart, | ||
unsigned int | numLoops = 0 , |
||
bool | forceDefaultQuantum = false , |
||
bool | preferWaitingforSynchronisedStart = false |
||
) |
Loop from a start point to some length.
startMs | Loop from this milliseconds. |
lengthMs | Loop length in milliseconds. |
jumpToStartMs | If the playhead is within the loop, jump to startMs or not. |
pointID | Looping caches startMs, therefore you can specify a pointID too (or set to 255 if you don't care). |
synchronisedStart | Beat-synced start. |
numLoops | Number of times to loop. 0 means: until exitLoop() is called. |
forceDefaultQuantum | If true and using quantized synchronization, will use the defaultQuantum instead of the syncToQuantum. |
preferWaitingforSynchronisedStart | Wait or start immediately when synchronized. |
bool Superpowered::AdvancedAudioPlayer::loopBetween | ( | double | startMs, |
double | endMs, | ||
bool | jumpToStartMs, | ||
unsigned char | pointID, | ||
bool | synchronisedStart, | ||
unsigned int | numLoops = 0 , |
||
bool | forceDefaultQuantum = false , |
||
bool | preferWaitingforSynchronisedStart = false |
||
) |
Loop between a start and end points.
startMs | Loop from this milliseconds. |
endMs | Loop to this milliseconds. |
jumpToStartMs | If the playhead is within the loop, jump to startMs or not. |
pointID | Looping caches startMs, therefore you can specify a pointID too (or set to 255 if you don't care). |
synchronisedStart | Beat-synced start. |
numLoops | Number of times to loop. 0 means: until exitLoop() is called. |
forceDefaultQuantum | If true and using quantized synchronization, will use the defaultQuantum instead of the syncToQuantum. |
preferWaitingforSynchronisedStart | Wait or start immediately when synchronized. |
bool Superpowered::AdvancedAudioPlayer::msInLoop | ( | double | ms | ) |
ms | The position in milliseconds. |
void Superpowered::AdvancedAudioPlayer::onMediaserverInterrupt | ( | ) |
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.
void Superpowered::AdvancedAudioPlayer::open | ( | const char * | path, |
Superpowered::httpRequest * | customHTTPRequest = 0 , |
||
bool | skipSilenceAtBeginning = false |
||
) |
Opens an audio file with playback paused.
Playback rate, pitchShift, timeStretching and syncMode are NOT changed if you open a new file.
path | Full file system path or progressive download path (http or https). |
customHTTPRequest | If 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. |
skipSilenceAtBeginning | If true, the player will set the position to skip the initial digital silence of the audio file (up to 10 seconds). |
void Superpowered::AdvancedAudioPlayer::open | ( | const char * | path, |
int | offset, | ||
int | length, | ||
Superpowered::httpRequest * | customHTTPRequest = 0 , |
||
bool | skipSilenceAtBeginning = false |
||
) |
Opens an audio file with playback paused.
Playback rate, pitchShift, timeStretching and syncMode are NOT changed if you open a new file.
path | Full file system path or progressive download path (http or https). |
offset | The byte offset inside the path. |
length | The byte length from the offset. |
customHTTPRequest | If 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. |
skipSilenceAtBeginning | If true, the player will set the position to skip the initial digital silence of the audio file (up to 10 seconds). |
void Superpowered::AdvancedAudioPlayer::openHLS | ( | const char * | url, |
Superpowered::httpRequest * | customHTTPRequest = 0 |
||
) |
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.
url | Stream URL. |
customHTTPRequest | If 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. |
|
private |
void Superpowered::AdvancedAudioPlayer::pause | ( | float | decelerateSeconds = 0 , |
unsigned int | slipMs = 0 |
||
) |
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.
decelerateSeconds | Optional momentum. 0 means to pause immediately. |
slipMs | Enable slip mode for a specific amount of time, or 0 to not slip. |
void Superpowered::AdvancedAudioPlayer::pitchBend | ( | float | maxPercent, |
bool | bendStretch, | ||
bool | faster, | ||
unsigned int | holdMs | ||
) |
Starts on changes pitch bend (temporary playback rate change).
maxPercent | The maximum playback rate range for pitch bend, should be between 0.01f and 0.3f (1% and 30%). |
bendStretch | Use time-stretching for pitch bend or not (false makes it "audible"). |
faster | True: faster, false: slower. |
holdMs | How long to maintain the pitch bend state. A value >= 1000 will hold until endContinuousPitchBend is called. |
void Superpowered::AdvancedAudioPlayer::play | ( | ) |
Starts playback immediately without any synchronization.
void Superpowered::AdvancedAudioPlayer::playSynchronized | ( | ) |
Starts beat or tempo synchronized playback.
void Superpowered::AdvancedAudioPlayer::playSynchronizedToPosition | ( | double | positionMs | ) |
Starts playback at a specific position.
isPlaying() will return false 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.
positionMs | Start position in milliseconds. |
bool Superpowered::AdvancedAudioPlayer::processMulti | ( | float ** | buffers, |
bool | mix, | ||
unsigned int | numberOfFrames, | ||
float * | volumes, | ||
double * | jogParameter = 0 |
||
) |
Processes audio, multi-channel version.
buffers | 32-bit interleaved stereo input/output buffer pairs. Each pair should be numberOfFrames * 8 + 64 bytes big. |
mix | 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. |
numberOfFrames | The number of frames requested. |
volumes | A volume for each buffer in buffers. 0.0f is silence, 1.0f is "original volume". Changes are automatically smoothed between consecutive processes. |
jogParameter | If jog wheel mode is JogMode_Parameter, returns with the current parameter typically in the range of -1 to 1, or more than 1000000.0 if there was no jog wheel movement. Can be NULL if not interested. |
void Superpowered::AdvancedAudioPlayer::processSTEMSMaster | ( | float * | input, |
float * | output, | ||
unsigned int | numberOfFrames, | ||
float | volume = 1.0f |
||
) |
Performs the last stage of STEMS processing, the master compressor and limiter.
Works only if a STEMS file was loaded.
input | Pointer to floating point numbers. 32-bit interleaved stereo input buffer. |
output | Pointer to floating point numbers. 32-bit interleaved stereo output buffer. |
numberOfFrames | The number of frames to process. |
volume | 0.0f is silence, 1.0f is "original volume". Changes are automatically smoothed between consecutive processes. |
bool Superpowered::AdvancedAudioPlayer::processStereo | ( | float * | buffer, |
bool | mix, | ||
unsigned int | numberOfFrames, | ||
float | volume = 1.0f , |
||
double * | jogParameter = 0 |
||
) |
Processes audio, stereo version.
buffer | Pointer to floating point numbers. 32-bit interleaved stereo input/output buffer. Should be numberOfFrames * 8 + 64 bytes big. |
mix | 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. |
numberOfFrames | The number of frames requested. |
volume | 0.0f is silence, 1.0f is "original volume". Changes are automatically smoothed between consecutive processes. |
jogParameter | 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. Can be NULL if not interested. |
void Superpowered::AdvancedAudioPlayer::resetBendMsOffset | ( | ) |
Reset the pitch bend offset to the beatgrid to zero.
void Superpowered::AdvancedAudioPlayer::scratch | ( | double | pitch, |
float | smoothing | ||
) |
Scratch movement.
pitch | The current speed. |
smoothing | Should be between 0.05f (max. smoothing) and 1.0f (no smoothing). |
void Superpowered::AdvancedAudioPlayer::seek | ( | double | percent | ) |
Simple seeking to a percentage.
percent | The position in percentage. |
void Superpowered::AdvancedAudioPlayer::setPosition | ( | double | ms, |
bool | andStop, | ||
bool | synchronisedStart, | ||
bool | forceDefaultQuantum = false , |
||
bool | preferWaitingforSynchronisedStart = false |
||
) |
Precise seeking.
ms | Position in milliseconds. |
andStop | If true, stops playback. |
synchronisedStart | If andStop is false, makes a beat-synced start possible. |
forceDefaultQuantum | If true and using quantized synchronization, will use the defaultQuantum instead of the syncToQuantum. |
preferWaitingforSynchronisedStart | Wait or start immediately when synchronized. |
void Superpowered::AdvancedAudioPlayer::setReverse | ( | bool | reverse, |
unsigned int | slipMs = 0 |
||
) |
Sets playback direction.
reverse | True: reverse. False: forward. |
slipMs | Enable slip mode for a specific amount of time, or 0 to not slip. |
|
static |
Set the folder to store for temporary files.
Used for HLS and progressive download only. Call this before any player instance is created. It will create a subfolder with the name "SuperpoweredAAP" in the specified folder (and will clear all content inside SuperpoweredAAP if it exists already). If you need to clear the folder before your app quits, use NULL for the path.
path | File system path of the folder. |
void Superpowered::AdvancedAudioPlayer::startScratch | ( | unsigned int | slipMs, |
bool | stopImmediately | ||
) |
Direct turntable handling.
Call this when scratching starts.
slipMs | Enable slip mode for a specific amount of time for scratching, or 0 to not slip. |
stopImmediately | Stop playback or not. |
|
static |
code | The return value of the Decoder::open method. |
void Superpowered::AdvancedAudioPlayer::togglePlayback | ( | ) |
Toggle play/pause (no synchronization).
double Superpowered::AdvancedAudioPlayer::defaultQuantum |
Sets the quantum for quantized synchronization. Example: 4 means 4 beats.
bool Superpowered::AdvancedAudioPlayer::enableStems |
If true and a Native Instruments STEMS file is loaded, output 4 stereo channels. Default: false (stereo master mix output).
double Superpowered::AdvancedAudioPlayer::firstBeatMs |
Tells where the first beat is (the beatgrid starts). Must be set to a correct value for syncing. Default: 0.
bool Superpowered::AdvancedAudioPlayer::fixDoubleOrHalfBPM |
If true and playbackRate is above 1.4f or below 0.6f, it will sync the tempo as half or double. Default: false.
bool Superpowered::AdvancedAudioPlayer::HLSAutomaticAlternativeSwitching |
If true, then the player will automatically swtich between the HLS alternatives according to the available network bandwidth. Default: true.
int Superpowered::AdvancedAudioPlayer::HLSBufferingSeconds |
How many seconds ahead of the playback position to download. Default value: HLS_DOWNLOAD_REMAINING.
|
static |
Will download everything after the playback position until the end.
|
static |
Downloads everything from the beginning to the end, regardless the playback position.
char Superpowered::AdvancedAudioPlayer::HLSLiveLatencySeconds |
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).
int Superpowered::AdvancedAudioPlayer::HLSMaximumDownloadAttempts |
How many times to retry if a HLS segment download fails. Default: 100.
|
private |
bool Superpowered::AdvancedAudioPlayer::loopOnEOF |
If true, jumps back and continues playback. If false, playback stops. Default: false.
float Superpowered::AdvancedAudioPlayer::maximumTimestretchingPlaybackRate |
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.
|
static |
The maximum playback rate or scratching speed: 20.
float Superpowered::AdvancedAudioPlayer::minimumTimestretchingPlaybackRate |
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.
double Superpowered::AdvancedAudioPlayer::originalBPM |
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).
unsigned int Superpowered::AdvancedAudioPlayer::outputSamplerate |
The player output sample rate in Hz.
int Superpowered::AdvancedAudioPlayer::pitchShiftCents |
Pitch shift cents, from -1200 (one octave down) to 1200 (one octave up). Use values representing notes (multiply of 100) for low CPU load. Default: 0 (no pitch shift).
double Superpowered::AdvancedAudioPlayer::playbackRate |
The playback rate. Must be positive and above 0.00001. Default: 1.
bool Superpowered::AdvancedAudioPlayer::reverseToForwardAtLoopStart |
If this is true with playing backwards and looping, then reaching the beginning of the loop will change playback direction to forwards. Default: false.
|
private |
SyncMode Superpowered::AdvancedAudioPlayer::syncMode |
The current sync mode (off, tempo, or tempo+beat). Default: off.
double Superpowered::AdvancedAudioPlayer::syncToBpm |
A bpm value to sync with. Use 0.0f for no syncing.
double Superpowered::AdvancedAudioPlayer::syncToMsElapsedSinceLastBeat |
The number of milliseconds elapsed since the last beat on audio the player has to sync with. Use -1.0 to ignore.
double Superpowered::AdvancedAudioPlayer::syncToPhase |
Used for quantized synchronization. The phase to sync with.
double Superpowered::AdvancedAudioPlayer::syncToQuantum |
Used for quantized synchronization. The quantum to sync with.
bool Superpowered::AdvancedAudioPlayer::timeStretching |
Enable/disable time-stretching. Default: true.