diff --git a/src/biquad.h b/src/biquad.h index 7a7195c..88d47e4 100644 --- a/src/biquad.h +++ b/src/biquad.h @@ -8,6 +8,7 @@ #ifndef SNDFILTER_BIQUAD__H #define SNDFILTER_BIQUAD__H +#include "sf_common.h" #include "snd.h" // biquad filtering is a technique used to perform a variety of sound filters @@ -41,6 +42,8 @@ typedef struct { sf_sample_st yn2; } sf_biquad_state_st; +SF_API_BEGIN + // these functions will initialize an sf_biquad_state_st structure based on the desired filter void sf_lowpass (sf_biquad_state_st *state, int rate, float cutoff, float resonance); void sf_highpass (sf_biquad_state_st *state, int rate, float cutoff, float resonance); @@ -56,4 +59,6 @@ void sf_highshelf(sf_biquad_state_st *state, int rate, float freq, float Q, floa void sf_biquad_process(sf_biquad_state_st *state, int size, sf_sample_st *input, sf_sample_st *output); +SF_API_END + #endif // SNDFILTER_BIQUAD__H diff --git a/src/compressor.h b/src/compressor.h index 13d7ef3..81f8ec7 100644 --- a/src/compressor.h +++ b/src/compressor.h @@ -8,6 +8,7 @@ #ifndef SNDFILTER_COMPRESSOR__H #define SNDFILTER_COMPRESSOR__H +#include "sf_common.h" #include "snd.h" // dynamic range compression is a complex topic with many different algorithms @@ -75,6 +76,8 @@ typedef struct { sf_sample_st delaybuf[SF_COMPRESSOR_MAXDELAY]; // predelay buffer } sf_compressor_state_st; +SF_API_BEGIN + // populate a compressor state with all default values void sf_defaultcomp(sf_compressor_state_st *state, int rate); @@ -108,4 +111,6 @@ void sf_advancecomp(sf_compressor_state_st *state, void sf_compressor_process(sf_compressor_state_st *state, int size, sf_sample_st *input, sf_sample_st *output); +SF_API_END + #endif // SNDFILTER_COMPRESSOR__H diff --git a/src/reverb.h b/src/reverb.h index 8b9e778..3fbf287 100644 --- a/src/reverb.h +++ b/src/reverb.h @@ -8,8 +8,11 @@ #ifndef SNDFILTER_REVERB__H #define SNDFILTER_REVERB__H +#include "sf_common.h" #include "snd.h" +SF_API_BEGIN + // this API works by first initializing an sf_reverb_state_st structure, then using it to process a // sample in chunks // @@ -286,4 +289,6 @@ void sf_advancereverb(sf_reverb_state_st *rv, void sf_reverb_process(sf_reverb_state_st *state, int size, sf_sample_st *input, sf_sample_st *output); +SF_API_END + #endif // SNDFILTER_REVERB__H diff --git a/src/sf_common.h b/src/sf_common.h new file mode 100644 index 0000000..ff26d4e --- /dev/null +++ b/src/sf_common.h @@ -0,0 +1,20 @@ +// (c) Copyright 2021, Kazuki Tanaka (@tk-aria) +// MIT License +// Project Home: https://github.com/velipso/sndfilter + +#ifndef SNDFILTER_COMMON__H +#define SNDFILTER_COMMON__H + +#ifdef __cplusplus + +#define SF_API_BEGIN extern "C" { +#define SF_API_END } + +#else + +#define SF_API_BEGIN +#define SF_API_END + +#endif + +#endif // SNDFILTER_COMMON__H diff --git a/src/snd.h b/src/snd.h index da86650..45f927f 100644 --- a/src/snd.h +++ b/src/snd.h @@ -8,6 +8,7 @@ #define SNDFILTER_SND__H #include +#include "sf_common.h" typedef struct { float L; // left channel sample @@ -20,7 +21,11 @@ typedef struct { int rate; // samples per second } sf_snd_st, *sf_snd; +SF_API_BEGIN + sf_snd sf_snd_new(int size, int rate, bool clear); void sf_snd_free(sf_snd snd); +SF_API_END + #endif // SNDFILTER_SND__H diff --git a/src/wav.h b/src/wav.h index 815cb08..5694b93 100644 --- a/src/wav.h +++ b/src/wav.h @@ -9,9 +9,14 @@ #ifndef SNDFILTER_WAV__H #define SNDFILTER_WAV__H +#include "sf_common.h" #include "snd.h" +SF_API_BEGIN + sf_snd sf_wavload(const char *file); bool sf_wavsave(sf_snd snd, const char *file); +SF_API_END + #endif // SNDFILTER_WAV__H