### Select SDK Language (C++/JS) Source: https://docs.superpowered.com/reference/latest/dsp-functions Choose the programming language for the Superpowered SDK. Options include C++ for native performance and JavaScript for web-based applications. This selection guides the subsequent setup and integration steps. ```text SDK Language C++ JS C++ JS ``` -------------------------------- ### Superpowered Flanger - C++ Implementation Example Source: https://docs.superpowered.com/reference/latest/flanger Example of initializing, configuring, and processing audio with the Superpowered Flanger effect in C++. ```APIDOC ## Implementation example (C++) ```cpp #include "SuperpoweredFlanger.h" void initFlangerEffect() { const unsigned int sampleRate = 44100; flanger = new Superpowered::Flanger(sampleRate); flanger->enabled = true; } void configureFlangerEffect() { flanger->bpm = 140; flanger->lfoBeats = 1; flanger->wet = 0.5; } void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames, unsigned int samplerate) { // Ensure the samplerate is in sync on every audio processing callback flanger->samplerate = samplerate; // Render the output buffers bool outputChanged = flanger->process(interleavedInput, interleavedOutput, numberOfFrames); ... } ``` ``` -------------------------------- ### Superpowered Flanger - JavaScript Implementation Example Source: https://docs.superpowered.com/reference/latest/flanger Example of how to implement and use the Superpowered Flanger effect within a Web Audio API AudioWorkletProcessor. ```APIDOC ## Implementation example (JavaScript) ```javascript class SuperpoweredFlangerProcessor extends SuperpoweredWebAudio.AudioWorkletProcessor { // Called when the AudioWorklet is ready to start processing audio onReady() { this.flanger = new this.Superpowered.Flanger( this.samplerate, // The initial sample rate in Hz. ); this.flanger.enabled = true; this.flanger.frequency = 22500; this.eflangerfect.bits = 8; } // Runs before the node is destroyed. // Clean up memory and objects here (such as free allocated linear memory or destruct Superpowered objects). onDestruct() { this.flanger.destruct(); } // messages are received from the main scope through this method. onMessageFromMainScope(message) { if (typeof message.wet !== 'undefined') this.flanger.wet = message.wet; if (typeof message.depth !== 'undefined') this.flanger.depth = message.depth; if (typeof message.lfoBeats !== 'undefined') this.flanger.lfoBeats = message.lfoBeats; if (typeof message.bpm !== 'undefined') this.flanger.bpm = message.bpm; if (typeof message.clipperThresholdDb !== 'undefined') this.flanger.clipperThresholdDb = message.clipperThresholdDb; if (typeof message.clipperMaximumDb !== 'undefined') this.flanger.clipperMaximumDb = message.clipperMaximumDb; if (typeof message.stereo !== 'undefined') this.flanger.stereo = Boolean(message.stereo); if (typeof message.enabled !== 'undefined') this.flanger.enabled = Boolean(message.enabled); } processAudio(inputBuffer, outputBuffer, buffersize, parameters) { // Ensure the samplerate is in sync on every audio processing callback this.flanger.samplerate = this.samplerate; // Render the output buffers, forward input if process returns false (no output changes) if (!this.flanger.process(inputBuffer.pointer, outputBuffer.pointer, buffersize)) { for (let n = 0; n < buffersize * 2 ; n++) outputBuffer.array[n] = inputBuffer.array[n]; } } } ``` ``` -------------------------------- ### Initialize and Process Flanger Effect in C++ Source: https://docs.superpowered.com/reference/latest/flanger This C++ snippet shows the basic setup for the Superpowered Flanger effect. It includes initializing the flanger with a sample rate, configuring its parameters, and processing audio buffers. This requires the Superpowered C++ SDK. ```cpp #include "SuperpoweredFlanger.h" void initFlangerEffect() { const unsigned int sampleRate = 44100; flanger = new Superpowered::Flanger(sampleRate); flanger->enabled = true; } void configureFlangerEffect() { flanger->bpm = 140; flanger->lfoBeats = 1; flanger->wet = 0.5; } void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames, unsigned int samplerate) { // Ensure the samplerate is in sync on every audio processing callback flanger->samplerate = samplerate; // Render the output buffers bool outputChanged = flanger->process(interleavedInput, interleavedOutput, numberOfFrames); ... } ``` -------------------------------- ### Version Source: https://docs.superpowered.com/reference/latest/dsp-functions Retrieves the current version of the Superpowered SDK. ```APIDOC ## Version ### Description Returns the current version of the Superpowered SDK. ### Method (Not explicitly defined, assumed to be a function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **version** (Number) - The returned value is: major version * 10000 + minor version * 100 + revision. Example: 10402 means 1.4.2 #### Response Example ```json { "version": 10402 } ``` ``` ```APIDOC ## Version (unsigned int version) ### Description Returns the current version of the Superpowered SDK. ### Method (Not explicitly defined, assumed to be a function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **version** (unsigned int) - The returned value is: major version * 10000 + minor version * 100 + revision. Example: 10402 means 1.4.2 #### Response Example ```json { "version": 10402 } ``` ``` -------------------------------- ### Analyzer Constructor Source: https://docs.superpowered.com/reference/latest/analyzer Creates an instance of the Analyzer class with specified sample rate and audio length. ```APIDOC ## constructor Analyzer ### Description Creates instance of Analyzer class. ### Method constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **samplerate** (Number) - Required - The sample rate of the audio input. - **lengthSeconds** (Number) - Required - The length in seconds of the audio input. The analyzer will not be able to process more audio than this. You can change this value in the process() method. ### Request Example ```json { "samplerate": 44100, "lengthSeconds": 120 } ``` ### Response #### Success Response (200) - **instance** (Superpowered.Analyzer) - The constructed instance. #### Response Example ```json { "instance": "Superpowered.Analyzer object" } ``` ``` -------------------------------- ### Offline Audio Analysis with Superpowered Analyzer (C++) Source: https://docs.superpowered.com/reference/latest/analyzer This C++ example outlines the process for performing offline audio analysis using the Superpowered Analyzer. Similar to the Javascript version, it involves preparing the audio file and utilizing the analyzer to extract detailed information such as BPM, key, and waveform data. The principles of method calls are consistent across web and native implementations. ```cpp // This is a placeholder for the actual C++ code. // The original text describes the functionality but does not provide the full code snippet. // A complete implementation would involve Superpowered API calls for analysis. #include // Assuming Superpowered Analyzer is available via a library // #include "SuperpoweredAnalyzer.h" int main() { std::cout << "Initiating Superpowered Analyzer for offline analysis..." << std::endl; // Example placeholder for audio file processing and analysis // std::string audioPath = "path/to/your/audio.wav"; // SuperpoweredAnalyzer analyzer; // analyzer.processFile(audioPath.c_str()); // float bpm = analyzer.getBPM(); // int key = analyzer.getKey(); // std::cout << "Detected BPM: " << bpm << ", Key: " << key << std::endl; return 0; } ``` -------------------------------- ### Offline Audio Analysis with Superpowered Analyzer (Javascript) Source: https://docs.superpowered.com/reference/latest/analyzer This Javascript example demonstrates how to use the Superpowered Analyzer to process an entire audio file. It covers converting the audio to the correct format and extracting various analysis data like waveform, beatgrid, and musical notes. The extracted data can be visualized on canvases and in tables. ```javascript /* * This is a placeholder for the actual Javascript code. * The original text describes the functionality but does not provide the full code snippet. * A complete implementation would involve Superpowered API calls for analysis. */ console.log("Initiating Superpowered Analyzer for offline analysis..."); // Example placeholder for audio file processing and analysis // const audioFile = "path/to/your/audio.wav"; // const analyzer = new SuperpoweredAnalyzer(); // analyzer.processFile(audioFile); // const bpm = analyzer.getBPM(); // const key = analyzer.getKey(); // console.log(`Detected BPM: ${bpm}, Key: ${key}`); ``` -------------------------------- ### Live Analyzer Class Source: https://docs.superpowered.com/reference/latest/live-analyzer Provides an overview of the Live Analyzer class, its purpose, memory usage, and implementation details. ```APIDOC ## Class: Live Analyzer ### Overview Performs continuous BPM and key detection with an update frequency of 2 seconds. **Warning:** High memory usage! This class allocates 320 x samplerate bytes (e.g., 48000 Hz x 320 = 15 MB). ### How to implement (C++ Example) ```cpp #include "SuperpoweredAnalyzer.h" // Assuming liveAnalyzer is a globally accessible pointer or managed appropriately Superpowered::LiveAnalyzer *liveAnalyzer; void initLiveAnalyzer() { liveAnalyzer = new Superpowered::LiveAnalyzer(44100); liveAnalyzer->bpm = 0; } void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames) { liveAnalyzer->process(interleavedInput, numberOfFrames); float bpm = liveAnalyzer->bpm; int keyIndex = liveAnalyzer->keyIndex; float silence = liveAnalyzer->silence; // ... further processing ... } ``` * * * ## Properties ### bpm **Type:** `float` **Description:** Current beats per minute. Setting bpm to zero forces the analyzer to "forget" the last BPM and find the correct value within 10 seconds. Setting it to an estimated value forces the analyzer to "forget" the last BPM and use your estimate, potentially finding the correct value within 4 seconds. Setting it to a negative value performs a "hard reset". **Min:** N/A **Max:** N/A **Default:** N/A ### keyIndex **Type:** `int` **Description:** The dominant key (chord) of the music. Ranges from 0-11 for major keys (A to G#) and 12-23 for minor keys (A to G#). A value of -1 indicates an unknown key. Refer to the header for musical, Camelot, and Open Key notations. **Min:** N/A **Max:** N/A **Default:** N/A ### samplerate **Type:** `unsigned int` **Description:** The sample rate in Hz. **Min:** N/A **Max:** N/A **Default:** N/A ### silence **Type:** `bool` **Description:** If true, BPM and key detection is paused because the analyzer detects a silence period (over 1 second of digital silence or 8 seconds below -48 decibels). If false, detection is in progress. **Min:** N/A **Max:** N/A **Default:** N/A * * * ## Methods ### constructor **Description:** Creates a `LiveAnalyzer` instance. **Parameters:** - **samplerate** (`unsigned int`) - The initial sample rate in Hz. **Returns:** - `Superpowered::LiveAnalyzer` - The constructed instance. ### process **Description:** Processes audio frames for BPM and key detection. This method is safe to use in a real-time audio thread. **Parameters:** - **input** (`float *`) - Pointer to 32-bit interleaved stereo audio data. - **numberOfFrames** (`unsigned int`) - The number of frames to process. **Returns:** None ``` -------------------------------- ### Initialize Superpowered Glue (JavaScript) Source: https://docs.superpowered.com/reference/latest/web-audio-helpers_lang=cpp This snippet demonstrates how to instantiate the SuperpoweredGlue class to initialize Superpowered. It shows two variations: one for evaluation with a provided license key, and another for production use which also includes the location of the WASM file. Ensure you replace 'ExampleLicenseKey-WillExpire-OnNextUpdate' with your actual license key and provide the correct WASM file location for production. ```javascript var Superpowered = await SuperpoweredGlue.Instantiate('ExampleLicenseKey-WillExpire-OnNextUpdate'); ``` ```javascript var Superpowered = await SuperpoweredGlue.Instantiate('ExampleLicenseKey-WillExpire-OnNextUpdate', 'https://LOCATION_OF_PUBLICALLY_ACESSABLE_WASM_FILE'); ``` -------------------------------- ### Superpowered Analyzer Initialization and Processing Source: https://docs.superpowered.com/reference/latest/analyzer This snippet demonstrates how to initialize the Superpowered Analyzer with sample rate and duration, process audio input, and understand the parameters for real-time processing. It highlights the input format and frame processing. ```javascript let analyzer = new Superpowered.Analyzer( 44100, // The sample rate of the audio input. 60 // The length in seconds of the audio input. The analyzer will not be able to process more audio than this. You can change this value in the process() method. ); analyzer.process( input, // Pointer to floating point numbers. 32-bit interleaved stereo input. 128, // Number of frames to process. -1 // If the audio input length may change, set this to the current length. Use -1 otherwise. If this value is not -1, this method can NOT be used in a real-time audio thread. ); ``` -------------------------------- ### C++ Implementation Example Source: https://docs.superpowered.com/reference/latest/compressor An example of how to implement and use the Superpowered Compressor in C++. It covers initialization, configuring parameters, and processing audio frames. ```APIDOC ## Implementation example (C++) ```cpp #include "SuperpoweredCompressor.h" void initCompressor() { unsigned int sampleRate = 44100; compressor = new Superpowered::Compressor(sampleRate); } void configureCompressor() { compressor->inputGainDb = 0; compressor->outputGainDb = 0; compressor->wet = 1; compressor->attackSec = 0.003; compressor->releaseSec = 0.3; compressor->ratio = 3; compressor->thresholdDb = 0; compressor->hpCutOffHz = 1; compressor->enabled = true; } void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames, unsigned int samplerate) { // Ensure the samplerate is in sync on every audio processing callback compressor->samplerate = samplerate; // Render the output buffers bool outputChanged = compressor->process(interleavedInput, interleavedOutput, numberOfFrames); ... } ``` ``` -------------------------------- ### Implement Live Analyzer in C++ Source: https://docs.superpowered.com/reference/latest/live-analyzer This C++ snippet demonstrates how to initialize and process audio using the Superpowered Live Analyzer. It includes setting up the analyzer with a sample rate and processing interleaved audio frames to retrieve BPM, key index, and silence information. Ensure you have the Superpowered C++ SDK included. ```c++ #include "SuperpoweredAnalyzer.h" void initLiveAnalyzer() { liveAnalyzer = new Superpowered::LiveAnalyzer(44100); liveAnalyzer->bpm = 0; } void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames) { liveAnalyzer->process(interleavedInput, numberOfFrames); float bpm = liveAnalyzer->bpm; int keyIndex = liveAnalyzer->keyIndex; float silence = liveAnalyzer->silence; ... } ``` -------------------------------- ### GetPeaks (float *) Source: https://docs.superpowered.com/reference/latest/dsp-functions Get the peak values of each channel in an interleaved buffer. ```APIDOC ## GetPeaks (float *) ### Description Get the peak values of each channel in an interleaved buffer. ### Method POST ### Endpoint /GetPeaks ### Parameters #### Request Body - **interleavedInput** (float *) - Required - Interleaved input. - **numInterleavedChannels** (unsigned int) - Required - The total number of channels in the interleaved input. - **numberOfFrames** (unsigned int) - Required - The number of frames to process. - **peaks** (float *) - Required - Peak value result, should be able to store totalChannels values minimum. ### Request Example ```json { "interleavedInput": [0.1, -0.2, 0.3, -0.4], "numInterleavedChannels": 2, "numberOfFrames": 2, "peaks": [0.3, -0.4] } ``` ### Response #### Success Response (200) (No specific fields described, typically indicates successful execution) #### Response Example ```json {} ``` ``` -------------------------------- ### Initialize and Play Audio File (C++) Source: https://docs.superpowered.com/reference/latest/audio-in-memory_lang=cpp This C++ code snippet shows the initialization of the Superpowered SDK with a license key, followed by the creation of an AdvancedAudioPlayer instance. It also sets up variables for the audio file path and size, preparing for audio playback. ```cpp void playAudioFile() { Initialize("ExampleLicenseKey-WillExpire-OnNextUpdate"); const unsigned int sampleRate = 44100; audioPlayer = new AdvancedAudioPlayer(sampleRate, 0); const char* filePath = "example-file.mp3"; char* fileData = nullptr; long fileSize = 0; } ``` -------------------------------- ### GetPeaks (pointer) Source: https://docs.superpowered.com/reference/latest/dsp-functions Get the peak values of each channel in an interleaved buffer. ```APIDOC ## GetPeaks (pointer) ### Description Get the peak values of each channel in an interleaved buffer. ### Method POST ### Endpoint /GetPeaks ### Parameters #### Request Body - **interleavedInput** (Number (pointer in Linear Memory)) - Required - Interleaved input. - **numInterleavedChannels** (Number) - Required - The total number of channels in the interleaved input. - **numberOfFrames** (Number) - Required - The number of frames to process. - **peaks** (Number (pointer in Linear Memory)) - Required - Peak value result, should be able to store totalChannels values minimum. ### Request Example ```json { "interleavedInput": "0x12345678", "numInterleavedChannels": 2, "numberOfFrames": 1024, "peaks": "0x87654321" } ``` ### Response #### Success Response (200) (No specific fields described, typically indicates successful execution) #### Response Example ```json {} ``` ``` -------------------------------- ### Get Buffered Start Percent (C++) Source: https://docs.superpowered.com/reference/latest/advanced-audio-player_lang=cpp Returns the start percentage of the buffered part of an audio source. For non-network sources like local files, this will always be 0. This method takes no parameters. ```cpp getBufferedStartPercent() ``` -------------------------------- ### C++ Compressor Implementation Example Source: https://docs.superpowered.com/reference/latest/compressor Provides a C++ implementation example for the Superpowered Compressor, showing initialization, configuration of its parameters, and audio processing. This code is intended for use with the Superpowered C++ SDK and requires manual memory management for the compressor object. ```cpp #include "SuperpoweredCompressor.h" void initCompressor() { unsigned int sampleRate = 44100; compressor = new Superpowered::Compressor(sampleRate); } void configureCompressor() { compressor->inputGainDb = 0; compressor->outputGainDb = 0; compressor->wet = 1; compressor->attackSec = 0.003; compressor->releaseSec = 0.3; compressor->ratio = 3; compressor->thresholdDb = 0; compressor->hpCutOffHz = 1; compressor->enabled = true; } void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames, unsigned int samplerate) { // Ensure the samplerate is in sync on every audio processing callback compressor->samplerate = samplerate; // Render the output buffers bool outputChanged = compressor->process(interleavedInput, interleavedOutput, numberOfFrames); ... } ``` -------------------------------- ### Limiter Implementation Example (C++) Source: https://docs.superpowered.com/reference/latest/limiter An example demonstrating how to initialize, configure, and process audio using the Superpowered Limiter in C++. ```APIDOC ## Limiter Implementation Example (C++) ### Initialization ```cpp #include "SuperpoweredLimiter.h" Superpowered::Limiter *limiter; void initLimiterEffect() { const unsigned int sampleRate = 44100; limiter = new Superpowered::Limiter(sampleRate); limiter->enabled = true; } ``` ### Configuration ```cpp void configureEffect() { limiter->ceilingDb = 0; limiter->thresholdDb = -16; limiter->releaseSec = 0.2; } ``` ### Audio Processing ```cpp void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames, unsigned int samplerate) { // Ensure the samplerate is in sync on every audio processing callback limiter->samplerate = samplerate; // Render the output buffers bool outputChanged = limiter->process(interleavedInput, interleavedOutput, numberOfFrames); // ... handle outputChanged if needed } ``` ``` -------------------------------- ### Get slice start position (C++) Source: https://docs.superpowered.com/reference/latest/audiopointer-list_lang=cpp Retrieves the starting position of a slice within an audio file or stream. This method is safe for use in real-time threads as it avoids blocking memory operations. ```cpp int getSliceStartPosition(); ``` -------------------------------- ### C++ Initialization and Processing Example Source: https://docs.superpowered.com/reference/latest/resampler Provides a C++ code example demonstrating how to initialize the Resampler and process audio frames. ```APIDOC ## C++ Initialization and Processing Example ### Description Illustrates the C++ usage of the Superpowered::Resampler class for audio processing. ### Code ```cpp #include "SuperpoweredResampler.h" Superpowered::Resampler *resampler; void initResampler() { resampler = new Superpowered::Resampler(); // The rate of the resampler. Default: 1. If rate = 1, process() is "transparent" without any effect on audio quality. resampler->rate = 1.1; // Reset all internals. Doesn't change rate. Has no return value. resampler->reset(); } void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames) { int outputNumberOfFrames = resampler->process(interleavedInput, interleavedOutput, numberOfFrames); // ... further processing ... } ``` ``` -------------------------------- ### Get Note Frequency (C++) Source: https://docs.superpowered.com/reference/latest/dsp-functions Calculates the frequency of a specific musical note. Note 0 corresponds to A4 at 440 Hz. This C++ version returns a float. ```cpp /** * Returns the frequency of a specific note. * @param note The index of the note. Note 0 is the standard A note at 440 Hz. * @return The frequency in Hz. */ float frequencyOfNote(int note); ``` -------------------------------- ### Uint8Buffer API Source: https://docs.superpowered.com/reference/latest/web-audio-helpers_lang=cpp Documentation for the Uint8Buffer, including its constructor, methods, and properties. ```APIDOC ## Uint8Buffer ### Description Provides methods and properties for managing a buffer of unsigned 8-bit integers. ### Methods #### constructor(length: Number) Creates a Superpowered.Uint8Buffer instance. - **length** (Number) - Required - Length of buffer array. Returns: - **Superpowered.Uint8Buffer** - A new Uint8Buffer instance. #### free() Deallocates the buffer. Parameters: None Returns: None ### Properties - **array** (Uint8Array) - A Uint8Array view of this buffer (standard TypedArray). - **length** (Number) - The length of the buffer. - **pointer** (Number) - Index in the Linear Memory (pointer). ``` -------------------------------- ### Initialize Superpowered SDK and Decode Audio File (C++) Source: https://docs.superpowered.com/reference/latest/time-stretching_lang=cpp This snippet shows how to initialize the Superpowered SDK using a provided license key and then opens an audio file ('test.m4a') for decoding. It utilizes the Superpowered::Initialize function and the Superpowered::Decoder class. Error handling is included for the file opening operation. Ensure the Superpowered SDK is properly linked. ```cpp int main(int argc, char *argv[]) { Superpowered::Initialize("ExampleLicenseKey-WillExpire-OnNextUpdate"); // Open the input file. Superpowered::Decoder *decoder = new Superpowered::Decoder(); int openReturn = decoder->open("test.m4a"); if (openReturn != Superpowered::Decoder::OpenSuccess) { printf("error"); } } ``` -------------------------------- ### CopyStereoFromInterleaved Source: https://docs.superpowered.com/reference/latest/dsp-functions Copies stereo audio data from an interleaved buffer. ```APIDOC ## CopyStereoFromInterleaved ### Description Copy stereo audio from an interleaved buffer. ### Method [Not specified, likely a function call within a library] ### Endpoint [Not applicable for library functions] ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **interleavedInput** (Number (pointer in Linear Memory)) - Required - Interleaved input. - **numInterleavedChannels** (Number) - Required - The total number of channels in the interleaved input. - **stereoOutput** (Number (pointer in Linear Memory)) - Required - Stereo interleaved output. - **channelIndex** (Number) - Required - Copy this channel. `channelIndex` is the left side, `channelIndex + 1` is the right side. - **numberOfFrames** (Number) - Required - The number of frames to process. ### Request Example ```json { "interleavedInput": "pointer_to_interleaved_input", "numInterleavedChannels": 4, "stereoOutput": "pointer_to_stereo_output", "channelIndex": 0, "numberOfFrames": 1024 } ``` ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## CopyStereoFromInterleaved (float version) ### Description Copy stereo audio from an interleaved buffer. ### Method [Not specified, likely a function call within a library] ### Endpoint [Not applicable for library functions] ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **interleavedInput** (float *) - Required - Interleaved input. - **numInterleavedChannels** (unsigned int) - Required - The total number of channels in the interleaved input. - **stereoOutput** (float *) - Required - Stereo interleaved output. - **channelIndex** (unsigned int) - Required - Copy this channel. `channelIndex` is the left side, `channelIndex + 1` is the right side. - **numberOfFrames** (unsigned int) - Required - The number of frames to process. ### Request Example ```json { "interleavedInput": "pointer_to_float_interleaved_input", "numInterleavedChannels": 2, "stereoOutput": "pointer_to_float_stereo_output", "channelIndex": 0, "numberOfFrames": 2048 } ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Peak Source: https://docs.superpowered.com/reference/latest/dsp-functions Returns the peak absolute value of the input. Useful for metering. ```APIDOC ## Peak ### Description Returns the peak absolute value. Useful for metering. ### Method POST ### Endpoint /websites/superpowered_reference/Peak ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **input** (Number pointer) - Input values. - **numberOfValues** (Number) - The number of values to process. For a stereo input this value should be 2 * numberOfFrames. Must be a multiply of 8. ### Request Example ```json { "input": 0, "numberOfValues": 0 } ``` ### Response #### Success Response (200) - **peakValue** (Number) - Peak absolute value. #### Response Example ```json { "peakValue": 0.5 } ``` ``` -------------------------------- ### JavaScript Implementation Example Source: https://docs.superpowered.com/reference/latest/compressor An example of how to implement and use the Superpowered Compressor within a JavaScript AudioWorkletProcessor. It demonstrates initialization, property configuration, and audio processing. ```APIDOC ## Implementation example (JavaScript) ```javascript class SuperpoweredCompressorStageProcessor extends SuperpoweredWebAudio.AudioWorkletProcessor { // runs after the constructor onReady() { this.compressor = new this.Superpowered.Compressor( this.samplerate, // The initial sample rate in Hz. ); this.compressor.enabled = true; } // Runs before the node is destroyed. // Clean up memory and objects here (such as free allocated linear memory or destruct Superpowered objects). onDestruct() { this.compressor.destruct(); } // messages are received from the main scope through this method. onMessageFromMainScope(message) { if (typeof message.inputGainDb !== 'undefined') this.compressor.inputGainDb = message.inputGainDb; if (typeof message.outputGainDb !== 'undefined') this.compressor.outputGainDb = message.outputGainDb; if (typeof message.wet !== 'undefined') this.compressor.wet = message.wet; if (typeof message.attackSec !== 'undefined') this.compressor.attackSec = message.attackSec; if (typeof message.releaseSec !== 'undefined') this.compressor.releaseSec = message.releaseSec; if (typeof message.ratio !== 'undefined') this.compressor.ratio = message.ratio; if (typeof message.thresholdDb !== 'undefined') this.compressor.thresholdDb = message.thresholdDb; if (typeof message.hpCutOffHz !== 'undefined') this.compressor.hpCutOffHz = message.hpCutOffHz; if (typeof message.enabled !== 'undefined') this.compressor.enabled = message.enabled; } processAudio(inputBuffer, outputBuffer, buffersize, parameters) { // Ensure the samplerate is in sync on every audio processing callback this.compressor.samplerate = this.samplerate; // Render the output buffers if (!this.compressor.process(inputBuffer.pointer, outputBuffer.pointer, buffersize)) { for (let n = 0; n < buffersize * 2 ; n++) outputBuffer.array[n] = inputBuffer.array[n]; } } } ``` ``` -------------------------------- ### MidSideToStereo Source: https://docs.superpowered.com/reference/latest/dsp-functions Converts a mid-side signal to stereo. The output can be processed in-place. ```APIDOC ## MidSideToStereo ### Description Converts a mid-side signal to stereo. ### Method POST ### Endpoint /websites/superpowered_reference/MidSideToStereo ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **input** (Number pointer) - Mid-side interleaved input. - **output** (Number pointer) - Interleaved stereo output. Can be equal to input (in-place processing). - **numberOfFrames** (Number) - The number of frames to process. ### Request Example ```json { "input": 0, "output": 0, "numberOfFrames": 0 } ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### IntToFloat Source: https://docs.superpowered.com/reference/latest/dsp-functions Converts 32-bit integer audio to 32-bit floating point. ```APIDOC ## IntToFloat ### Description Converts 32-bit integer audio to 32-bit floating point. ### Method POST ### Endpoint /websites/superpowered_reference/IntToFloat ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **input** (Number pointer) - 32-bit input. - **output** (Number pointer) - 32-bit output. - **numberOfFrames** (Number) - The number of frames to process. - **numberOfChannels** (Number) - The number of channels. ### Request Example ```json { "input": 0, "output": 0, "numberOfFrames": 0, "numberOfChannels": 0 } ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Int8Buffer API Source: https://docs.superpowered.com/reference/latest/web-audio-helpers_lang=cpp Documentation for the Int8Buffer, including its constructor. ```APIDOC ## Int8Buffer ### Description Provides methods for managing a buffer of signed 8-bit integers. ### Methods #### constructor() Creates a Superpowered.Int8Buffer instance. Parameters: None Returns: - **Superpowered.Int8Buffer** - A new Int8Buffer instance. ``` -------------------------------- ### CopyMonoToInterleaved Source: https://docs.superpowered.com/reference/latest/dsp-functions Copies a mono audio channel into an interleaved audio buffer. ```APIDOC ## CopyMonoToInterleaved ### Description Copy a mono channel into an interleaved buffer. ### Method [Not specified, likely a function call within a library] ### Endpoint [Not applicable for library functions] ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **monoInput** (Number (pointer in Linear Memory)) - Required - Mono input. - **channelIndex** (Number) - Required - Copy to this channel. - **interleavedOutput** (Number (pointer in Linear Memory)) - Required - Interleaved output. - **numInterleavedChannels** (Number) - Required - The total number of channels in the interleaved output. - **numberOfFrames** (Number) - Required - The number of frames to process. ### Request Example ```json { "monoInput": "pointer_to_mono_input", "channelIndex": 2, "interleavedOutput": "pointer_to_interleaved_output", "numInterleavedChannels": 4, "numberOfFrames": 1024 } ``` ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## CopyMonoToInterleaved (float version) ### Description Copy a mono channel into an interleaved buffer. ### Method [Not specified, likely a function call within a library] ### Endpoint [Not applicable for library functions] ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **monoInput** (float *) - Required - Mono input. - **channelIndex** (unsigned int) - Required - Copy to this channel. - **interleavedOutput** (float *) - Required - Interleaved output. - **numInterleavedChannels** (unsigned int) - Required - The total number of channels in the interleaved output. - **numberOfFrames** (unsigned int) - Required - The number of frames to process. ### Request Example ```json { "monoInput": "pointer_to_float_mono_input", "channelIndex": 0, "interleavedOutput": "pointer_to_float_interleaved_output", "numInterleavedChannels": 2, "numberOfFrames": 2048 } ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Superpowered Decoder Initialization and Opening Source: https://docs.superpowered.com/reference/latest/decoder Demonstrates how to initialize the Superpowered Decoder and open audio files from memory for decoding. ```APIDOC ## Superpowered Decoder Initialization and Opening ### Description Initializes the Superpowered Decoder and provides methods to open audio data stored in memory, with options for fast metadata reading. ### Method - `new Superpowered::Decoder()` - `decoder->openMemory(pointer, false)` - `decoder->openAudioFileInMemory(pointer, length, false)` ### Parameters #### Constructor Parameters None #### `openMemory` Parameters - **pointer** (*void*) - Pointer to audio data in Superpowered AudioInMemory format. - **false** (*bool*) - If true, opens for metadata reading only. #### `openAudioFileInMemory` Parameters - **pointer** (*void*) - Pointer to audio file loaded into memory. - **length** (*int*) - The audio file length in bytes. - **false** (*bool*) - If true, opens for metadata reading only. ### Response #### Success Response (200) - `decoder` (*Superpowered::Decoder*) - An instance of the decoder. - `openErrorCode` (*int*) - 0 indicates success. #### Error Codes - `Superpowered::Decoder::statusCodeToString(openErrorCode)` - Returns a human-readable error string for the given error code. ``` -------------------------------- ### CopyMonoFromInterleaved Source: https://docs.superpowered.com/reference/latest/dsp-functions Copies a mono audio channel from an interleaved audio buffer. ```APIDOC ## CopyMonoFromInterleaved ### Description Copy mono audio from an interleaved buffer. ### Method [Not specified, likely a function call within a library] ### Endpoint [Not applicable for library functions] ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **interleavedInput** (Number (pointer in Linear Memory)) - Required - Interleaved input. - **numInterleavedChannels** (Number) - Required - The total number of channels in the interleaved input. - **monoOutput** (Number (pointer in Linear Memory)) - Required - Mono output. - **channelIndex** (Number) - Required - Copy this channel. - **numberOfFrames** (Number) - Required - The number of frames to process. ### Request Example ```json { "interleavedInput": "pointer_to_interleaved_input", "numInterleavedChannels": 4, "monoOutput": "pointer_to_mono_output", "channelIndex": 1, "numberOfFrames": 1024 } ``` ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## CopyMonoFromInterleaved (float version) ### Description Copy mono audio from an interleaved buffer. ### Method [Not specified, likely a function call within a library] ### Endpoint [Not applicable for library functions] ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **interleavedInput** (float *) - Required - Interleaved input. - **numInterleavedChannels** (unsigned int) - Required - The total number of channels in the interleaved input. - **monoOutput** (float *) - Required - Mono output. - **channelIndex** (unsigned int) - Required - Copy this channel. - **numberOfFrames** (unsigned int) - Required - The number of frames to process. ### Request Example ```json { "interleavedInput": "pointer_to_float_interleaved_input", "numInterleavedChannels": 2, "monoOutput": "pointer_to_float_mono_output", "channelIndex": 0, "numberOfFrames": 2048 } ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Initialize Superpowered and Load Audio in Web Worker (JavaScript) Source: https://docs.superpowered.com/reference/latest/web-audio-helpers_lang=cpp This snippet handles audio file loading and initialization of the Superpowered SDK within a Web Worker. It fetches an audio file as an ArrayBuffer, converts it to raw binary data, and loads it into WebAssembly linear memory using the SuperpoweredGlue.Instantiate function. Dependencies include the SuperpoweredGlue and the fetch API. ```javascript self.onmessage = async function(e) { const Superpowered = await SuperpoweredGlue.Instantiate(''); await fetch(e.data.url).then(response => response.arrayBuffer() ).then(audiofileArrayBuffer => { // Copy the ArrayBuffer to WebAssembly Linear Memory. const audiofileInWASMHeap = Superpowered.main_memory.buffer.slice(...Superpowered.alignedCopy(audiofileArrayBuffer.byteLength)); }); } ``` -------------------------------- ### Flanger Destructor Source: https://docs.superpowered.com/reference/latest/flanger Frees the memory allocated for the Flanger instance. ```APIDOC ## Flanger destruct ### Description Destructor to free Linear Memory. ### Method DELETE ### Endpoint /flanger/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the Flanger instance to destroy. #### Query Parameters None #### Request Body None ### Request Example (No request body for DELETE method) ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the destruction. #### Response Example ```json { "status": "destroyed" } ``` ``` -------------------------------- ### BandpassFilterbank Constructor Source: https://docs.superpowered.com/reference/latest/bandpass-filterbank_lang=cpp Demonstrates how to implement and use the BandpassFilterbank constructor with example code. ```APIDOC ## BandpassFilterbank Constructor ### Description Initializes a new instance of the BandpassFilterbank class. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Request Example ```javascript // Constructor. let frequencies = new Superpowered.Float32Buffer(8), widths = new Superpowered.Float32Buffer(8); for (let n = 0; n < 8; n++) { frequencies.array[n] = 440.0 * Math.pow(2.0, (n - 4.5) * 0.5); // Example frequencies widths.array[n] = frequencies.array[n] * 0.1; // Example widths } let bandpassFilterbank = new Superpowered.BandpassFilterbank(44100, frequencies, widths); ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Get Superpowered SDK Version (C++) Source: https://docs.superpowered.com/reference/latest/dsp-functions Retrieves the current version of the Superpowered SDK. The version is returned as an integer where major, minor, and revision numbers are encoded (e.g., 1.4.2 becomes 10402). ```cpp unsigned int Version(); ``` -------------------------------- ### create Source: https://docs.superpowered.com/reference/latest/audio-in-memory Creates a new audio data table. Overloads exist for different pointer types and parameter type interpretations. ```APIDOC ## create (Number Parameters) ### Description Creates a main table with specified properties. ### Method N/A (Static Method) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **Pointer** (`Number (pointer in Linear Memory)`) - Pointer to the main table. #### Response Example N/A ``` ```APIDOC ## create (void* Parameters) ### Description Creates a main table with specified properties. ### Method N/A (Static Method) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **Pointer** (`void *`) - Pointer to the main table. #### Response Example N/A ``` -------------------------------- ### Uint32Buffer Methods Source: https://docs.superpowered.com/reference/latest/web-audio-helpers_lang=cpp Details the available methods for interacting with Uint32Buffer instances. ```APIDOC ## Uint32Buffer Methods ### Description Provides functionality to manage Uint32Buffer instances. ### Method `free()` ### Endpoint N/A (JavaScript Class Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript myBuffer.free(); ``` ### Response #### Success Response (200) None (This method deallocates memory and does not return a value). #### Response Example None ``` -------------------------------- ### ShortIntToFloat Source: https://docs.superpowered.com/reference/latest/dsp-functions Converts 16-bit signed integer input to 32-bit float output. ```APIDOC ## ShortIntToFloat ### Description Converts 16-bit signed integer input to 32-bit float output. ### Method POST ### Endpoint /websites/superpowered_reference/ShortIntToFloat ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **input** (Number pointer) - Stereo interleaved 16-bit input. - **output** (Number pointer) - Stereo interleaved 32-bit output. - **numberOfFrames** (Number) - The number of frames to process. - **numberOfChannels** (Number) - The number of channels. ### Request Example ```json { "input": 0, "output": 0, "numberOfFrames": 0, "numberOfChannels": 0 } ``` ### Response #### Success Response (200) None #### Response Example None ```