diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2f9e55b0..953983807 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -139,7 +139,7 @@ set ( libfluidsynth_SOURCES rvoice/fluid_lfo.h rvoice/fluid_rvoice.h rvoice/fluid_rvoice.c - rvoice/fluid_rvoice_dsp.c + rvoice/fluid_rvoice_dsp.cpp rvoice/fluid_rvoice_event.h rvoice/fluid_rvoice_event.c rvoice/fluid_rvoice_mixer.h diff --git a/src/gentables/make_tables.c b/src/gentables/make_tables.c index 3aee11b61..2fd0b280f 100644 --- a/src/gentables/make_tables.c +++ b/src/gentables/make_tables.c @@ -61,7 +61,22 @@ static void open_table(FILE**fp, const char* dir, const char* file) } /* Emit warning header */ - fprintf(*fp, "/* THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. */\n\n"); + fprintf(*fp, + "/* THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT. */\n\n" + "#ifdef __cplusplus\n" + "extern \"C\" {\n" + "#endif\n\n" + ); +} + +static void close_table(FILE**fp) +{ + fprintf(*fp, + "#ifdef __cplusplus\n" + "}\n" + "#endif\n" + ); + fclose(*fp); } int main (int argc, char *argv[]) @@ -74,11 +89,11 @@ int main (int argc, char *argv[]) open_table(&fp, argv[1], "fluid_conv_tables.inc.h"); gen_conv_table(fp); - fclose(fp); + close_table(&fp); open_table(&fp, argv[1], "fluid_rvoice_dsp_tables.inc.h"); gen_rvoice_table_dsp(fp); - fclose(fp); + close_table(&fp); return 0; } diff --git a/src/rvoice/fluid_adsr_env.h b/src/rvoice/fluid_adsr_env.h index 5e99c6bf3..1267cd4f0 100644 --- a/src/rvoice/fluid_adsr_env.h +++ b/src/rvoice/fluid_adsr_env.h @@ -24,6 +24,9 @@ #include "fluidsynth_priv.h" #include "fluid_sys.h" +#ifdef __cplusplus +extern "C" { +#endif /* * envelope data */ @@ -39,7 +42,7 @@ struct _fluid_env_data_t /* Indices for envelope tables */ enum fluid_voice_envelope_index { - FLUID_VOICE_ENVDELAY, + FLUID_VOICE_ENVDELAY=0, FLUID_VOICE_ENVATTACK, FLUID_VOICE_ENVHOLD, FLUID_VOICE_ENVDECAY, @@ -56,9 +59,9 @@ typedef struct _fluid_adsr_env_t fluid_adsr_env_t; struct _fluid_adsr_env_t { fluid_env_data_t data[FLUID_VOICE_ENVLAST]; + unsigned int section; // type fluid_adsr_env_section_t, but declare it unsigned to make C++ happy unsigned int count; fluid_real_t val; /* the current value of the envelope */ - fluid_adsr_env_section_t section; }; /* For performance, all functions are inlined */ @@ -136,14 +139,14 @@ fluid_adsr_env_set_val(fluid_adsr_env_t *env, fluid_real_t val) static FLUID_INLINE fluid_adsr_env_section_t fluid_adsr_env_get_section(fluid_adsr_env_t *env) { - return env->section; + return (fluid_adsr_env_section_t)env->section; } static FLUID_INLINE void fluid_adsr_env_set_section(fluid_adsr_env_t *env, fluid_adsr_env_section_t section) { - env->section = section; + env->section = (unsigned int)section; env->count = 0; } @@ -163,5 +166,8 @@ fluid_adsr_env_get_max_val(fluid_adsr_env_t *env) } } +#ifdef __cplusplus +} +#endif #endif diff --git a/src/rvoice/fluid_iir_filter.h b/src/rvoice/fluid_iir_filter.h index 73e87754c..f75533e9f 100644 --- a/src/rvoice/fluid_iir_filter.h +++ b/src/rvoice/fluid_iir_filter.h @@ -31,6 +31,9 @@ #define LOG_FILTER(...) #endif +#ifdef __cplusplus +extern "C" { +#endif typedef struct _fluid_iir_filter_t fluid_iir_filter_t; DECLARE_FLUID_RVOICE_FUNCTION(fluid_iir_filter_init); @@ -78,5 +81,8 @@ struct _fluid_iir_filter_t #endif }; +#ifdef __cplusplus +} +#endif #endif diff --git a/src/rvoice/fluid_lfo.h b/src/rvoice/fluid_lfo.h index b9a9ca6ea..7da4a3676 100644 --- a/src/rvoice/fluid_lfo.h +++ b/src/rvoice/fluid_lfo.h @@ -23,6 +23,9 @@ #include "fluid_sys.h" +#ifdef __cplusplus +extern "C" { +#endif typedef struct _fluid_lfo_t fluid_lfo_t; struct _fluid_lfo_t @@ -71,5 +74,8 @@ fluid_lfo_calc(fluid_lfo_t *lfo, unsigned int cur_delay) } +#ifdef __cplusplus +} +#endif #endif diff --git a/src/rvoice/fluid_phase.h b/src/rvoice/fluid_phase.h index 44df6b249..abd5d7bbd 100644 --- a/src/rvoice/fluid_phase.h +++ b/src/rvoice/fluid_phase.h @@ -22,6 +22,9 @@ #ifndef _FLUID_PHASE_H #define _FLUID_PHASE_H +#ifdef __cplusplus +extern "C" { +#endif /* * phase */ @@ -110,4 +113,7 @@ typedef uint64_t fluid_phase_t; * Creates the expression a.index++. */ #define fluid_phase_index_plusplus(a) (((a) += 0x100000000LL) +#ifdef __cplusplus +} +#endif #endif /* _FLUID_PHASE_H */ diff --git a/src/rvoice/fluid_rvoice.h b/src/rvoice/fluid_rvoice.h index 9c8788dec..b51603d1a 100644 --- a/src/rvoice/fluid_rvoice.h +++ b/src/rvoice/fluid_rvoice.h @@ -29,6 +29,9 @@ #include "fluid_phase.h" #include "fluid_sfont.h" +#ifdef __cplusplus +extern "C" { +#endif typedef struct _fluid_rvoice_envlfo_t fluid_rvoice_envlfo_t; typedef struct _fluid_rvoice_dsp_t fluid_rvoice_dsp_t; typedef struct _fluid_rvoice_buffers_t fluid_rvoice_buffers_t; @@ -228,4 +231,7 @@ fluid_rvoice_get_sample(const short int *dsp_msb, const char *dsp_lsb, unsigned return (int32_t)((msb << 8) | lsb); } +#ifdef __cplusplus +} +#endif #endif diff --git a/src/rvoice/fluid_rvoice_dsp.c b/src/rvoice/fluid_rvoice_dsp.cpp similarity index 100% rename from src/rvoice/fluid_rvoice_dsp.c rename to src/rvoice/fluid_rvoice_dsp.cpp diff --git a/src/sfloader/fluid_sfont.h b/src/sfloader/fluid_sfont.h index 9a42c02eb..855adee1b 100644 --- a/src/sfloader/fluid_sfont.h +++ b/src/sfloader/fluid_sfont.h @@ -24,6 +24,9 @@ #include "fluidsynth.h" +#ifdef __cplusplus +extern "C" { +#endif int fluid_sample_validate(fluid_sample_t *sample, unsigned int max_end); int fluid_sample_sanitize_loop(fluid_sample_t *sample, unsigned int max_end); @@ -186,4 +189,7 @@ struct _fluid_sample_t }; +#ifdef __cplusplus +} +#endif #endif /* _PRIV_FLUID_SFONT_H */ diff --git a/src/utils/fluid_conv.h b/src/utils/fluid_conv.h index bd1edb94f..801afc4c3 100644 --- a/src/utils/fluid_conv.h +++ b/src/utils/fluid_conv.h @@ -24,6 +24,9 @@ #include "fluidsynth_priv.h" #include "utils/fluid_conv_tables.h" +#ifdef __cplusplus +extern "C" { +#endif fluid_real_t fluid_ct2hz_real(fluid_real_t cents); fluid_real_t fluid_ct2hz(fluid_real_t cents); fluid_real_t fluid_cb2amp(fluid_real_t cb); @@ -39,4 +42,7 @@ fluid_real_t fluid_balance(fluid_real_t balance, int left); fluid_real_t fluid_concave(fluid_real_t val); fluid_real_t fluid_convex(fluid_real_t val); +#ifdef __cplusplus +} +#endif #endif /* _FLUID_CONV_H */ diff --git a/src/utils/fluid_sys.h b/src/utils/fluid_sys.h index a756fc073..f491254dd 100644 --- a/src/utils/fluid_sys.h +++ b/src/utils/fluid_sys.h @@ -177,6 +177,10 @@ typedef gintptr intptr_t; #include +#ifdef __cplusplus +extern "C" { +#endif + /** * Macro used for safely accessing a message from a GError and using a default * message if it is NULL. @@ -786,4 +790,7 @@ static FLUID_INLINE void *fluid_align_ptr(const void *ptr, unsigned int alignmen #define FLUID_DEFAULT_ALIGNMENT (64U) +#ifdef __cplusplus +} +#endif #endif /* _FLUID_SYS_H */