mirror of
https://github.com/cookiengineer/audacity
synced 2026-04-24 23:13:42 +02:00
SBSMS library/effect changes. Apparently resolves bug #170. Incorporated optimizations with minor quality changes. Returned optimization flags to build (introduced in a patch). The audacity SBSMS branch is now a trimmed down version without associated programs. Includes (untested) changes to the windows .vcproj.
This commit is contained in:
@@ -9,76 +9,72 @@ namespace _sbsms_ {
|
||||
typedef float real;
|
||||
typedef real interleaved[2];
|
||||
typedef interleaved audio;
|
||||
}
|
||||
|
||||
#define SBSMS_WINDOW SBSMS_HANN
|
||||
extern _sbsms_::real SBSMS_P1;
|
||||
extern _sbsms_::real SBSMS_Q1;
|
||||
#define SBSMS_S 4
|
||||
#define SBSMS_MAX_BANDS 7
|
||||
#define SBSMS_QUALITIES 3
|
||||
#define SBSMS_MAX_STRETCH 12
|
||||
#define SBSMS_MIN_STRETCH 1.0/12.0
|
||||
extern int SBSMS_BANDS[SBSMS_QUALITIES];
|
||||
extern int SBSMS_M_MAX[SBSMS_QUALITIES];
|
||||
extern int SBSMS_FRAME_SIZE[SBSMS_QUALITIES];
|
||||
extern int SBSMS_MAX_FRAME_SIZE[SBSMS_QUALITIES];
|
||||
extern int SBSMS_H[SBSMS_QUALITIES][5];
|
||||
extern _sbsms_::real SBSMS_PAD[SBSMS_QUALITIES][SBSMS_MAX_BANDS];
|
||||
extern int SBSMS_RES[SBSMS_QUALITIES][SBSMS_MAX_BANDS];
|
||||
extern int SBSMS_N[SBSMS_QUALITIES][SBSMS_MAX_BANDS];
|
||||
struct sbsms_quality {
|
||||
long inframesize;
|
||||
long maxoutframesize;
|
||||
real minrate;
|
||||
real maxrate;
|
||||
int bands;
|
||||
int M_MAX;
|
||||
int H[5];
|
||||
int N[8];
|
||||
int S[8];
|
||||
int res[8];
|
||||
real pad[8];
|
||||
real P[8];
|
||||
real Q[8];
|
||||
};
|
||||
|
||||
extern const sbsms_quality sbsms_quality_standard;
|
||||
extern const sbsms_quality sbsms_quality_fast;
|
||||
|
||||
struct sbsms_resample_frame {
|
||||
_sbsms_::real ratio0;
|
||||
_sbsms_::real ratio1;
|
||||
_sbsms_::audio *in;
|
||||
real ratio0;
|
||||
real ratio1;
|
||||
audio *in;
|
||||
long size;
|
||||
};
|
||||
|
||||
typedef long (*sbsms_cb)(_sbsms_::audio *buf, long n, void *data);
|
||||
typedef _sbsms_::real (*sbsms_stretch_cb)(long nProcessed, void *data);
|
||||
typedef _sbsms_::real (*sbsms_ratio_cb)(long nProcessed, void *data);
|
||||
typedef long (*sbsms_cb)(audio *buf, long n, void *data);
|
||||
typedef real (*sbsms_rate_cb)(long nProcessed, void *data);
|
||||
typedef real (*sbsms_pitch_cb)(long nProcessed, void *data);
|
||||
typedef long (*sbsms_resample_cb)(void *cb_data, sbsms_resample_frame *frame);
|
||||
|
||||
namespace _sbsms_ {
|
||||
class subband;
|
||||
class TrackAllocator;
|
||||
class PeakAllocator;
|
||||
}
|
||||
class subband;
|
||||
class TrackAllocator;
|
||||
class PeakAllocator;
|
||||
|
||||
struct sbsms {
|
||||
FILE *fp;
|
||||
sbsms_cb getSamplesCB;
|
||||
sbsms_stretch_cb getStretchCB;
|
||||
sbsms_ratio_cb getRatioCB;
|
||||
_sbsms_::subband *top;
|
||||
_sbsms_::TrackAllocator *ta;
|
||||
_sbsms_::PeakAllocator *pa;
|
||||
sbsms_rate_cb getRateCB;
|
||||
sbsms_pitch_cb getPitchCB;
|
||||
subband *top;
|
||||
TrackAllocator *ta;
|
||||
PeakAllocator *pa;
|
||||
long n_prepad, n_postpad, n_prespent, n_processed;
|
||||
bool bWritingComplete;
|
||||
int quality, channels;
|
||||
long bufsize;
|
||||
long chunksize;
|
||||
_sbsms_::audio *ina;
|
||||
sbsms_quality quality;
|
||||
int channels;
|
||||
audio *ina;
|
||||
void *threadData;
|
||||
};
|
||||
|
||||
namespace _sbsms_ {
|
||||
|
||||
class SampleBufBase {
|
||||
public:
|
||||
SampleBufBase() {};
|
||||
virtual ~SampleBufBase() {};
|
||||
virtual long read(_sbsms_::audio *buf, long n)=0;
|
||||
virtual long read(audio *buf, long n)=0;
|
||||
virtual void advance(long n)=0;
|
||||
virtual long n_readable()=0;
|
||||
};
|
||||
|
||||
|
||||
class grain;
|
||||
|
||||
class SampleBuf {
|
||||
public:
|
||||
SampleBuf() {};
|
||||
//SampleBuf() {};
|
||||
SampleBuf(int N);
|
||||
SampleBuf(int N, long delay);
|
||||
void init(int N, long delay);
|
||||
@@ -88,7 +84,7 @@ class SampleBuf {
|
||||
void grow(long pos);
|
||||
long write(audio *buf, long n);
|
||||
long write(grain* g, int h);
|
||||
virtual long read(_sbsms_::audio *buf, long n);
|
||||
virtual long read(audio *buf, long n);
|
||||
virtual void advance(long n);
|
||||
virtual long n_readable();
|
||||
audio *getReadBuf();
|
||||
@@ -101,16 +97,12 @@ class SampleBuf {
|
||||
audio *buf;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
using namespace _sbsms_;
|
||||
class Resampler {
|
||||
public:
|
||||
Resampler(sbsms_resample_cb func, void *data);
|
||||
Resampler(SampleBuf *in, real ratio);
|
||||
Resampler(SampleBuf *in, real pitch);
|
||||
~Resampler();
|
||||
long read(_sbsms_::audio *audioOut, long frames);
|
||||
long read(audio *audioOut, long frames);
|
||||
void writingComplete();
|
||||
void reset();
|
||||
void init();
|
||||
@@ -120,11 +112,11 @@ class Resampler {
|
||||
sbsms_resample_frame frame;
|
||||
long startAbs;
|
||||
long midAbs;
|
||||
_sbsms_::real midAbsf;
|
||||
real midAbsf;
|
||||
long endAbs;
|
||||
long writePosAbs;
|
||||
bool bInput;
|
||||
_sbsms_::SampleBuf *out;
|
||||
SampleBuf *out;
|
||||
sbsms_resample_cb cb;
|
||||
void *data;
|
||||
bool bPull;
|
||||
@@ -134,22 +126,13 @@ class Resampler {
|
||||
bool bWritingComplete;
|
||||
};
|
||||
|
||||
struct pitcher {
|
||||
void *sbsmsData;
|
||||
sbsms *sbsmser;
|
||||
_sbsms_::real ratio;
|
||||
Resampler *postResampler;
|
||||
_sbsms_::audio *buf;
|
||||
long bufsize;
|
||||
};
|
||||
|
||||
void sbsms_init(int n);
|
||||
void sbsms_reset(sbsms *sbsmser);
|
||||
void sbsms_seek(sbsms *sbsmser, long framePos, long samplePos);
|
||||
sbsms* sbsms_create(sbsms_cb getSamplesCB, sbsms_stretch_cb getStretchCB, sbsms_ratio_cb getRatioCB, int channels, int quality, bool bPreAnalyze, bool bSynthesize);
|
||||
sbsms* sbsms_create(FILE *fp, sbsms_stretch_cb getStretchCB, sbsms_ratio_cb getRatioCB);
|
||||
sbsms* sbsms_create(sbsms_cb getSamplesCB, sbsms_rate_cb getRateCB, sbsms_pitch_cb getPitchCB, int channels, sbsms_quality *quality, bool bPreAnalyze, bool bSynthesize);
|
||||
sbsms* sbsms_create(FILE *fp, sbsms_rate_cb getRateCB, sbsms_pitch_cb getPitchCB);
|
||||
void sbsms_destroy(sbsms* sbsmser);
|
||||
long sbsms_read_frame(_sbsms_::audio *out, void *data, sbsms *sbsmer, _sbsms_::real *ratio0, _sbsms_::real *ratio1);
|
||||
long sbsms_read_frame(audio *out, void *data, sbsms *sbsmer, real *pitch0, real *pitch1);
|
||||
long sbsms_write_frame(FILE *fp, void *data, sbsms *sbsmser);
|
||||
long sbsms_samples_processed(sbsms *sbsmser);
|
||||
long sbsms_pre_analyze(sbsms_cb getSamplesCB, void *data, sbsms *sbsmser);
|
||||
@@ -167,27 +150,23 @@ FILE *sbsms_open_read(const char *fileName);
|
||||
long sbsms_get_samples_to_process(FILE *fp);
|
||||
long sbsms_get_frames_to_process(FILE *fp);
|
||||
long sbsms_get_channels(FILE *fp);
|
||||
long sbsms_get_quality(FILE *fp);
|
||||
void sbsms_get_quality(FILE *fp, sbsms_quality *quality);
|
||||
void sbsms_seek_start_data(FILE *fp);
|
||||
|
||||
|
||||
pitcher *pitch_create(sbsms *sbsmser, void *sbsmsData, _sbsms_::real ratio);
|
||||
void pitch_reset(pitcher *pitch);
|
||||
void pitch_destroy(pitcher *pitch);
|
||||
long pitch_process(_sbsms_::audio *out, long n, pitcher *pitch);
|
||||
long pitch_get_samples_queued(pitcher *pitch);
|
||||
|
||||
struct sbsmsInfo {
|
||||
float stretch0, stretch1;
|
||||
float ratio0, ratio1;
|
||||
real rate0, rate1;
|
||||
real pitch0, pitch1;
|
||||
long samplesToProcess;
|
||||
long samplesToGenerate;
|
||||
Resampler *rs;
|
||||
};
|
||||
|
||||
real stretchCBLinear(long nProcessed, void *userData);
|
||||
real stretchCBConstant(long nProcessed, void *userData);
|
||||
real ratioCBLinear(long nProcessed, void *userData);
|
||||
real ratioCBConstant(long nProcessed, void *userData);
|
||||
long getLinearOutputSamples(sbsmsInfo *si);
|
||||
real rateCBLinear(long nProcessed, void *userData);
|
||||
real rateCBConstant(long nProcessed, void *userData);
|
||||
real pitchCBLinear(long nProcessed, void *userData);
|
||||
real pitchCBConstant(long nProcessed, void *userData);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user