Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wtq2255 committed Jan 23, 2024
2 parents 09ec368 + 4ad4df4 commit eb12445
Show file tree
Hide file tree
Showing 26 changed files with 945 additions and 87 deletions.
31 changes: 31 additions & 0 deletions include/classic/nmf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@


#ifndef NMF_H
#define NMF_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>

/***
V=W*H
k k<n&&k<m,k*(n+m)<n*m
maxIter 300
type 0 0 KL 1 IS 2 Euc
thresh 1e-3
norm 0 max 1 sum/p-1 2 p-2
****/
void nmf(float *mDataArr,int nLength,int mLength,int k,
float *wArr,float *hArr,
int *maxIter,int *type,float *thresh,
int *norm);


#ifdef __cplusplus
}
#endif

#endif
29 changes: 29 additions & 0 deletions include/classic/viterbi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@


#ifndef VITERBI_H
#define VITERBI_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>

/***
λ=(π,A,B) sLength*1,sLength*sLength,sLength*nLength
oArr B nLength index
mProbArr tLength*sLength
sArr A sLength index
****/
float viterbi(float *piArr,float *mAArr,float *mBArr,
int sLength,int nLength,
int *oArr,int tLength,int *isLog,
int *sArr,float *mProbArr,int *mIndexArr);


#ifdef __cplusplus
}
#endif

#endif
44 changes: 44 additions & 0 deletions include/dsp/conv_algorithm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@


#ifndef CONV_ALGORITHM_H
#define CONV_ALGORITHM_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>
#include "../flux_base.h"

// convolution 相关
typedef enum{
ConvMode_Full=0,
ConvMode_Same,
ConvMode_Valid,

} ConvModeType;

typedef enum{
ConvMethod_Auto=0,
ConvMethod_Direct,
ConvMethod_FFT,

} ConvMethodType;

typedef struct OpaqueConv *ConvObj;

int convObj_new(ConvObj *convObj);

int convObj_conv(ConvObj convObj,float *vArr1,int length1,float *vArr2,int length2,
ConvModeType *mode,ConvMethodType *method,
float *vArr3);

void convObj_free(ConvObj convObj);


#ifdef __cplusplus
}
#endif

#endif
27 changes: 27 additions & 0 deletions include/dsp/hilbert_algorithm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@


#ifndef HILBERT_ALGORITHM_H
#define HILBERT_ALGORITHM_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>
#include "../flux_base.h"

typedef struct OpaqueHilbert *HilbertObj;

int hilbertObj_new(HilbertObj *hilbertObj,int radix2Exp);

void hilbertObj_hilbert(HilbertObj hilbertObj,float *dataArr,
float *realArr3,float *imageArr3);

void hilbertObj_free(HilbertObj hilbertObj);

#ifdef __cplusplus
}
#endif

#endif
26 changes: 26 additions & 0 deletions include/dsp/phase_vocoder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@


#ifndef PHASE_VOCODER_H
#define PHASE_VOCODER_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>

/***
mDataArr1 stft time*fftLength
rate 0.5~2
slideLength fftLength/4
****/
void phase_vocoder(float *mRealArr1,float *mImageArr1,int timeLength,int fftLength,int slideLength,float rate,
float *mRealArr2,float *mImageArr2);


#ifdef __cplusplus
}
#endif

#endif
9 changes: 5 additions & 4 deletions include/dsp/resample_algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ typedef struct OpaqueResample *ResampleObj;
int resampleObj_new(ResampleObj *resampleObj,ResampleQualityType *qualType,int *isScale,int *isContinue);
/***
sinc right
zeroNum 64 一般16/32/64
nbit 9 一般5~9 每个zero-cross 1<<nbit samples
zeroNum 64, 16/32/64
nbit 9, 5~9 echo zero-cross 1<<nbit samples
winType hann
value kaiser/gauss 5/2.5
rollOff 0.945 一般0.8~0.95
rollOff 0.945, 0.8~0.95
****/
int resampleObj_newWithWindow(ResampleObj *resampleObj,
int *zeroNum,int *nbit,
Expand All @@ -46,8 +46,9 @@ int resampleObj_newWithWindow(ResampleObj *resampleObj,

int resampleObj_calDataLength(ResampleObj resampleObj,int dataLength);

// 默认32000/16000
// 32000/16000
void resampleObj_setSamplate(ResampleObj resampleObj,int sourceRate,int targetRate);
void resampleObj_setSamplateRatio(ResampleObj resampleObj,float ratio);
void resampleObj_enableContinue(ResampleObj resampleObj,int flag);

int resampleObj_resample(ResampleObj resampleObj,float *dataArr1,int dataLength1,float *dataArr2);
Expand Down
37 changes: 37 additions & 0 deletions include/harmonic_algorithm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@


#ifndef HARMONI_ALGORITHM_H
#define HARMONI_ALGORITHM_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>
#include "flux_base.h"

typedef struct OpaqueHarmonic *HarmonicObj;

/***
samplate 32000
radix2Exp 12
windowType hamm
****/
int harmonicObj_new(HarmonicObj *harmonicObj,
int *samplate,
int *radix2Exp,WindowType *windowType,int *slideLength);

int harmonicObj_calTimeLength(HarmonicObj harmonicObj,int dataLength);

void harmonicObj_exec(HarmonicObj harmonicObj,float *dataArr,int dataLength);

void harmonicObj_harmonicCount(HarmonicObj harmonicObj,float low,float high,int *countArr);

void harmonicObj_free(HarmonicObj harmonicObj);

#ifdef __cplusplus
}
#endif

#endif
43 changes: 0 additions & 43 deletions include/mir/_pitch_stft.h

This file was deleted.

2 changes: 1 addition & 1 deletion include/mir/_pitch_yin.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int pitchYINObj_new(PitchYINObj *pitchYINObj,
int *radix2Exp,int *slideLength,int *autoLength,
int *isContinue);

// default 0.1 thresh>0&&thresh<1
// default 0.6 thresh>0&&thresh<1
void pitchYINObj_setThresh(PitchYINObj pitchYINObj,float thresh);
int pitchYINObj_calTimeLength(PitchYINObj pitchYINObj,int dataLength);

Expand Down
33 changes: 33 additions & 0 deletions include/mir/pitchShift_algorithm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@


#ifndef PITCHSHIFT_ALGORITHM_H
#define PITCHSHIFT_ALGORITHM_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>

#include "../flux_base.h"

typedef struct OpaquePitchShift *PitchShiftObj;

/***
radix2Exp 12
WindowType hann
slideLength (1<<radix2Exp)/4
****/
int pitchShiftObj_new(PitchShiftObj *pitchShiftObj,int *radix2Exp,int *slideLength,WindowType *windowType);

// nSemitone -12~12
void pitchShiftObj_pitchShift(PitchShiftObj pitchShiftObj,int samplate,int nSemitone,float *dataArr1,int dataLength1,float *dataArr2);

void pitchShiftObj__free(PitchShiftObj pitchShiftObj);

#ifdef __cplusplus
}
#endif

#endif
33 changes: 33 additions & 0 deletions include/mir/timeStretch_algorithm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@


#ifndef TIMESTRETCH_ALGORITHM_H
#define TIMESTRETCH_ALGORITHM_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>

#include "../flux_base.h"

typedef struct OpaqueTimeStretch *TimeStretchObj;

/***
radix2Exp 12
WindowType hann
slideLength (1<<radix2Exp)/4
****/
int timeStretchObj_new(TimeStretchObj *timeStretchObj,int *radix2Exp,int *slideLength,WindowType *windowType);

int timeStretchObj_calDataCapacity(TimeStretchObj timeStretchObj,float rate,int dataLength);
int timeStretchObj_timeStretch(TimeStretchObj timeStretchObj,float rate,float *dataArr1,int dataLength1,float *dataArr2);

void timeStretchObj_free(TimeStretchObj timeStretchObj);

#ifdef __cplusplus
}
#endif

#endif
Loading

0 comments on commit eb12445

Please sign in to comment.