Class: Resampler
Overview
Linear or 6-point resampler, audio reverser and 16-bit to 32-bit audio converter.
It doesn't allocate any internal buffers and needs just a few bytes of memory.
How to implement
// Constructor. Has no additional parameters.let 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();// Processes the audio.let outputNumberOfFrames = resampler.process(input, // Pointer to short integer numbers, 16-bit stereo interleaved input. Should be numberOfFrames * 2 + 64 big.output, // Pointer to floating point numbers, 32-bit stereo interleaved output. Should be big enough to store the expected number of output frames and some more.128, // Number of frames to process.false, // If true, the output will be backwards (reverse playback).false, // Enables more sophisticated processing to reduce interpolation noise. Good for scratching for example, but not recommended for continous music playback above 0.5 rate.0 // "rateAdd": Changes rate smoothly during process(). Useful for scratching or super smooth rate changes. After process() rate will be changed, but may or may not be precisely equal to the desired target value.);// Processes the audio.let outputNumberOfFrames = resampler.process16(input, // Pointer to short integer numbers, 16-bit stereo interleaved input. Should be numberOfFrames * 2 + 64 big.temp, // Pointer to floating point numbers. Should be numberOfFrames * 2 + 64 big.output, // Pointer to short integer numbers, 16-bit stereo interleaved output. Should be big enough to store the expected number of output frames and some more.128, // Number of frames to process.false, // If true, the output will be backwards (reverse playback).false, // Enables more sophisticated processing to reduce interpolation noise. Good for scratching for example, but not recommended for continous music playback above 0.5 rate.0 // "rateAdd": Changes rate smoothly during process(). Useful for scratching or super smooth rate changes. After process() rate will be changed, but may or may not be precisely equal to the desired target value.);// Destructor (to free up memory).resampler.destruct();
#include "SuperpoweredResampler.h"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);...}
Properties
rate
PROPERTYThe rate of the resampler. If rate = 1, process() is 'transparent' without any effect on audio quality.
Type | Min | Max | Default | Number | 1 |
---|
rate
PROPERTYThe rate of the resampler. If rate = 1, process() is 'transparent' without any effect on audio quality.
Type | Min | Max | Default | float | 1 |
---|
Methods
constructor
METHODCreates a Resampler instance.ParametersNoneReturnsType Description Superpowered.Resampler
The constructed instance. constructor
METHODCreates a Resampler instance.ParametersNoneReturnsType Description Superpowered::Resampler
The constructed instance. destruct
METHODDestructor to free Linear Memory.ParametersNoneReturnsNoneprocess
METHODProcesses the audio.ParametersReturnsName Type Description input Number (pointer in Linear Memory)
16-bit stereo interleaved input. Should be numberOfFrames * 2 + 64 big. output Number (pointer in Linear Memory)
32-bit stereo interleaved output. Should be big enough to store the expected number of output frames and some more. numberOfFrames Number
Number of frames to process. reverse Boolean
If true, the output will be backwards (reverse playback). highQuality Boolean
Enables more sophisticated processing to reduce interpolation noise. Good for scratching for example, but not recommended for continous music playback above 0.5 rate. rateAdd Number
Changes rate smoothly during process(). Useful for scratching or super smooth rate changes. After process() rate will be changed, but may or may not be precisely equal to the desired target value. Type Description Number
The number of output frames. process
METHODProcesses the audio.ParametersReturnsName Type Default Description input short int *
16-bit stereo interleaved input. Should be numberOfFrames * 2 + 64 big. output float *
32-bit stereo interleaved output. Should be big enough to store the expected number of output frames and some more. numberOfFrames int
Number of frames to process. reverse bool
false If true, the output will be backwards (reverse playback). highQuality bool
false Enables more sophisticated processing to reduce interpolation noise. Good for scratching for example, but not recommended for continous music playback above 0.5 rate. rateAdd float
0 Changes rate smoothly during process(). Useful for scratching or super smooth rate changes. After process() rate will be changed, but may or may not be precisely equal to the desired target value. Type Description int
The number of output frames. process16
METHODProcesses the audio.ParametersReturnsName Type Description input Number (pointer in Linear Memory)
16-bit stereo interleaved input. Should be numberOfFrames * 2 + 64 big. temp Number (pointer in Linear Memory)
Floating point buffer. Should be numberOfFrames * 2 + 64 big. output Number (pointer in Linear Memory)
16-bit stereo interleaved input. Should be big enough to store the expected number of output frames and some more. numberOfFrames Number
Number of frames to process. reverse Boolean
If true, the output will be backwards (reverse playback). highQuality Boolean
Enables more sophisticated processing to reduce interpolation noise. Good for scratching for example, but not recommended for continous music playback above 0.5 rate. rateAdd Number
Changes rate smoothly during process(). Useful for scratching or super smooth rate changes. After process() rate will be changed, but may or may not be precisely equal to the desired target value. Type Description Number
The number of output frames. process16
METHODProcesses the audio.ParametersReturnsName Type Default Description input short int *
16-bit stereo interleaved input. Should be numberOfFrames * 2 + 64 big. temp float *
Floating point buffer. Should be numberOfFrames * 2 + 64 big. output short int *
16-bit stereo interleaved input. Should be big enough to store the expected number of output frames and some more. numberOfFrames int
Number of frames to process. reverse bool
false If true, the output will be backwards (reverse playback). highQuality bool
false Enables more sophisticated processing to reduce interpolation noise. Good for scratching for example, but not recommended for continous music playback above 0.5 rate. rateAdd Number
0 Changes rate smoothly during process(). Useful for scratching or super smooth rate changes. After process() rate will be changed, but may or may not be precisely equal to the desired target value. Type Description int
The number of output frames. reset
METHODReset all internals. Doesn't change rate.ParametersNoneReturnsNonereset
METHODReset all internals. Doesn't change rate.ParametersNoneReturnsNone