From 6d6c64c1b019fe5d2b2bd41b50d2fbdfb96fbe7b Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 5 Feb 2014 23:47:16 -0800 Subject: [PATCH] make brace style consistent --- README.md | 3 +-- bench.c | 9 ++++++--- crap_delay_test.h | 28 ++++++++++++++++------------ crap_eq.h | 30 ++++++++++++++++++------------ crap_eq_const.h | 25 ++++++++++++++----------- crap_noise.h | 27 ++++++++++++++------------- crap_tube.h | 25 +++++++++++++++---------- crap_util_def.h | 15 ++++++++++----- design.c | 6 ++++-- template-ladspa.c | 24 ++++++++++++++++-------- template-vst.cpp | 26 ++++++++++++++++++-------- 11 files changed, 132 insertions(+), 86 deletions(-) diff --git a/README.md b/README.md index bd32074..f726b49 100644 --- a/README.md +++ b/README.md @@ -55,10 +55,9 @@ remember to export `VST_SDK_DIR` to the path of your `vstsdk2.4/` ## TODO * rename plugins (fix capitalization consistency and such) -* make code style consistent * remove crap\_ prefixes? * move to subdirs? * reduce input/output buffers on biquads (shared) * ease up on the preprocessor ifs * polish parameter support - +* make code style consistent diff --git a/bench.c b/bench.c index bcc94ff..afd6c44 100644 --- a/bench.c +++ b/bench.c @@ -16,13 +16,15 @@ static float *audio_buffer; static int audio_count = 0; static void -cleanup() { +cleanup() +{ dlclose(plug); if (audio_count) free(audio_buffer); } static const LADSPA_Descriptor* -load_ladspa(char *path) { +load_ladspa(char *path) +{ plug = dlopen(path, RTLD_NOW); assert(plug); atexit(cleanup); @@ -37,7 +39,8 @@ load_ladspa(char *path) { } int -main(int argc, char **argv) { +main(int argc, char **argv) +{ assert(argc > 1); const LADSPA_Descriptor *d = load_ladspa(argv[1]); diff --git a/crap_delay_test.h b/crap_delay_test.h index 378b3df..4971172 100644 --- a/crap_delay_test.h +++ b/crap_delay_test.h @@ -84,7 +84,8 @@ static void process(personal *data, float *in_L, float *in_R, float *out_L, float *out_R, - ulong count) { + ulong count) +{ for (ulong pos = 0; pos < count; pos++) { out_L[pos] = process_one(&data->c[0], in_L[pos]); out_R[pos] = process_one(&data->c[1], in_R[pos]); @@ -95,7 +96,8 @@ static void process_double(personal *data, double *in_L, double *in_R, double *out_L, double *out_R, - ulong count) { + ulong count) +{ for (ulong pos = 0; pos < count; pos++) { out_L[pos] = process_one(&data->c[0], in_L[pos]); out_R[pos] = process_one(&data->c[1], in_R[pos]); @@ -103,30 +105,32 @@ process_double(personal *data, } static void -construct(personal *data) { -} +construct(personal *data) +{} static void -destruct(personal *data) { -} +destruct(personal *data) +{} static void -resume(personal *data) { -} +resume(personal *data) +{} static void -pause(personal *data) { -} +pause(personal *data) +{} static void -adjust(personal *data, ulong fs) { +adjust(personal *data, ulong fs) +{ for (int k = 0; k < 2; k++) { channel *c = &data->c[k]; for (int i = 0; i < UP; i++) c->up[i] = 0; for (int i = 0; i < DOWN; i++) c->down[i] = 0; - c->filter = biquad_gen(FILT_PEAKING, 16630, 10, 1, fs*oversample); + c->filter = biquad_gen(FILT_PEAKING, + 16630, 10, 1, fs*oversample); biquad_init(&c->filter); } } diff --git a/crap_eq.h b/crap_eq.h index 8ca155d..02d57ee 100644 --- a/crap_eq.h +++ b/crap_eq.h @@ -30,7 +30,8 @@ static void process(personal *data, float *in_L, float *in_R, float *out_L, float *out_R, - unsigned long count) { + unsigned long count) +{ for (unsigned long pos = 0; pos < count; pos++) { out_L[pos] = process_one(data->filters[0], in_L[pos]); out_R[pos] = process_one(data->filters[1], in_R[pos]); @@ -41,7 +42,8 @@ static void process_double(personal *data, double *in_L, double *in_R, double *out_L, double *out_R, - unsigned long count) { + unsigned long count) +{ for (unsigned long pos = 0; pos < count; pos++) { out_L[pos] = process_one(data->filters[0], in_L[pos]); out_R[pos] = process_one(data->filters[1], in_R[pos]); @@ -49,7 +51,8 @@ process_double(personal *data, } static void -resume(personal *data) { +resume(personal *data) +{ biquad *filters = data->filters[0]; for (int i = 0; i < BANDS; i++) biquad_init(&filters[i]); @@ -57,11 +60,12 @@ resume(personal *data) { } static void -pause(personal *data) { -} +pause(personal *data) +{} static void -construct_params(param *params) { +construct_params(param *params) +{ for (int i = 0; i < BANDS; i++) { sprintf(params[0].name, "Band %i Frequency", i + 1); params[0].min = 20; @@ -89,15 +93,16 @@ construct_params(param *params) { } static void -construct(personal *data) { -} +construct(personal *data) +{} static void -destruct(personal *data) { -} +destruct(personal *data) +{} static void -adjust(personal *data, param *params, unsigned long fs) { +adjust(personal *data, param *params, unsigned long fs) +{ data->fs = fs; biquad *filters = data->filters[0]; for (int i = 0; i < BANDS; i++) { @@ -109,7 +114,8 @@ adjust(personal *data, param *params, unsigned long fs) { } static void -adjust_one(personal *data, param *params, unsigned int index) { +adjust_one(personal *data, param *params, unsigned int index) +{ float fs = data->fs; params += index/3*3; data->filters[0][index/3] = biquad_gen(FILT_PEAKING, diff --git a/crap_eq_const.h b/crap_eq_const.h index e379153..30e35a0 100644 --- a/crap_eq_const.h +++ b/crap_eq_const.h @@ -26,7 +26,8 @@ static void process(personal *data, float *in_L, float *in_R, float *out_L, float *out_R, - unsigned long count) { + unsigned long count) +{ for (unsigned long pos = 0; pos < count; pos++) { out_L[pos] = process_one(data->filters[0], in_L[pos]); out_R[pos] = process_one(data->filters[1], in_R[pos]); @@ -37,8 +38,8 @@ static void process_double(personal *data, double *in_L, double *in_R, double *out_L, double *out_R, - unsigned long count) { - // TODO: test which hosts use this + unsigned long count) +{ for (unsigned long pos = 0; pos < count; pos++) { out_L[pos] = process_one(data->filters[0], in_L[pos]); out_R[pos] = process_one(data->filters[1], in_R[pos]); @@ -46,15 +47,16 @@ process_double(personal *data, } static void -construct(personal *data) { -} +construct(personal *data) +{} static void -destruct(personal *data) { -} +destruct(personal *data) +{} static void -resume(personal *data) { +resume(personal *data) +{ biquad *filters = data->filters[0]; for (int i = 0; i < BANDS; i++) biquad_init(&filters[i]); @@ -62,11 +64,12 @@ resume(personal *data) { } static void -pause(personal *data) { -} +pause(personal *data) +{} static void -adjust(personal *data, unsigned long fs) { +adjust(personal *data, unsigned long fs) +{ biquad *filters = data->filters[0]; filters[0] = biquad_gen(FILT_PEAKING, 34.34, +4.6, 1.21, fs); filters[1] = biquad_gen(FILT_PEAKING, 85.74, -1.2, 1.31, fs); diff --git a/crap_noise.h b/crap_noise.h index f842dc1..1219613 100644 --- a/crap_noise.h +++ b/crap_noise.h @@ -14,7 +14,8 @@ static void process(personal *data, float *in_L, float *in_R, float *out_L, float *out_R, - unsigned long count) { + unsigned long count) +{ // TODO: separate and preserve mirand for each channel for (unsigned long pos = 0; pos < count; pos++) out_L[pos] = whitenoise(); @@ -26,7 +27,8 @@ static void process_double(personal *data, double *in_L, double *in_R, double *out_L, double *out_R, - unsigned long count) { + unsigned long count) +{ for (unsigned long pos = 0; pos < count; pos++) out_L[pos] = whitenoise(); for (unsigned long pos = 0; pos < count; pos++) @@ -34,22 +36,21 @@ process_double(personal *data, } static void -construct(personal *data) { -} +construct(personal *data) +{} static void -destruct(personal *data) { -} +destruct(personal *data) +{} static void -resume(personal *data) { -} +resume(personal *data) +{} static void -pause(personal *data) { -} +pause(personal *data) +{} static void -adjust(personal *data, unsigned long fs) { -} - +adjust(personal *data, unsigned long fs) +{} diff --git a/crap_tube.h b/crap_tube.h index fe8369b..67ae99e 100644 --- a/crap_tube.h +++ b/crap_tube.h @@ -97,7 +97,8 @@ static void process(personal *data, float *in_L, float *in_R, float *out_L, float *out_R, - unsigned long count) { + unsigned long count) +{ disable_denormals(); for (unsigned long pos = 0; pos < count; pos++) { out_L[pos] = process_one(data->history_L, in_L[pos]); @@ -109,7 +110,8 @@ static void process_double(personal *data, double *in_L, double *in_R, double *out_L, double *out_R, - unsigned long count) { + unsigned long count) +{ disable_denormals(); for (unsigned long pos = 0; pos < count; pos++) { out_L[pos] = process_one(data->history_L, in_L[pos]); @@ -118,24 +120,27 @@ process_double(personal *data, } static void -resume(personal *data) { +resume(personal *data) +{ memset(data->history_L, 0, HIST_SIZE*sizeof(double)); memset(data->history_R, 0, HIST_SIZE*sizeof(double)); } static void -pause(personal *data) { -} +pause(personal *data) +{} + static void -construct(personal *data) { +construct(personal *data) +{ resume(data); } static void -destruct(personal *data) { -} +destruct(personal *data) +{} static void -adjust(personal *data, unsigned long fs) { +adjust(personal *data, unsigned long fs) +{ resume(data); } - diff --git a/crap_util_def.h b/crap_util_def.h index 6e0326e..c7c5454 100644 --- a/crap_util_def.h +++ b/crap_util_def.h @@ -6,7 +6,8 @@ static unsigned int mirand = 1; static float -whitenoise() { +whitenoise() +{ union either { float f; unsigned int i; @@ -19,14 +20,16 @@ whitenoise() { /* used to resemble https://github.com/swh/ladspa/blob/master/util/biquad.h */ static void -biquad_init(biquad *bq) { +biquad_init(biquad *bq) +{ bq->x1 = bq->x2 = bq->y1 = bq->y2 = 0; } static biquad_interim design(double cw, double sw, double num0, double num1, double num2, - double den0, double den1, double den2) { + double den0, double den1, double den2) +{ return (biquad_interim) { .b0 = num0* (1 + cw) + num1*sw + num2* (1 - cw), .b1 = num0*-2*(1 + cw) + num2*2*(1 - cw), @@ -38,7 +41,8 @@ design(double cw, double sw, } static biquad -biquad_gen(filter_t type, double fc, double gain, double bw, double fs) { +biquad_gen(filter_t type, double fc, double gain, double bw, double fs) +{ double w0, cw, sw, A, As, Q; w0 = ANGULAR_LIM(fc, fs); cw = cos(w0); @@ -77,7 +81,8 @@ biquad_gen(filter_t type, double fc, double gain, double bw, double fs) { } static double -biquad_run(biquad *bq, double x) { +biquad_run(biquad *bq, double x) +{ double y; y = bq->b0*x + bq->b1*bq->x1 + bq->b2*bq->x2 diff --git a/design.c b/design.c index 1e89cd4..22f1d2c 100644 --- a/design.c +++ b/design.c @@ -6,13 +6,15 @@ #include "crap_util.h" void -usage() { +usage() +{ fputs("usage: design SAMPLERATE TYPE CENTERFREQ GAIN BANDWIDTH\n", stderr); exit(1); } int -main(int argc, char **argv) { +main(int argc, char **argv) +{ if (argc != 6) usage(); double tv[5]; for (int i = 1; i <= 5; i++) { diff --git a/template-ladspa.c b/template-ladspa.c index 760c217..3c0cc21 100644 --- a/template-ladspa.c +++ b/template-ladspa.c @@ -41,7 +41,8 @@ typedef struct { } plug_t; static void -plug_connect(LADSPA_Handle instance, unsigned long port, LADSPA_Data *data) { +plug_connect(LADSPA_Handle instance, unsigned long port, LADSPA_Data *data) +{ plug_t *plug = (plug_t *)instance; if (port == PLUG_INPUT_L) plug->input_L = data; @@ -58,19 +59,22 @@ plug_connect(LADSPA_Handle instance, unsigned long port, LADSPA_Data *data) { } static void -plug_resume(LADSPA_Handle instance) { +plug_resume(LADSPA_Handle instance) +{ plug_t *plug = (plug_t *)instance; resume(&plug->data); } static void -plug_pause(LADSPA_Handle instance) { +plug_pause(LADSPA_Handle instance) +{ plug_t *plug = (plug_t *)instance; pause(&plug->data); } static LADSPA_Handle -plug_construct(const LADSPA_Descriptor *descriptor, unsigned long fs) { +plug_construct(const LADSPA_Descriptor *descriptor, unsigned long fs) +{ plug_t *plug = (plug_t *) calloc(1, sizeof(plug_t)); construct(&plug->data); #if (PARAMETERS > 0) @@ -83,14 +87,16 @@ plug_construct(const LADSPA_Descriptor *descriptor, unsigned long fs) { } static void -plug_destruct(LADSPA_Handle instance) { +plug_destruct(LADSPA_Handle instance) +{ plug_t *plug = (plug_t *)instance; destruct(&plug->data); free(plug); } static void -plug_process(LADSPA_Handle instance, unsigned long count) { +plug_process(LADSPA_Handle instance, unsigned long count) +{ plug_t *plug = (plug_t *)instance; #if (PARAMETERS > 0) for (int i = 0; i < PARAMETERS; i++) { @@ -129,14 +135,16 @@ static const LADSPA_Descriptor plug_desc = { }; const LADSPA_Descriptor * -ladspa_descriptor(unsigned long index) { +ladspa_descriptor(unsigned long index) +{ if (index != 0) return NULL; return &plug_desc; } static void -plug_init() { +plug_init() +{ for (int i = 0; i < 4; i++) { p_names[i] = p_default_strings[i]; p_descs[i] = LADSPA_PORT_AUDIO; diff --git a/template-vst.cpp b/template-vst.cpp index eec7bc5..9c7d640 100644 --- a/template-vst.cpp +++ b/template-vst.cpp @@ -48,7 +48,8 @@ private: }; AudioEffect * -createEffectInstance(audioMasterCallback audioMaster) { +createEffectInstance(audioMasterCallback audioMaster) +{ return new plugin(audioMaster); } @@ -73,19 +74,23 @@ plugin::~plugin() } void -plugin::resume() { +plugin::resume() +{ ::resume(&data); AudioEffectX::resume(); } void -plugin::suspend() { +plugin::suspend() +{ AudioEffectX::suspend(); ::pause(&data); } void -plugin::processReplacing(float **inputs, float **outputs, VstInt32 count) { +plugin::processReplacing( + float **inputs, float **outputs, VstInt32 count) +{ ::process(&data, inputs[0], inputs[1], outputs[0], outputs[1], @@ -93,7 +98,9 @@ plugin::processReplacing(float **inputs, float **outputs, VstInt32 count) { } void -plugin::processDoubleReplacing(double **inputs, double **outputs, VstInt32 count) { +plugin::processDoubleReplacing( + double **inputs, double **outputs, VstInt32 count) +{ ::process_double(&data, inputs[0], inputs[1], outputs[0], outputs[1], @@ -101,12 +108,14 @@ plugin::processDoubleReplacing(double **inputs, double **outputs, VstInt32 count } bool -plugin::setProcessPrecision(VstInt32 precision) { +plugin::setProcessPrecision(VstInt32 precision) +{ return true; } void -plugin::setSampleRate(float fs) { +plugin::setSampleRate(float fs) +{ AudioEffectX::setSampleRate(fs); #if (PARAMETERS > 0) ::adjust(&data, params, (unsigned long) fs); @@ -119,7 +128,8 @@ plugin::setSampleRate(float fs) { } bool -plugin::getEffectName(char *name) { +plugin::getEffectName(char *name) +{ vst_strncpy(name, LABEL, kVstMaxEffectNameLen); return true; }