Permalink
Browse files

no more static/global midi map

  • Loading branch information...
1 parent a12c602 commit 99e8d3a4732221f3c12e6b1a39b7eece3178de0b @x42 x42 committed Mar 10, 2013
@@ -158,6 +158,7 @@ static Convproc *convproc = 0;
*
*/
void initConvolution (
+ void *clv, void *m,
const unsigned int channels,
const unsigned int buffersize,
int sched_pri,
@@ -261,7 +262,7 @@ void initConvolution (
exit (1);
}
- ::useMIDIControlFunction (_S"convolution.mix", setConvolutionMix, NULL);
+ useMIDIControlFunction (m, _S"convolution.mix", setConvolutionMix, NULL);
}
void freeConvolution () {
@@ -31,7 +31,7 @@ extern "C" {
extern void setConvolutionMix (unsigned char u);
-extern void initConvolution (const unsigned int channels, const unsigned int buffersize, int sched_pri, int sched_pol);
+extern void initConvolution (void *clv, void *m, const unsigned int channels, const unsigned int buffersize, int sched_pri, int sched_pol);
extern void freeConvolution ();
extern void convolve (const float ** inbuf, float ** outbuf, size_t n_channels, size_t n_samples);
@@ -45,7 +45,7 @@ float p_globfeed = 0.5826;
float p_gainin = 0.3567;
float p_gainout = 0.07873;
-void useMIDIControlFunction (char * cfname, void (* f) (void *, unsigned char), void *d) {}
+void useMIDIControlFunction (void *m, char * cfname, void (* f) (void *, unsigned char), void *d) {}
int getConfigParameter_fr (char * par, ConfigContext * cfg, float * fp, float lowInc, float highInc) {return 0;}
int getConfigParameter_f (char * par, ConfigContext * cfg, float * fp) {return 0;}
@@ -223,7 +223,7 @@ float pp(const char *ps) {
int main (int argc, char**argv) {
int osc_port=0;
- initPreamp();
+ initPreamp(NULL, NULL);
int c;
const char *optstring = "hi:o:O:p:V";
View
@@ -70,7 +70,7 @@ instantiate(const LV2_Descriptor* descriptor,
B3O* b3o = (B3O*)calloc(1, sizeof(B3O));
b3o->o_bias = b3o->o_feedback = b3o->o_sagtobias = b3o->o_postfeed = b3o->o_globfeed = b3o->o_gainin = b3o->o_gainout = -1;
- initPreamp();
+ initPreamp(NULL, NULL);
return (LV2_Handle)b3o;
}
@@ -185,7 +185,7 @@ lv2_descriptor(uint32_t index)
}
}
-void useMIDIControlFunction (char * cfname, void (* f) (void *, unsigned char), void *d) {}
+void useMIDIControlFunction (void *m, char * cfname, void (* f) (void *, unsigned char), void *d) {}
int getConfigParameter_fr (char * par, ConfigContext * cfg, float * fp, float lowInc, float highInc) {return 0;}
int getConfigParameter_f (char * par, ConfigContext * cfg, float * fp) {return 0;}
/* vi:set ts=8 sts=2 sw=2: */
@@ -27,7 +27,7 @@
extern int ampConfig (ConfigContext * cfg);
extern const ConfigDoc *ampDoc ();
-extern void initPreamp ();
+extern void initPreamp (void *pa, void *m);
extern void setClean (int useClean);
extern float * preamp (float * inBuf, float * outBuf, size_t bufLengthSamples);
@@ -1160,26 +1160,26 @@ void legacyInit () {
char buf[BUFSZ];
vspace (3);
commentln ("Legacy function");
- codeln ("void initPreamp () {");
+ codeln ("void initPreamp (void *pa, void *m) {");
pushIndent ();
codeln ("mixFilterWeights (ipwdef, aaldef);");
#ifdef PRE_FILTER_TYPE
if (generatePreFilter) {
- codeln ("useMIDIControlFunction (\"xov.prefilter.hz\", setPreFilterHz, NULL);");
- codeln ("useMIDIControlFunction (\"xov.prefilter.q\", setPreFilterQ, NULL);");
- codeln ("useMIDIControlFunction(\"xov.prefilter.gain\", setPreFilterG, NULL);");
+ codeln ("useMIDIControlFunction (m, \"xov.prefilter.hz\", setPreFilterHz, NULL);");
+ codeln ("useMIDIControlFunction (m, \"xov.prefilter.q\", setPreFilterQ, NULL);");
+ codeln ("useMIDIControlFunction(m, \"xov.prefilter.gain\", setPreFilterG, NULL);");
sprintf (buf, "preFilterDefine (%d, pr_F, pr_Q, pr_G);", PRE_FILTER_TYPE);
codeln (buf);
}
#endif /* PRE_FILTER_TYPE */
#ifdef POST_FILTER_TYPE
if (generatePostFilter) {
- codeln ("useMIDIControlFunction (\"xov.postfilter.hz\", setPostFilterHz, NULL);");
- codeln ("useMIDIControlFunction (\"xov.postfilter.q\", setPostFilterQ, NULL);");
- codeln ("useMIDIControlFunction (\"xov.postfilter.gain\", setPostFilterG, NULL);");
+ codeln ("useMIDIControlFunction (m, \"xov.postfilter.hz\", setPostFilterHz, NULL);");
+ codeln ("useMIDIControlFunction (m, \"xov.postfilter.q\", setPostFilterQ, NULL);");
+ codeln ("useMIDIControlFunction (m, \"xov.postfilter.gain\", setPostFilterG, NULL);");
sprintf (buf,"postFilterDefine (%d, de_F, de_Q, de_G);", POST_FILTER_TYPE);
codeln (buf);
}
@@ -1189,38 +1189,38 @@ void legacyInit () {
/* ================================================================ */
#ifdef TR_BIASED
- sprintf (buf, "useMIDIControlFunction (\"xov.ctl_biased\", ctl_biased, NULL);");
+ sprintf (buf, "useMIDIControlFunction (m, \"xov.ctl_biased\", ctl_biased, NULL);");
codeln (buf);
#ifdef ADWS_PRE_DIFF
sprintf (buf,
- "useMIDIControlFunction (\"xov.ctl_biased_fb\", ctl_biased_fb, NULL);");
+ "useMIDIControlFunction (m, \"xov.ctl_biased_fb\", ctl_biased_fb, NULL);");
codeln (buf);
#endif /* ADWS_PRE_DIFF */
#ifdef ADWS_POST_DIFF
sprintf (buf,
- "useMIDIControlFunction (\"xov.ctl_biased_fb2\", ctl_biased_fb2, NULL);");
+ "useMIDIControlFunction (m, \"xov.ctl_biased_fb2\", ctl_biased_fb2, NULL);");
codeln (buf);
#endif /* ADWS_POST_DIFF */
#ifdef ADWS_GFB
sprintf (buf,
- "useMIDIControlFunction (\"xov.ctl_biased_gfb\", ctl_biased_gfb, NULL);");
+ "useMIDIControlFunction (m, \"xov.ctl_biased_gfb\", ctl_biased_gfb, NULL);");
codeln (buf);
#endif /* ADWS_GFB */
#ifdef SAG_EMULATION
sprintf (buf,
- "useMIDIControlFunction (\"xov.ctl_sagtobias\", ctl_sagtoBias, NULL);");
+ "useMIDIControlFunction (m, \"xov.ctl_sagtobias\", ctl_sagtoBias, NULL);");
codeln (buf);
#endif /* SAG_EMULATION */
#ifdef ADWS_FAT_CTRL
sprintf
(
buf,
- "useMIDIControlFunction (\"overdrive.character\", ctl_biased_fat, NULL);"
+ "useMIDIControlFunction (m, \"overdrive.character\", ctl_biased_fat, NULL);"
);
codeln (buf);
#endif /* ADWS_FAT_CTRL */
@@ -1232,28 +1232,28 @@ void legacyInit () {
#ifdef INPUT_GAIN
- sprintf (buf, "useMIDIControlFunction (\"overdrive.inputgain\", setInputGain, NULL);");
+ sprintf (buf, "useMIDIControlFunction (m, \"overdrive.inputgain\", setInputGain, NULL);");
codeln (buf);
#endif /* INPUT_GAIN */
#ifdef OUTPUT_GAIN
- sprintf (buf, "useMIDIControlFunction (\"overdrive.outputgain\", setOutputGain, NULL);");
+ sprintf (buf, "useMIDIControlFunction (m, \"overdrive.outputgain\", setOutputGain, NULL);");
codeln (buf);
#endif /* OUTPUT_GAIN */
#ifdef PRE_DC_OFFSET
- codeln ("useMIDIControlFunction (\"xov.pre_dc_offset\", setPreDCOffset, NULL);");
+ codeln ("useMIDIControlFunction (m, \"xov.pre_dc_offset\", setPreDCOffset, NULL);");
#endif /* PRE_DC_OFFSET */
#ifdef CLEAN_MIX
- sprintf (buf, "useMIDIControlFunction (\"xov.mix.dry\", setCleanMix, NULL);");
+ sprintf (buf, "useMIDIControlFunction (m, \"xov.mix.dry\", setCleanMix, NULL);");
codeln (buf);
#endif /* CLEAN_MIX */
#ifdef INPUT_COMPRESS
- codeln ("useMIDIControlFunction (\"xov.compressor.threshold\", setIpcThreshold, NULL);");
- codeln ("useMIDIControlFunction (\"xov.compressor.attack\", setIpcAttack, NULL);");
- codeln ("useMIDIControlFunction (\"xov.compressor.release\", setIpcRelease, NULL);");
+ codeln ("useMIDIControlFunction (m, \"xov.compressor.threshold\", setIpcThreshold, NULL);");
+ codeln ("useMIDIControlFunction (m, \"xov.compressor.attack\", setIpcAttack, NULL);");
+ codeln ("useMIDIControlFunction (m, \"xov.compressor.release\", setIpcRelease, NULL);");
#endif /* INPUT_COMPRESS */
popIndent ();
codeln ("}");
View
@@ -60,7 +60,7 @@ instantiate(const LV2_Descriptor* descriptor,
return NULL;
}
- initReverb(b3r->instance, rate);
+ initReverb(b3r->instance, NULL, rate);
return (LV2_Handle)b3r;
}
View
@@ -273,7 +273,7 @@ const ConfigDoc *reverbDoc () {
/*
*
*/
-void initReverb (struct b_reverb *r, double rate) {
+void initReverb (struct b_reverb *r, void *m, double rate) {
int i;
r->SampleRateD = rate;
for (i = 0; i < RV_NZ; i++) {
View
@@ -66,7 +66,7 @@ extern void setReverbDry (struct b_reverb *r, float g);
extern void setReverbWet (struct b_reverb *r, float g);
-extern void initReverb (struct b_reverb *r, double rate);
+extern void initReverb (struct b_reverb *r, void *m, double rate);
extern float * reverb (struct b_reverb *r, const float * inbuf, float * outbuf, size_t bufferLengthSamples);
View
@@ -73,20 +73,20 @@ void initSynth(B3S *b3s, double rate) {
unsigned int defaultPreset[9] = {8,8,8, 0,0,0,0, 0,0};
srand ((unsigned int) time (NULL));
- initControllerTable ();
- midiPrimeControllerMapping ();
+ initControllerTable (b3s->inst.midicfg);
+ midiPrimeControllerMapping (b3s->inst.midicfg);
/* initAll() */
- initToneGenerator (b3s->inst.synth);
- initVibrato (b3s->inst.synth);
- initPreamp ();
- initReverb (b3s->inst.reverb, rate);
- initWhirl (b3s->inst.whirl, rate);
+ initToneGenerator (b3s->inst.synth, b3s->inst.midicfg);
+ initVibrato (b3s->inst.synth, b3s->inst.midicfg);
+ initPreamp (NULL, b3s->inst.midicfg);
+ initReverb (b3s->inst.reverb, b3s->inst.midicfg, rate);
+ initWhirl (b3s->inst.whirl, b3s->inst.midicfg, rate);
/* end - initAll() */
- initMidiTables();
+ initMidiTables(b3s->inst.midicfg);
- setMIDINoteShift (0);
+ setMIDINoteShift (b3s->inst.midicfg, 0);
setDrawBars (b3s->inst.synth, 0, defaultPreset);
setDrawBars (b3s->inst.synth, 1, defaultPreset);
setDrawBars (b3s->inst.synth, 2, defaultPreset);
@@ -165,6 +165,7 @@ instantiate(const LV2_Descriptor* descriptor,
b3s->inst.reverb = allocReverb();
b3s->inst.whirl = allocWhirl();
b3s->inst.synth = allocTonegen();
+ b3s->inst.midicfg = allocMidiCfg();
initSynth(b3s, rate);
@@ -232,6 +233,7 @@ cleanup(LV2_Handle instance)
freeReverb(b3s->inst.reverb);
freeWhirl(b3s->inst.whirl);
freeToneGenerator(b3s->inst.synth);
+ freeMidiCfg(b3s->inst.midicfg);
free(instance);
}
View
@@ -102,7 +102,7 @@ instantiate(const LV2_Descriptor* descriptor,
* parameters during deactive/activate cycles..
*/
- initWhirl(b3w->instance, rate);
+ initWhirl(b3w->instance, NULL, rate);
return (LV2_Handle)b3w;
}
@@ -280,7 +280,7 @@ lv2_descriptor(uint32_t index)
}
}
-void useMIDIControlFunction (char * cfname, void (* f) (void *d, unsigned char), void *d) { }
+void useMIDIControlFunction (void *m, char * cfname, void (* f) (void *d, unsigned char), void *d) { }
int getConfigParameter_dr (char * par, ConfigContext * cfg, double * dp, double lowInc, double highInc) { return 0; }
int getConfigParameter_d (char * par, ConfigContext * cfg, double * dp) { return 0; }
int getConfigParameter_ir (char * par, ConfigContext * cfg, int * ip, int lowInc, int highInc) { return 0; }
View
@@ -777,7 +777,7 @@ void setDrumDeceleration (void *d, unsigned char uc) {
/*
* This function initialises this module. It is run after whirlConfig.
*/
-void initWhirl (struct b_whirl *w, double rate) {
+void initWhirl (struct b_whirl *w, void *m, double rate) {
w->SampleRateD = rate;
@@ -791,26 +791,26 @@ void initWhirl (struct b_whirl *w, double rate) {
w->leakage = w->leakLevel * w->hornLevel;
- useMIDIControlFunction ("rotary.speed-toggle", setWhirlSustainPedal, (void*)w);
- useMIDIControlFunction ("rotary.speed-preset", revControl, (void*)w);
- useMIDIControlFunction ("rotary.speed-select", revControlAll, (void*)w);
-
- useMIDIControlFunction ("whirl.horn.filter.a.type", setHornFilterAType, (void*)w);
- useMIDIControlFunction ("whirl.horn.filter.a.hz", setHornFilterAFrequency, (void*)w);
- useMIDIControlFunction ("whirl.horn.filter.a.q", setHornFilterAQ, (void*)w);
- useMIDIControlFunction ("whirl.horn.filter.a.gain", setHornFilterAGain, (void*)w);
- useMIDIControlFunction ("whirl.horn.filter.b.type", setHornFilterBType, (void*)w);
- useMIDIControlFunction ("whirl.horn.filter.b.hz", setHornFilterBFrequency, (void*)w);
- useMIDIControlFunction ("whirl.horn.filter.b.q", setHornFilterBQ, (void*)w);
- useMIDIControlFunction ("whirl.horn.filter.b.gain", setHornFilterBGain, (void*)w);
-
- useMIDIControlFunction ("whirl.horn.breakpos", setHornBreakPosition, (void*)w);
- useMIDIControlFunction ("whirl.drum.breakpos", setDrumBreakPosition, (void*)w);
-
- useMIDIControlFunction ("whirl.horn.acceleration", setHornAcceleration, (void*)w);
- useMIDIControlFunction ("whirl.horn.deceleration", setHornDeceleration, (void*)w);
- useMIDIControlFunction ("whirl.drum.acceleration", setDrumAcceleration, (void*)w);
- useMIDIControlFunction ("whirl.drum.deceleration", setDrumDeceleration, (void*)w);
+ useMIDIControlFunction (m, "rotary.speed-toggle", setWhirlSustainPedal, (void*)w);
+ useMIDIControlFunction (m, "rotary.speed-preset", revControl, (void*)w);
+ useMIDIControlFunction (m, "rotary.speed-select", revControlAll, (void*)w);
+
+ useMIDIControlFunction (m, "whirl.horn.filter.a.type", setHornFilterAType, (void*)w);
+ useMIDIControlFunction (m, "whirl.horn.filter.a.hz", setHornFilterAFrequency, (void*)w);
+ useMIDIControlFunction (m, "whirl.horn.filter.a.q", setHornFilterAQ, (void*)w);
+ useMIDIControlFunction (m, "whirl.horn.filter.a.gain", setHornFilterAGain, (void*)w);
+ useMIDIControlFunction (m, "whirl.horn.filter.b.type", setHornFilterBType, (void*)w);
+ useMIDIControlFunction (m, "whirl.horn.filter.b.hz", setHornFilterBFrequency, (void*)w);
+ useMIDIControlFunction (m, "whirl.horn.filter.b.q", setHornFilterBQ, (void*)w);
+ useMIDIControlFunction (m, "whirl.horn.filter.b.gain", setHornFilterBGain, (void*)w);
+
+ useMIDIControlFunction (m, "whirl.horn.breakpos", setHornBreakPosition, (void*)w);
+ useMIDIControlFunction (m, "whirl.drum.breakpos", setDrumBreakPosition, (void*)w);
+
+ useMIDIControlFunction (m, "whirl.horn.acceleration", setHornAcceleration, (void*)w);
+ useMIDIControlFunction (m, "whirl.horn.deceleration", setHornDeceleration, (void*)w);
+ useMIDIControlFunction (m, "whirl.drum.acceleration", setDrumAcceleration, (void*)w);
+ useMIDIControlFunction (m, "whirl.drum.deceleration", setDrumDeceleration, (void*)w);
}
/*
View
@@ -199,7 +199,7 @@ extern void freeWhirl(struct b_whirl *w);
extern int whirlConfig (struct b_whirl *w, ConfigContext * cfg);
extern const ConfigDoc *whirlDoc ();
-extern void initWhirl (struct b_whirl *w, double rate);
+extern void initWhirl (struct b_whirl *w, void *m, double rate);
extern void whirlProc (struct b_whirl *w,
const float * inbuffer,
View
@@ -67,7 +67,7 @@ static int distributeParameter (b_instance* inst, ConfigContext * cfg) {
#else
n += mainConfig (cfg);
- n += midiConfig (cfg);
+ n += midiConfig (inst->midicfg, cfg);
n += pgmConfig (cfg);
n += oscConfig (inst->synth, cfg);
n += scannerConfig (inst->synth, cfg);
View
@@ -31,7 +31,7 @@ typedef struct b_instance {
struct b_reverb *reverb;
struct b_whirl *whirl;
struct b_tonegen *synth;
- void * midicfg; // TODO
+ void * midicfg;
} b_instance;
#endif
Oops, something went wrong. Retry.

0 comments on commit 99e8d3a

Please sign in to comment.