SAF
Loading...
Searching...
No Matches
pitch_shifter.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Leo McCormack
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
15 */
16
36#ifndef __PITCH_SHIFTER_H_INCLUDED__
37#define __PITCH_SHIFTER_H_INCLUDED__
38
39#include "_common.h"
40
41#ifdef __cplusplus
42extern "C" {
43#endif /* __cplusplus */
44
45/* ========================================================================== */
46/* Presets + Constants */
47/* ========================================================================== */
48
53typedef enum {
54 PITCH_SHIFTER_FFTSIZE_512 = 1,
55 PITCH_SHIFTER_FFTSIZE_1024,
56 PITCH_SHIFTER_FFTSIZE_2048,
57 PITCH_SHIFTER_FFTSIZE_4096,
58 PITCH_SHIFTER_FFTSIZE_8192,
59 PITCH_SHIFTER_FFTSIZE_16384
60
62
64#define PITCH_SHIFTER_NUM_FFTSIZE_OPTIONS ( 6 )
65
70typedef enum {
71 PITCH_SHIFTER_OSAMP_2 = 1,
72 PITCH_SHIFTER_OSAMP_4,
73 PITCH_SHIFTER_OSAMP_8,
74 PITCH_SHIFTER_OSAMP_16,
75 PITCH_SHIFTER_OSAMP_32
76
78
80#define PITCH_SHIFTER_NUM_OSAMP_OPTIONS ( 5 )
81
83#define PITCH_SHIFTER_MAX_SHIFT_FACTOR ( 2.0f )
84
86#define PITCH_SHIFTER_MIN_SHIFT_FACTOR ( 0.5f )
87
88
89/* ========================================================================== */
90/* Main Functions */
91/* ========================================================================== */
92
98void pitch_shifter_create(void** const phPS);
99
105void pitch_shifter_destroy(void** const phPS);
106
115void pitch_shifter_init(void* const hPS,
116 int samplerate);
117
133void pitch_shifter_initCodec(void* const hPS);
134
145void pitch_shifter_process(void* const hPS,
146 const float *const * inputs,
147 float* const* const outputs,
148 int nInputs,
149 int nOutputs,
150 int nSamples);
151
152
153/* ========================================================================== */
154/* Set Functions */
155/* ========================================================================== */
156
163void pitch_shifter_refreshParams(void* const hPS);
164
169void pitch_shifter_setPitchShiftFactor(void* const hPS, float newValue);
170
172void pitch_shifter_setNumChannels(void* const hPS, int newValue);
173
178void pitch_shifter_setFFTSizeOption(void* const hPS,
180
185void pitch_shifter_setOSampOption(void* const hPS,
187
188
189/* ========================================================================== */
190/* Get Functions */
191/* ========================================================================== */
192
198
201
207float pitch_shifter_getProgressBar0_1(void* const hPS);
208
215void pitch_shifter_getProgressBarText(void* const hPS, char* text);
216
221float pitch_shifter_getPitchShiftFactor(void* const hPS);
222
228
234
236int pitch_shifter_getNCHrequired(void* const hPS);
237
242int pitch_shifter_getProcessingDelay(void* const hPS);
243
244
245#ifdef __cplusplus
246} /* extern "C" { */
247#endif /* __cplusplus */
248
249#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...