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

A very basic multichannel pitch shifter.

A very basic multichannel pitch shifter

Files

pitch_shifter.h (include), pitch_shifter_internal.h, pitch_shifter.c, pitch_shifter_internal.c

Include Header

/*
* Copyright 2020 Leo McCormack
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef __PITCH_SHIFTER_H_INCLUDED__
#define __PITCH_SHIFTER_H_INCLUDED__
#include "_common.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* ========================================================================== */
/* Presets + Constants */
/* ========================================================================== */
typedef enum {
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
#define PITCH_SHIFTER_NUM_FFTSIZE_OPTIONS ( 6 )
typedef enum {
PITCH_SHIFTER_OSAMP_2 = 1,
PITCH_SHIFTER_OSAMP_4,
PITCH_SHIFTER_OSAMP_8,
PITCH_SHIFTER_OSAMP_16,
PITCH_SHIFTER_OSAMP_32
#define PITCH_SHIFTER_NUM_OSAMP_OPTIONS ( 5 )
#define PITCH_SHIFTER_MAX_SHIFT_FACTOR ( 2.0f )
#define PITCH_SHIFTER_MIN_SHIFT_FACTOR ( 0.5f )
/* ========================================================================== */
/* Main Functions */
/* ========================================================================== */
void pitch_shifter_create(void** const phPS);
void pitch_shifter_destroy(void** const phPS);
void pitch_shifter_init(void* const hPS,
int samplerate);
void pitch_shifter_initCodec(void* const hPS);
void pitch_shifter_process(void* const hPS,
const float *const * inputs,
float* const* const outputs,
int nInputs,
int nOutputs,
int nSamples);
/* ========================================================================== */
/* Set Functions */
/* ========================================================================== */
void pitch_shifter_refreshParams(void* const hPS);
void pitch_shifter_setPitchShiftFactor(void* const hPS, float newValue);
void pitch_shifter_setNumChannels(void* const hPS, int newValue);
void pitch_shifter_setFFTSizeOption(void* const hPS,
void pitch_shifter_setOSampOption(void* const hPS,
/* ========================================================================== */
/* Get Functions */
/* ========================================================================== */
float pitch_shifter_getProgressBar0_1(void* const hPS);
void pitch_shifter_getProgressBarText(void* const hPS, char* text);
float pitch_shifter_getPitchShiftFactor(void* const hPS);
int pitch_shifter_getNCHrequired(void* const hPS);
int pitch_shifter_getProcessingDelay(void* const hPS);
#ifdef __cplusplus
} /* extern "C" { */
#endif /* __cplusplus */
#endif /* __PITCH_SHIFTER_H_INCLUDED__ */
A bunch of things that are common to many of the saf examples.
CODEC_STATUS
Current status of the codec.
Definition _common.h:201
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)
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_getProgressBarText(void *const hPS, char *text)
(Optional) Returns current intialisation/processing progress text
void pitch_shifter_create(void **const phPS)
Creates an instance of pitch_shifter.
PITCH_SHIFTER_FFTSIZE_OPTIONS
Available FFT size options.
int pitch_shifter_getProcessingDelay(void *const hPS)
Returns the processing delay in samples (may be used for delay compensation features)
float pitch_shifter_getProgressBar0_1(void *const hPS)
(Optional) Returns current intialisation/processing progress, between 0..1
PITCH_SHIFTER_OSAMP_OPTIONS
Available oversampling options.
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_destroy(void **const phPS)
Destroys an instance of pitch_shifter.
void pitch_shifter_initCodec(void *const hPS)
Intialises the codec variables, based on current global/user parameters.
CODEC_STATUS pitch_shifter_getCodecStatus(void *const hPS)
Returns current codec status (see CODEC_STATUS enum)
void pitch_shifter_init(void *const hPS, int samplerate)
Initialises an instance of pitch_shifter with default settings.
int pitch_shifter_getNCHrequired(void *const hPS)
Returns the number of channels required by the current configuration.
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_OSAMP_OPTIONS pitch_shifter_getOSampOption(void *const hPS)
Returns the oversampling factor used by the algorithm (see PITCH_SHIFTER_OSAMP_OPTIONS enum)
PITCH_SHIFTER_FFTSIZE_OPTIONS pitch_shifter_getFFTSizeOption(void *const hPS)
Returns the FFT size used by the algorithm (see PITCH_SHIFTER_FFTSIZE_OPTIONS enum)
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.
int pitch_shifter_getFrameSize(void)
Returns the processing framesize (i.e., number of samples processed with every _process() call )
void pitch_shifter_setNumChannels(void *const hPS, int newValue)
Sets the number channels to pitch shift.
void pitch_shifter_refreshParams(void *const hPS)
Sets all intialisation flags to 1; re-initialising all settings/variables as pitch_shifter is current...