SAF
Loading...
Searching...
No Matches
pitch_shifter.c File Reference

A very basic multichannel pitch shifter. More...

Go to the source code of this file.

Functions

void pitch_shifter_create (void **const phPS)
 Creates an instance of pitch_shifter.
 
void pitch_shifter_destroy (void **const phPS)
 Destroys an instance of pitch_shifter.
 
void pitch_shifter_init (void *const hPS, int sampleRate)
 Initialises an instance of pitch_shifter with default settings.
 
void pitch_shifter_initCodec (void *const hPS)
 Intialises the codec variables, based on current global/user parameters.
 
void pitch_shifter_process (void *const hPS, const float *const *inputs, float *const *const outputs, int nInputs, int nOutputs, int nSamples)
 Pitch shifts the input signals.
 
void pitch_shifter_refreshParams (void *const hPS)
 Sets all intialisation flags to 1; re-initialising all settings/variables as pitch_shifter is currently configured, at next available opportunity.
 
void pitch_shifter_setPitchShiftFactor (void *const hPS, float newValue)
 Sets the pitch shift factor, 1: no change, 2: up one octave, 0.5: down one octave.
 
void pitch_shifter_setNumChannels (void *const hPS, int newValue)
 Sets the number channels to pitch shift.
 
void pitch_shifter_setFFTSizeOption (void *const hPS, PITCH_SHIFTER_FFTSIZE_OPTIONS newOption)
 Sets the FFT size used by the algorithm (see PITCH_SHIFTER_FFTSIZE_OPTIONS enum)
 
void pitch_shifter_setOSampOption (void *const hPS, PITCH_SHIFTER_OSAMP_OPTIONS newOption)
 Sets the oversampling factor used by the algorithm (see PITCH_SHIFTER_OSAMP_OPTIONS enum)
 
int pitch_shifter_getFrameSize (void)
 Returns the processing framesize (i.e., number of samples processed with every _process() call )
 
CODEC_STATUS pitch_shifter_getCodecStatus (void *const hBin)
 Returns current codec status (see CODEC_STATUS enum)
 
float pitch_shifter_getProgressBar0_1 (void *const hBin)
 (Optional) Returns current intialisation/processing progress, between 0..1
 
void pitch_shifter_getProgressBarText (void *const hBin, char *text)
 (Optional) Returns current intialisation/processing progress text
 
float pitch_shifter_getPitchShiftFactor (void *const hPS)
 Returns the pitch shift factor, 1: no change, 2: up one octave, 0.5: down one octave.
 
PITCH_SHIFTER_FFTSIZE_OPTIONS pitch_shifter_getFFTSizeOption (void *const hPS)
 Returns the FFT size used by the algorithm (see PITCH_SHIFTER_FFTSIZE_OPTIONS enum)
 
PITCH_SHIFTER_OSAMP_OPTIONS pitch_shifter_getOSampOption (void *const hPS)
 Returns the oversampling factor used by the algorithm (see PITCH_SHIFTER_OSAMP_OPTIONS enum)
 
int pitch_shifter_getNCHrequired (void *const hPS)
 Returns the number of channels required by the current configuration.
 
int pitch_shifter_getProcessingDelay (void *const hPS)
 Returns the processing delay in samples (may be used for delay compensation features)
 

Detailed Description

A very basic multichannel pitch shifter.

Author
Leo McCormack
Date
05.05.2020
License
ISC

Definition in file pitch_shifter.c.

Function Documentation

◆ pitch_shifter_create()

void pitch_shifter_create ( void **const phPS)

Creates an instance of pitch_shifter.

Parameters
[in]phPS(&) address of pitch_shifter handle

Definition at line 29 of file pitch_shifter.c.

◆ pitch_shifter_destroy()

void pitch_shifter_destroy ( void **const phPS)

Destroys an instance of pitch_shifter.

Parameters
[in]phPS(&) address of pitch_shifter handle

Definition at line 65 of file pitch_shifter.c.

◆ pitch_shifter_getCodecStatus()

CODEC_STATUS pitch_shifter_getCodecStatus ( void *const hBin)

Returns current codec status (see CODEC_STATUS enum)

Definition at line 270 of file pitch_shifter.c.

◆ pitch_shifter_getFFTSizeOption()

PITCH_SHIFTER_FFTSIZE_OPTIONS pitch_shifter_getFFTSizeOption ( void *const hPS)

Returns the FFT size used by the algorithm (see PITCH_SHIFTER_FFTSIZE_OPTIONS enum)

Definition at line 294 of file pitch_shifter.c.

◆ pitch_shifter_getFrameSize()

int pitch_shifter_getFrameSize ( void )

Returns the processing framesize (i.e., number of samples processed with every _process() call )

Definition at line 265 of file pitch_shifter.c.

◆ pitch_shifter_getNCHrequired()

int pitch_shifter_getNCHrequired ( void *const hPS)

Returns the number of channels required by the current configuration.

Definition at line 306 of file pitch_shifter.c.

◆ pitch_shifter_getOSampOption()

PITCH_SHIFTER_OSAMP_OPTIONS pitch_shifter_getOSampOption ( void *const hPS)

Returns the oversampling factor used by the algorithm (see PITCH_SHIFTER_OSAMP_OPTIONS enum)

Definition at line 300 of file pitch_shifter.c.

◆ pitch_shifter_getPitchShiftFactor()

float pitch_shifter_getPitchShiftFactor ( void *const hPS)

Returns the pitch shift factor, 1: no change, 2: up one octave, 0.5: down one octave.

Definition at line 288 of file pitch_shifter.c.

◆ pitch_shifter_getProcessingDelay()

int pitch_shifter_getProcessingDelay ( void *const hPS)

Returns the processing delay in samples (may be used for delay compensation features)

Definition at line 312 of file pitch_shifter.c.

◆ pitch_shifter_getProgressBar0_1()

float pitch_shifter_getProgressBar0_1 ( void *const hPS)

(Optional) Returns current intialisation/processing progress, between 0..1

  • 0: intialisation/processing has started
  • 1: intialisation/processing has ended

Definition at line 276 of file pitch_shifter.c.

◆ pitch_shifter_getProgressBarText()

void pitch_shifter_getProgressBarText ( void *const hPS,
char * text )

(Optional) Returns current intialisation/processing progress text

Note
"text" string should be (at least) of length: PROGRESSBARTEXT_CHAR_LENGTH

Definition at line 282 of file pitch_shifter.c.

◆ pitch_shifter_init()

void pitch_shifter_init ( void *const hPS,
int samplerate )

Initialises an instance of pitch_shifter with default settings.

Warning
This should not be called while _process() is on-going!
Parameters
[in]hPSpitch_shifter handle
[in]samplerateHost samplerate.

Definition at line 89 of file pitch_shifter.c.

◆ pitch_shifter_initCodec()

void pitch_shifter_initCodec ( void *const hPS)

Intialises the codec variables, based on current global/user parameters.

Note
This function is fully threadsafe. It can even be called periodically via a timer on one thread, while calling _process() on another thread. Since, if a set function is called (that warrants a re-init), then a flag is triggered internally and the next time this function is called, it will wait until the current process() function has completed before reinitialising the relevant parameters. If the _initCodec() takes longer than the time it takes for process() to be called again, then process() is simply bypassed until the codec is ready.
This function does nothing if no re-initialisations are required.
Parameters
[in]hPSpitch_shifter handle

Definition at line 103 of file pitch_shifter.c.

◆ pitch_shifter_process()

void pitch_shifter_process ( void *const hPS,
const float *const * inputs,
float *const *const outputs,
int nInputs,
int nOutputs,
int nSamples )

Pitch shifts the input signals.

Parameters
[in]hPSpitch_shifter handle
[in]inputsInput channel buffers; 2-D array: nInputs x nSamples
[in]outputsOutput channel buffers; 2-D array: nOutputs x nSamples
[in]nInputsNumber of input channels
[in]nOutputsNumber of output channels
[in]nSamplesNumber of samples in 'inputs'/'output' matrices

Definition at line 163 of file pitch_shifter.c.

◆ pitch_shifter_refreshParams()

void pitch_shifter_refreshParams ( void *const hPS)

Sets all intialisation flags to 1; re-initialising all settings/variables as pitch_shifter is currently configured, at next available opportunity.

Parameters
[in]hPSpitch_shifter handle

Definition at line 222 of file pitch_shifter.c.

◆ pitch_shifter_setFFTSizeOption()

void pitch_shifter_setFFTSizeOption ( void *const hPS,
PITCH_SHIFTER_FFTSIZE_OPTIONS newOption )

Sets the FFT size used by the algorithm (see PITCH_SHIFTER_FFTSIZE_OPTIONS enum)

Definition at line 240 of file pitch_shifter.c.

◆ pitch_shifter_setNumChannels()

void pitch_shifter_setNumChannels ( void *const hPS,
int newValue )

Sets the number channels to pitch shift.

Definition at line 233 of file pitch_shifter.c.

◆ pitch_shifter_setOSampOption()

void pitch_shifter_setOSampOption ( void *const hPS,
PITCH_SHIFTER_OSAMP_OPTIONS newOption )

Sets the oversampling factor used by the algorithm (see PITCH_SHIFTER_OSAMP_OPTIONS enum)

Definition at line 251 of file pitch_shifter.c.

◆ pitch_shifter_setPitchShiftFactor()

void pitch_shifter_setPitchShiftFactor ( void *const hPS,
float newValue )

Sets the pitch shift factor, 1: no change, 2: up one octave, 0.5: down one octave.

Definition at line 227 of file pitch_shifter.c.