SAF
Loading...
Searching...
No Matches
pitch_shifter_internal.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
25
26#ifndef __PITCH_SHIFTER_INTERNAL_H_INCLUDED__
27#define __PITCH_SHIFTER_INTERNAL_H_INCLUDED__
28
29#include "pitch_shifter.h" /* Include header for this example */
30#include "saf.h" /* Main include header for SAF */
31#include "saf_externals.h" /* To also include SAF dependencies (cblas etc.) */
32
33#ifdef __cplusplus
34extern "C" {
35#endif /* __cplusplus */
36
37/* ========================================================================== */
38/* Internal Parameters */
39/* ========================================================================== */
40
41#if !defined(PITCH_SHIFTER_FRAME_SIZE)
42# if defined(FRAME_SIZE) /* Use the global framesize if it is specified: */
43# define PITCH_SHIFTER_FRAME_SIZE ( FRAME_SIZE )
44# else /* Otherwise, the default framesize for this example is: */
45# define PITCH_SHIFTER_FRAME_SIZE ( 128 )
46# endif
47#endif
48
49#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
50 typedef _Atomic PITCH_SHIFTER_FFTSIZE_OPTIONS _Atomic_PITCH_SHIFTER_FFTSIZE_OPTIONS;
51 typedef _Atomic PITCH_SHIFTER_OSAMP_OPTIONS _Atomic_PITCH_SHIFTER_OSAMP_OPTIONS;
52#else
53 typedef PITCH_SHIFTER_FFTSIZE_OPTIONS _Atomic_PITCH_SHIFTER_FFTSIZE_OPTIONS;
54 typedef PITCH_SHIFTER_OSAMP_OPTIONS _Atomic_PITCH_SHIFTER_OSAMP_OPTIONS;
55#endif
56
57/* ========================================================================== */
58/* Structures */
59/* ========================================================================== */
60
62typedef struct _pitch_shifter
63{
64 /* FIFO buffers */
66 float** inFIFO;
67 float** outFIFO;
68
69 /* internal */
70 void* hSmb;
71 _Atomic_CODEC_STATUS codecStatus;
72 _Atomic_FLOAT32 progressBar0_1;
74 _Atomic_PROC_STATUS procStatus;
75 float sampleRate;
78 _Atomic_INT32 new_nChannels;
81
82 /* user parameters */
83 _Atomic_INT32 nChannels;
84 _Atomic_FLOAT32 pitchShift_factor;
85 _Atomic_PITCH_SHIFTER_FFTSIZE_OPTIONS fftsize_option;
86 _Atomic_PITCH_SHIFTER_OSAMP_OPTIONS osamp_option;
87
89
90
91/* ========================================================================== */
92/* Internal Functions */
93/* ========================================================================== */
94
96void pitch_shifter_setCodecStatus(void* const hPS,
97 CODEC_STATUS newStatus);
98
99
100#ifdef __cplusplus
101} /* extern "C" { */
102#endif /* __cplusplus */
103
104#endif /* __PITCH_SHIFTER_INTERNAL_H_INCLUDED__ */
#define MAX_NUM_CHANNELS
Maximum number of input/output channels supported.
Definition _common.h:234
CODEC_STATUS
Current status of the codec.
Definition _common.h:205
A very basic multichannel pitch shifter.
PITCH_SHIFTER_FFTSIZE_OPTIONS
Available FFT size options.
PITCH_SHIFTER_OSAMP_OPTIONS
Available oversampling options.
#define PITCH_SHIFTER_FRAME_SIZE
Framesize, in time-domain samples.
void pitch_shifter_setCodecStatus(void *const hPS, CODEC_STATUS newStatus)
Sets codec status (see CODEC_STATUS enum)
Main include header for the Spatial_Audio_Framework (SAF)
Include header for SAF externals.
Main struct for the pitch_shifter.
float inputFrame[MAX_NUM_CHANNELS][PITCH_SHIFTER_FRAME_SIZE]
Current input frame.
float outputFrame[MAX_NUM_CHANNELS][PITCH_SHIFTER_FRAME_SIZE]
Current output frame.
_Atomic_PROC_STATUS procStatus
see PROC_STATUS
_Atomic_FLOAT32 progressBar0_1
Current (re)initialisation progress, between [0..1].
float ** inFIFO
Input FIFO buffer.
_Atomic_PITCH_SHIFTER_FFTSIZE_OPTIONS fftsize_option
see PITCH_SHIFTER_FFTSIZE_OPTIONS
_Atomic_FLOAT32 pitchShift_factor
1: no shift, 0.5: down one octave, 2: up one octave
_Atomic_INT32 nChannels
Current number of input/output channels.
_Atomic_CODEC_STATUS codecStatus
see CODEC_STATUS
char * progressBarText
Current (re)initialisation step, string.
int FIFO_idx
FIFO buffer index.
int stepsize
Hop size in samples.
_Atomic_PITCH_SHIFTER_OSAMP_OPTIONS osamp_option
see PITCH_SHIFTER_OSAMP_OPTIONS
void * hSmb
pitch-shifter handle
float ** outFIFO
Output FIFO buffer.
float sampleRate
Host sampling rate, in Hz.
_Atomic_INT32 new_nChannels
(current value will be replaced by this after next re-init)