CI130X SDK API手册  2.2.0
本手册用于描述CI130X SDK各个组件和驱动API
结构体 | 宏定义 | 函数 | 变量
sonic.c 文件参考
#include "sonic.h"
#include <limits.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "FreeRTOS.h"
#include "romlib_runtime.h"

结构体

struct  sonicStreamStruct
 

宏定义

#define malloc   pvPortMalloc
 
#define calloc   pvPortCalloc
 
#define realloc   pvPortRealloc
 
#define free   vPortFree
 
#define SINC_FILTER_POINTS   12 /* I am not able to hear improvement with higher N. */
 
#define SINC_TABLE_SIZE   601
 

函数

void * pvPortCalloc (size_t nmemb, size_t size)
 
void * pvPortMalloc (size_t xWantedSize)
 
void * pvPortRealloc (void *pv, size_t size)
 
void vPortFree (void *pv)
 
static void scaleSamples (short *samples, int numSamples, float volume)
 
float sonicGetSpeed (sonicStream stream)
 
void sonicSetSpeed (sonicStream stream, float speed)
 
float sonicGetPitch (sonicStream stream)
 
void sonicSetPitch (sonicStream stream, float pitch)
 
float sonicGetRate (sonicStream stream)
 
void sonicSetRate (sonicStream stream, float rate)
 
int sonicGetChordPitch (sonicStream stream)
 
void sonicSetChordPitch (sonicStream stream, int useChordPitch)
 
int sonicGetQuality (sonicStream stream)
 
void sonicSetQuality (sonicStream stream, int quality)
 
float sonicGetVolume (sonicStream stream)
 
void sonicSetVolume (sonicStream stream, float volume)
 
static void freeStreamBuffers (sonicStream stream)
 
void sonicDestroyStream (sonicStream stream)
 
static int allocateStreamBuffers (sonicStream stream, int sampleRate, int numChannels)
 
sonicStream sonicCreateStream (int sampleRate, int numChannels)
 
int sonicGetSampleRate (sonicStream stream)
 
int sonicSetSampleRate (sonicStream stream, int sampleRate)
 
int sonicGetNumChannels (sonicStream stream)
 
int sonicSetNumChannels (sonicStream stream, int numChannels)
 
void sonicCleanStream (sonicStream stream)
 
static int enlargeOutputBufferIfNeeded (sonicStream stream, int numSamples)
 
static int enlargeInputBufferIfNeeded (sonicStream stream, int numSamples)
 
static int addFloatSamplesToInputBuffer (sonicStream stream, float *samples, int numSamples)
 
static int addShortSamplesToInputBuffer (sonicStream stream, short *samples, int numSamples)
 
static int addUnsignedCharSamplesToInputBuffer (sonicStream stream, unsigned char *samples, int numSamples)
 
static void removeInputSamples (sonicStream stream, int position)
 
static int copyToOutput (sonicStream stream, short *samples, int numSamples)
 
static int copyInputToOutput (sonicStream stream, int position)
 
int sonicReadFloatFromStream (sonicStream stream, float *samples, int maxSamples)
 
int sonicReadShortFromStream (sonicStream stream, short *samples, int maxSamples)
 
int sonicReadUnsignedCharFromStream (sonicStream stream, unsigned char *samples, int maxSamples)
 
int sonicFlushStream (sonicStream stream)
 
int sonicSamplesAvailable (sonicStream stream)
 
static void downSampleInput (sonicStream stream, short *samples, int skip)
 
static int findPitchPeriodInRange (short *samples, int minPeriod, int maxPeriod, int *retMinDiff, int *retMaxDiff)
 
static int prevPeriodBetter (sonicStream stream, int period, int minDiff, int maxDiff, int preferNewPeriod)
 
static int findPitchPeriod (sonicStream stream, short *samples, int preferNewPeriod)
 
static void overlapAdd (int numSamples, int numChannels, short *out, short *rampDown, short *rampUp)
 
static void overlapAddWithSeparation (int numSamples, int numChannels, int separation, short *out, short *rampDown, short *rampUp)
 
static int moveNewSamplesToPitchBuffer (sonicStream stream, int originalNumOutputSamples)
 
static void removePitchSamples (sonicStream stream, int numSamples)
 
static int adjustPitch (sonicStream stream, int originalNumOutputSamples)
 
static int findSincCoefficient (int i, int ratio, int width)
 
static int getSign (int value)
 
static short interpolate (sonicStream stream, short *in, int oldSampleRate, int newSampleRate)
 
static int adjustRate (sonicStream stream, float rate, int originalNumOutputSamples)
 
static int skipPitchPeriod (sonicStream stream, short *samples, float speed, int period)
 
static int insertPitchPeriod (sonicStream stream, short *samples, float speed, int period)
 
static int changeSpeed (sonicStream stream, float speed)
 
static int processStreamInput (sonicStream stream)
 
int sonicWriteFloatToStream (sonicStream stream, float *samples, int numSamples)
 
int sonicWriteShortToStream (sonicStream stream, short *samples, int numSamples)
 
int sonicWriteUnsignedCharToStream (sonicStream stream, unsigned char *samples, int numSamples)
 
int sonicChangeFloatSpeed (float *samples, int numSamples, float speed, float pitch, float rate, float volume, int useChordPitch, int sampleRate, int numChannels)
 
int sonicChangeShortSpeed (short *samples, int numSamples, float speed, float pitch, float rate, float volume, int useChordPitch, int sampleRate, int numChannels)
 

变量

static short sincTable [601]
 

结构体说明

◆ sonicStreamStruct

struct sonicStreamStruct
成员变量
float avePower
short * downSampleBuffer
short * inputBuffer
int inputBufferSize
int maxPeriod
int maxRequired
int minPeriod
int newRatePosition
int numChannels
int numInputSamples
int numOutputSamples
int numPitchSamples
int oldRatePosition
short * outputBuffer
int outputBufferSize
float pitch
short * pitchBuffer
int pitchBufferSize
int prevMinDiff
int prevPeriod
int quality
float rate
int remainingInputToCopy
int sampleRate
float speed
int useChordPitch
float volume

宏定义说明

◆ calloc

#define calloc   pvPortCalloc

◆ free

#define free   vPortFree

◆ malloc

#define malloc   pvPortMalloc

◆ realloc

#define realloc   pvPortRealloc

◆ SINC_FILTER_POINTS

#define SINC_FILTER_POINTS   12 /* I am not able to hear improvement with higher N. */

◆ SINC_TABLE_SIZE

#define SINC_TABLE_SIZE   601

函数说明

◆ addFloatSamplesToInputBuffer()

static int addFloatSamplesToInputBuffer ( sonicStream  stream,
float *  samples,
int  numSamples 
)
static

◆ addShortSamplesToInputBuffer()

static int addShortSamplesToInputBuffer ( sonicStream  stream,
short *  samples,
int  numSamples 
)
static

◆ addUnsignedCharSamplesToInputBuffer()

static int addUnsignedCharSamplesToInputBuffer ( sonicStream  stream,
unsigned char *  samples,
int  numSamples 
)
static

◆ adjustPitch()

static int adjustPitch ( sonicStream  stream,
int  originalNumOutputSamples 
)
static

◆ adjustRate()

static int adjustRate ( sonicStream  stream,
float  rate,
int  originalNumOutputSamples 
)
static

◆ allocateStreamBuffers()

static int allocateStreamBuffers ( sonicStream  stream,
int  sampleRate,
int  numChannels 
)
static

◆ changeSpeed()

static int changeSpeed ( sonicStream  stream,
float  speed 
)
static

◆ copyInputToOutput()

static int copyInputToOutput ( sonicStream  stream,
int  position 
)
static

◆ copyToOutput()

static int copyToOutput ( sonicStream  stream,
short *  samples,
int  numSamples 
)
static

◆ downSampleInput()

static void downSampleInput ( sonicStream  stream,
short *  samples,
int  skip 
)
static

◆ enlargeInputBufferIfNeeded()

static int enlargeInputBufferIfNeeded ( sonicStream  stream,
int  numSamples 
)
static

◆ enlargeOutputBufferIfNeeded()

static int enlargeOutputBufferIfNeeded ( sonicStream  stream,
int  numSamples 
)
static

◆ findPitchPeriod()

static int findPitchPeriod ( sonicStream  stream,
short *  samples,
int  preferNewPeriod 
)
static

◆ findPitchPeriodInRange()

static int findPitchPeriodInRange ( short *  samples,
int  minPeriod,
int  maxPeriod,
int *  retMinDiff,
int *  retMaxDiff 
)
static

◆ findSincCoefficient()

static int findSincCoefficient ( int  i,
int  ratio,
int  width 
)
static

◆ freeStreamBuffers()

static void freeStreamBuffers ( sonicStream  stream)
static

◆ getSign()

static int getSign ( int  value)
static

◆ insertPitchPeriod()

static int insertPitchPeriod ( sonicStream  stream,
short *  samples,
float  speed,
int  period 
)
static

◆ interpolate()

static short interpolate ( sonicStream  stream,
short *  in,
int  oldSampleRate,
int  newSampleRate 
)
static

◆ moveNewSamplesToPitchBuffer()

static int moveNewSamplesToPitchBuffer ( sonicStream  stream,
int  originalNumOutputSamples 
)
static

◆ overlapAdd()

static void overlapAdd ( int  numSamples,
int  numChannels,
short *  out,
short *  rampDown,
short *  rampUp 
)
static

◆ overlapAddWithSeparation()

static void overlapAddWithSeparation ( int  numSamples,
int  numChannels,
int  separation,
short *  out,
short *  rampDown,
short *  rampUp 
)
static

◆ prevPeriodBetter()

static int prevPeriodBetter ( sonicStream  stream,
int  period,
int  minDiff,
int  maxDiff,
int  preferNewPeriod 
)
static

◆ processStreamInput()

static int processStreamInput ( sonicStream  stream)
static

◆ pvPortCalloc()

void* pvPortCalloc ( size_t  nmemb,
size_t  size 
)

◆ pvPortMalloc()

void* pvPortMalloc ( size_t  xWantedSize)

◆ pvPortRealloc()

void* pvPortRealloc ( void *  pv,
size_t  size 
)

◆ removeInputSamples()

static void removeInputSamples ( sonicStream  stream,
int  position 
)
static

◆ removePitchSamples()

static void removePitchSamples ( sonicStream  stream,
int  numSamples 
)
static

◆ scaleSamples()

static void scaleSamples ( short *  samples,
int  numSamples,
float  volume 
)
static

◆ skipPitchPeriod()

static int skipPitchPeriod ( sonicStream  stream,
short *  samples,
float  speed,
int  period 
)
static

◆ sonicChangeFloatSpeed()

int sonicChangeFloatSpeed ( float *  samples,
int  numSamples,
float  speed,
float  pitch,
float  rate,
float  volume,
int  useChordPitch,
int  sampleRate,
int  numChannels 
)

◆ sonicChangeShortSpeed()

int sonicChangeShortSpeed ( short *  samples,
int  numSamples,
float  speed,
float  pitch,
float  rate,
float  volume,
int  useChordPitch,
int  sampleRate,
int  numChannels 
)

◆ sonicCleanStream()

void sonicCleanStream ( sonicStream  stream)

◆ sonicCreateStream()

sonicStream sonicCreateStream ( int  sampleRate,
int  numChannels 
)

◆ sonicDestroyStream()

void sonicDestroyStream ( sonicStream  stream)

◆ sonicFlushStream()

int sonicFlushStream ( sonicStream  stream)

◆ sonicGetChordPitch()

int sonicGetChordPitch ( sonicStream  stream)

◆ sonicGetNumChannels()

int sonicGetNumChannels ( sonicStream  stream)

◆ sonicGetPitch()

float sonicGetPitch ( sonicStream  stream)

◆ sonicGetQuality()

int sonicGetQuality ( sonicStream  stream)

◆ sonicGetRate()

float sonicGetRate ( sonicStream  stream)

◆ sonicGetSampleRate()

int sonicGetSampleRate ( sonicStream  stream)

◆ sonicGetSpeed()

float sonicGetSpeed ( sonicStream  stream)

◆ sonicGetVolume()

float sonicGetVolume ( sonicStream  stream)

◆ sonicReadFloatFromStream()

int sonicReadFloatFromStream ( sonicStream  stream,
float *  samples,
int  maxSamples 
)

◆ sonicReadShortFromStream()

int sonicReadShortFromStream ( sonicStream  stream,
short *  samples,
int  maxSamples 
)

◆ sonicReadUnsignedCharFromStream()

int sonicReadUnsignedCharFromStream ( sonicStream  stream,
unsigned char *  samples,
int  maxSamples 
)

◆ sonicSamplesAvailable()

int sonicSamplesAvailable ( sonicStream  stream)

◆ sonicSetChordPitch()

void sonicSetChordPitch ( sonicStream  stream,
int  useChordPitch 
)

◆ sonicSetNumChannels()

int sonicSetNumChannels ( sonicStream  stream,
int  numChannels 
)

◆ sonicSetPitch()

void sonicSetPitch ( sonicStream  stream,
float  pitch 
)

◆ sonicSetQuality()

void sonicSetQuality ( sonicStream  stream,
int  quality 
)

◆ sonicSetRate()

void sonicSetRate ( sonicStream  stream,
float  rate 
)

◆ sonicSetSampleRate()

int sonicSetSampleRate ( sonicStream  stream,
int  sampleRate 
)

◆ sonicSetSpeed()

void sonicSetSpeed ( sonicStream  stream,
float  speed 
)

◆ sonicSetVolume()

void sonicSetVolume ( sonicStream  stream,
float  volume 
)

◆ sonicWriteFloatToStream()

int sonicWriteFloatToStream ( sonicStream  stream,
float *  samples,
int  numSamples 
)

◆ sonicWriteShortToStream()

int sonicWriteShortToStream ( sonicStream  stream,
short *  samples,
int  numSamples 
)

◆ sonicWriteUnsignedCharToStream()

int sonicWriteUnsignedCharToStream ( sonicStream  stream,
unsigned char *  samples,
int  numSamples 
)

◆ vPortFree()

void vPortFree ( void *  pv)

变量说明

◆ sincTable

short sincTable[601]
static