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

A very basic multichannel pitch shifter. More...

#include "_common.h"

Go to the source code of this file.

Macros

#define PITCH_SHIFTER_NUM_FFTSIZE_OPTIONS   ( 6 )
 Number of FFT size options.
 
#define PITCH_SHIFTER_NUM_OSAMP_OPTIONS   ( 5 )
 Number of over-sampling options.
 
#define PITCH_SHIFTER_MAX_SHIFT_FACTOR   ( 2.0f )
 Maximum pitch shifting factor.
 
#define PITCH_SHIFTER_MIN_SHIFT_FACTOR   ( 0.5f )
 Minimum pitch shifting factor.
 

Enumerations

enum  PITCH_SHIFTER_FFTSIZE_OPTIONS {
  PITCH_SHIFTER_FFTSIZE_512 = 1 , PITCH_SHIFTER_FFTSIZE_1024 , PITCH_SHIFTER_FFTSIZE_2048 , PITCH_SHIFTER_FFTSIZE_4096 ,
  PITCH_SHIFTER_FFTSIZE_8192 , PITCH_SHIFTER_FFTSIZE_16384
}
 Available FFT size options. More...
 
enum  PITCH_SHIFTER_OSAMP_OPTIONS {
  PITCH_SHIFTER_OSAMP_2 = 1 , PITCH_SHIFTER_OSAMP_4 , PITCH_SHIFTER_OSAMP_8 , PITCH_SHIFTER_OSAMP_16 ,
  PITCH_SHIFTER_OSAMP_32
}
 Available oversampling options. More...
 

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 hPS)
 Returns current codec status (see CODEC_STATUS enum)
 
float pitch_shifter_getProgressBar0_1 (void *const hPS)
 (Optional) Returns current intialisation/processing progress, between 0..1
 
void pitch_shifter_getProgressBarText (void *const hPS, 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.h.

Macro Definition Documentation

◆ PITCH_SHIFTER_MAX_SHIFT_FACTOR

#define PITCH_SHIFTER_MAX_SHIFT_FACTOR   ( 2.0f )

Maximum pitch shifting factor.

Definition at line 83 of file pitch_shifter.h.

◆ PITCH_SHIFTER_MIN_SHIFT_FACTOR

#define PITCH_SHIFTER_MIN_SHIFT_FACTOR   ( 0.5f )

Minimum pitch shifting factor.

Definition at line 86 of file pitch_shifter.h.

◆ PITCH_SHIFTER_NUM_FFTSIZE_OPTIONS

#define PITCH_SHIFTER_NUM_FFTSIZE_OPTIONS   ( 6 )

Number of FFT size options.

Definition at line 64 of file pitch_shifter.h.

◆ PITCH_SHIFTER_NUM_OSAMP_OPTIONS

#define PITCH_SHIFTER_NUM_OSAMP_OPTIONS   ( 5 )

Number of over-sampling options.

Definition at line 80 of file pitch_shifter.h.

Enumeration Type Documentation

◆ PITCH_SHIFTER_FFTSIZE_OPTIONS

Available FFT size options.

The higher it is, the more drastic the pitch shifting factor can be, at the cost of increased latency and cpu requirements

Definition at line 53 of file pitch_shifter.h.

◆ PITCH_SHIFTER_OSAMP_OPTIONS

Available oversampling options.

The higher it is, the better the signal fidelity, but at the cost of increased latency and cpu requirements

Definition at line 70 of file pitch_shifter.h.

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
Examples
pitch_shifter.h.

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
Examples
pitch_shifter.h.

Definition at line 65 of file pitch_shifter.c.

◆ pitch_shifter_getCodecStatus()

CODEC_STATUS pitch_shifter_getCodecStatus ( void *const hPS)

Returns current codec status (see CODEC_STATUS enum)

Examples
pitch_shifter.h.

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)

Examples
pitch_shifter.h.

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 )

Examples
pitch_shifter.h.

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.

Examples
pitch_shifter.h.

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)

Examples
pitch_shifter.h.

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.

Examples
pitch_shifter.h.

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)

Examples
pitch_shifter.h.

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
Examples
pitch_shifter.h.

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
Examples
pitch_shifter.h.

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.
Examples
pitch_shifter.h.

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
Examples
pitch_shifter.h.

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
Examples
pitch_shifter.h.

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
Examples
pitch_shifter.h.

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)

Examples
pitch_shifter.h.

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.

Examples
pitch_shifter.h.

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)

Examples
pitch_shifter.h.

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.

Examples
pitch_shifter.h.

Definition at line 227 of file pitch_shifter.c.