Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

no more static/global midi map

  • Loading branch information...
commit 99e8d3a4732221f3c12e6b1a39b7eece3178de0b 1 parent a12c602
@x42 x42 authored
View
3  b_conv/convolution.cc
@@ -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 () {
View
2  b_conv/convolution.h
@@ -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);
View
4 b_overdrive/jboverdrive.c
@@ -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
4 b_overdrive/lv2.c
@@ -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: */
View
2  b_overdrive/overdrive.h
@@ -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);
View
40 b_overdrive/overmaker.c
@@ -1160,16 +1160,16 @@ 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);
}
@@ -1177,9 +1177,9 @@ void legacyInit () {
#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,30 +1189,30 @@ 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 */
@@ -1220,7 +1220,7 @@ void legacyInit () {
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
2  b_reverb/lv2.c
@@ -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
2  b_reverb/reverb.c
@@ -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
2  b_reverb/reverb.h
@@ -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
20 b_synth/lv2.c
@@ -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
4 b_whirl/lv2.c
@@ -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
42 b_whirl/whirl.c
@@ -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
2  b_whirl/whirl.h
@@ -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
2  src/cfgParser.c
@@ -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
2  src/global_inst.h
@@ -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
View
27 src/main.c
@@ -331,6 +331,10 @@ static void allocAll () {
fprintf (stderr, "FATAL: memory allocation failed for tonegen.\n");
exit(1);
}
+ if (! (inst.midicfg = allocMidiCfg())) {
+ fprintf (stderr, "FATAL: memory allocation failed for midi config.\n");
+ exit(1);
+ }
}
/*
@@ -341,6 +345,7 @@ static void freeAll () {
freeWhirl(inst.whirl);
freeToneGenerator(inst.synth);
+ freeMidiCfg(inst.midicfg);
#ifdef HAVE_ZITACONVOLVE
freeConvolution();
#endif
@@ -362,23 +367,23 @@ static void initAll () {
fprintf (stderr, "Oscillators : ");
fflush (stderr);
- initToneGenerator (inst.synth);
+ initToneGenerator (inst.synth, inst.midicfg);
fprintf (stderr, "Scanner : ");
fflush (stderr);
- initVibrato (inst.synth);
+ initVibrato (inst.synth, inst.midicfg);
fprintf (stderr, "Overdrive : ");
fflush (stderr);
- initPreamp ();
+ initPreamp (NULL, inst.midicfg);
fprintf (stderr, "Reverb : ");
fflush (stderr);
- initReverb (inst.reverb, SampleRateD);
+ initReverb (inst.reverb, inst.midicfg, SampleRateD);
fprintf (stderr, "Whirl : ");
fflush (stderr);
- initWhirl (inst.whirl, SampleRateD);
+ initWhirl (inst.whirl, inst.midicfg, SampleRateD);
#ifdef HAVE_ZITACONVOLVE
fprintf (stderr, "Convolve : ");
@@ -392,7 +397,7 @@ static void initAll () {
} else {
fprintf(stderr, "zita-convolver: not using RT scheduling\n");
}
- initConvolution(AUDIO_CHANNELS, BUFFER_SIZE_SAMPLES, s_param.sched_priority, s_policy);
+ initConvolution(NULL, inst.midicfg, AUDIO_CHANNELS, BUFFER_SIZE_SAMPLES, s_param.sched_priority, s_policy);
#endif
fprintf (stderr, "..done.\n");
@@ -697,8 +702,8 @@ int main (int argc, char * argv []) {
* static initializations that is not practical to achieve in source code.
*/
- initControllerTable ();
- midiPrimeControllerMapping ();
+ initControllerTable (inst.midicfg);
+ midiPrimeControllerMapping (inst.midicfg);
/*
* Commandline arguments are parsed. If we are of a mind to try the
@@ -758,10 +763,10 @@ int main (int argc, char * argv []) {
listProgrammes (stderr);
}
- initMidiTables();
+ initMidiTables(inst.midicfg);
if (printCCTable) {
- listCCAssignments(stderr);
+ listCCAssignments(inst.midicfg, stderr);
}
/*
@@ -781,7 +786,7 @@ int main (int argc, char * argv []) {
}
#endif
- setMIDINoteShift (0);
+ setMIDINoteShift (inst.midicfg, 0);
setDrawBars (inst.synth, 0, presetSelect);
#if 0 // initial values are assigned in tonegen.c initToneGenerator()
View
2  src/main.h
@@ -50,7 +50,7 @@
extern int mainConfig (ConfigContext * cfg);
extern const ConfigDoc *mainDoc ();
-extern void listCCAssignments(FILE * fp);
+extern void listCCAssignments(void *mctl, FILE * fp);
extern double SampleRateD;
View
515 src/midi.c
@@ -163,11 +163,30 @@ enum parserState {
stProgramChg, dtaProgramChg
};
+#define CTRL_USE_MAX 128
+
+/* Arrays of pointers to functions that handle controller values. */
+
+typedef struct {
+ void (*fn)(void *, unsigned char);
+ void *d;
+} ctrl_function;
+
+typedef uint8_t midiccflags_t;
+
+enum { // 1,2,4,8,.. - adjust ctrlflg once >8 to uint16_t
+ MFLAG_INV = 1,
+};
+
+/* ---------------------------------------------------------------- */
+
+struct b_midicfg {
+
/* Used by the MIDI parser to record message bytes */
-static unsigned char rcvChA = 0; /* MIDI receive channel */
-static unsigned char rcvChB = 1; /* MIDI receive channel */
-static unsigned char rcvChC = 2; /* MIDI receive channel */
+unsigned char rcvChA; /* MIDI receive channel */
+unsigned char rcvChB; /* MIDI receive channel */
+unsigned char rcvChC; /* MIDI receive channel */
/*
* The all channel transpose is used to transpose the entire instrument
@@ -176,17 +195,17 @@ static unsigned char rcvChC = 2; /* MIDI receive channel */
* reach of the user's MIDI controller(s) to the desired range.
*/
-static int transpose = 0; /* All channel transpose */
+int transpose; /* All channel transpose */
-static int nshA = 0; /* Channel A transpose (no split) */
-static int nshA_U = 0; /* Channel A upper region transpose */
-static int nshA_PL = 0; /* Channel A pedal region transpose */
-static int nshA_UL = 0; /* Channel A lower region transpose */
-static int nshB = 0; /* Channel B transpose */
-static int nshC = 0; /* Channel C transpose */
+int nshA; /* Channel A transpose (no split) */
+int nshA_U; /* Channel A upper region transpose */
+int nshA_PL; /* Channel A pedal region transpose */
+int nshA_UL; /* Channel A lower region transpose */
+int nshB; /* Channel B transpose */
+int nshC; /* Channel C transpose */
-static int splitA_PL = 0; /* A channel pedal region */
-static int splitA_UL = 0; /* A channel lower region */
+int splitA_PL; /* A channel pedal region */
+int splitA_UL; /* A channel lower region */
/*
* This flag controls how to map MIDI input that falls outside of
@@ -195,41 +214,61 @@ static int splitA_UL = 0; /* A channel lower region */
* into the nearest octave with a playable key, a mechanism similar to
* the foldback used in some organ models.
*/
-static int userExcursionStrategy = 0;
+int userExcursionStrategy;
-static unsigned char keyTableA[128]; /**< MIDI note to key transl. tbl */
-static unsigned char keyTableB[128]; /**< MIDI note to key transl. tbl */
-static unsigned char keyTableC[128]; /**< MIDI note to key transl. tbl */
+unsigned char keyTableA[128]; /**< MIDI note to key transl. tbl */
+unsigned char keyTableB[128]; /**< MIDI note to key transl. tbl */
+unsigned char keyTableC[128]; /**< MIDI note to key transl. tbl */
-static unsigned char * keyTable[16]; /**< Tables per MIDI channel */
+unsigned char * keyTable[16]; /**< Tables per MIDI channel */
-/* Arrays that map from usage codes to MIDI controller numbers. */
-#define CTRL_USE_MAX 128
+unsigned char ctrlUseA[CTRL_USE_MAX];
+unsigned char ctrlUseB[CTRL_USE_MAX];
+unsigned char ctrlUseC[CTRL_USE_MAX];
-static unsigned char ctrlUseA[CTRL_USE_MAX];
-static unsigned char ctrlUseB[CTRL_USE_MAX];
-static unsigned char ctrlUseC[CTRL_USE_MAX];
+ctrl_function ctrlvecA[128];
+ctrl_function ctrlvecB[128];
+ctrl_function ctrlvecC[128];
-/* Arrays of pointers to functions that handle controller values. */
+ctrl_function *ctrlvec[16]; /**< control function table per MIDI channel */
-typedef struct {
- void (*fn)(void *, unsigned char);
- void *d;
-} ctrl_function;
+midiccflags_t ctrlflg[16][128]; /**< binary flags for each control -- binary OR */
+};
-static ctrl_function ctrlvecA[128];
-static ctrl_function ctrlvecB[128];
-static ctrl_function ctrlvecC[128];
+void resetMidiCfg(void *mcfg) {
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
-static ctrl_function *ctrlvec[16]; /**< control function table per MIDI channel */
+ m->rcvChA = 0; /* MIDI receive channel */
+ m->rcvChB = 1; /* MIDI receive channel */
+ m->rcvChC = 2; /* MIDI receive channel */
-typedef uint8_t midiccflags_t;
-static midiccflags_t ctrlflg[16][128]; /**< binary flags for each control -- binary OR */
-enum { // 1,2,4,8,.. - adjust ctrlflg once >8 to uint16_t
- MFLAG_INV = 1,
-};
+ m->transpose = 0; /* All channel transpose */
+
+ m->nshA = 0; /* Channel A transpose (no split) */
+ m->nshA_U = 0; /* Channel A upper region transpose */
+ m->nshA_PL = 0; /* Channel A pedal region transpose */
+ m->nshA_UL = 0; /* Channel A lower region transpose */
+ m->nshB = 0; /* Channel B transpose */
+ m->nshC = 0; /* Channel C transpose */
+
+ m->splitA_PL = 0; /* A channel pedal region */
+ m->splitA_UL = 0; /* A channel lower region */
+
+ m->userExcursionStrategy = 0;
+}
+
+void *allocMidiCfg() {
+ struct b_midicfg * mcfg = calloc(1, sizeof(struct b_midicfg));
+ resetMidiCfg(mcfg);
+ return mcfg;
+}
+
+void freeMidiCfg(void *mcfg) {
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
+ free(m);
+}
/* ---------------------------------------------------------------- */
@@ -299,20 +338,21 @@ static void assignMIDIControllerFunction (ctrl_function *vec,
* implemented by the function pointed to by the f parameter.
* @param f Pointer to function that acts on the controller message.
*/
-void useMIDIControlFunction (char * cfname, void (* f) (void *, unsigned char), void *d) {
+void useMIDIControlFunction (void *mcfg, char * cfname, void (* f) (void *, unsigned char), void *d) {
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
int x = getCCFunctionId (cfname);
assert (-1 < x);
- if (ctrlUseA[x] < 128) {
- assignMIDIControllerFunction (ctrlvecA, ctrlUseA[x], f, d);
+ if (m->ctrlUseA[x] < 128) {
+ assignMIDIControllerFunction (m->ctrlvecA, m->ctrlUseA[x], f, d);
}
- if (ctrlUseB[x] < 128) {
- assignMIDIControllerFunction (ctrlvecB, ctrlUseB[x], f, d);
+ if (m->ctrlUseB[x] < 128) {
+ assignMIDIControllerFunction (m->ctrlvecB, m->ctrlUseB[x], f, d);
}
- if (ctrlUseC[x] < 128) {
- assignMIDIControllerFunction (ctrlvecC, ctrlUseC[x], f, d);
+ if (m->ctrlUseC[x] < 128) {
+ assignMIDIControllerFunction (m->ctrlvecC, m->ctrlUseC[x], f, d);
}
}
@@ -320,19 +360,20 @@ void useMIDIControlFunction (char * cfname, void (* f) (void *, unsigned char),
/*
* This initializes the MIDI controller vector tables.
*/
-void initControllerTable () {
+void initControllerTable (void *mcfg) {
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
int i;
for (i = 0; i < 128; i++) {
int chn;
for (chn = 0; chn < 16; chn++) {
- ctrlflg[chn][i] = 0;
+ m->ctrlflg[chn][i] = 0;
}
- ctrlvecA[i].fn = emptyControlFunction;
- ctrlvecB[i].fn = emptyControlFunction;
- ctrlvecC[i].fn = emptyControlFunction;
- ctrlvecA[i].d = NULL;
- ctrlvecB[i].d = NULL;
- ctrlvecC[i].d = NULL;
+ m->ctrlvecA[i].fn = emptyControlFunction;
+ m->ctrlvecB[i].fn = emptyControlFunction;
+ m->ctrlvecC[i].fn = emptyControlFunction;
+ m->ctrlvecA[i].d = NULL;
+ m->ctrlvecB[i].d = NULL;
+ m->ctrlvecC[i].d = NULL;
}
}
@@ -393,29 +434,29 @@ static void clearKeyTable (unsigned char * table) {
/*
* This function loads the channel A note-to-key translation table.
*/
-static void loadKeyTableA () {
+static void loadKeyTableA (struct b_midicfg * m) {
int left = 0;
int first_MIDI_Note;
- clearKeyTable (keyTableA);
+ clearKeyTable (m->keyTableA);
- if (0 < splitA_PL) {
- loadKeyTableRegion (keyTableA,
- 24, splitA_PL - 1,
+ if (0 < m->splitA_PL) {
+ loadKeyTableRegion (m->keyTableA,
+ 24, m->splitA_PL - 1,
128, 159,
- transpose + nshA_PL,
+ m->transpose + m->nshA_PL,
0);
- left = splitA_PL;
+ left = m->splitA_PL;
}
- if (left < splitA_UL) {
+ if (left < m->splitA_UL) {
first_MIDI_Note = (36 < left) ? left : 36;
- loadKeyTableRegion (keyTableA,
- first_MIDI_Note, splitA_UL - 1,
+ loadKeyTableRegion (m->keyTableA,
+ first_MIDI_Note, m->splitA_UL - 1,
64 + (first_MIDI_Note % 12), 124,
- transpose + nshA_UL,
+ m->transpose + m->nshA_UL,
0);
- left = splitA_UL;
+ left = m->splitA_UL;
}
first_MIDI_Note = (36 < left) ? left : 36;
@@ -427,10 +468,10 @@ static void loadKeyTableA () {
* wide controller (e.g. 88 keys).
*/
- loadKeyTableRegion (keyTableA,
+ loadKeyTableRegion (m->keyTableA,
first_MIDI_Note, 127,
0 + (first_MIDI_Note - 36), 60,
- transpose + ((0 < left) ? nshA_U : nshA),
+ m->transpose + ((0 < left) ? m->nshA_U : m->nshA),
0);
} /* loadKeyTableA */
@@ -438,72 +479,78 @@ static void loadKeyTableA () {
/*
* Loads the B channel (lower manual) MIDI to key mapping table.
*/
-static void loadKeyTableB () {
+static void loadKeyTableB (struct b_midicfg * m) {
- clearKeyTable (keyTableB);
+ clearKeyTable (m->keyTableB);
- loadKeyTableRegion (keyTableB,
+ loadKeyTableRegion (m->keyTableB,
36, 96,
64, 124,
- transpose + nshB,
- userExcursionStrategy);
+ m->transpose + m->nshB,
+ m->userExcursionStrategy);
}
/*
* Loads the C channel (pedals) MIDI to key mapping table.
*/
-static void loadKeyTableC () {
+static void loadKeyTableC (struct b_midicfg * m) {
- clearKeyTable (keyTableC);
+ clearKeyTable (m->keyTableC);
- loadKeyTableRegion (keyTableC,
+ loadKeyTableRegion (m->keyTableC,
24, 55,
128, 159,
- transpose + nshC,
- userExcursionStrategy);
+ m->transpose + m->nshC,
+ m->userExcursionStrategy);
}
/*
* External interface to set and unset the A keyboard split points.
*/
-void setKeyboardSplitMulti (int flags,
+void setKeyboardSplitMulti (void *mcfg,
+ int flags,
int p_splitA_PL,
int p_splitA_UL,
int p_nshA_PL,
int p_nshA_UL,
int p_nshA_U)
{
- if (flags & 1) splitA_PL = p_splitA_PL;
- if (flags & 2) splitA_UL = p_splitA_UL;
- if (flags & 4) nshA_PL = p_nshA_PL;
- if (flags & 8) nshA_UL = p_nshA_UL;
- if (flags & 16) nshA_U = p_nshA_U;
-
- loadKeyTableA ();
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
+ if (flags & 1) m->splitA_PL = p_splitA_PL;
+ if (flags & 2) m->splitA_UL = p_splitA_UL;
+ if (flags & 4) m->nshA_PL = p_nshA_PL;
+ if (flags & 8) m->nshA_UL = p_nshA_UL;
+ if (flags & 16) m->nshA_U = p_nshA_U;
+
+ loadKeyTableA (m);
}
-void setKeyboardTransposeA (int transpose) {
- nshA = transpose;
- loadKeyTableA ();
+void setKeyboardTransposeA (void *mcfg, int transpose) {
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
+ m->nshA = transpose;
+ loadKeyTableA (m);
}
-void setKeyboardTransposeB (int transpose) {
- nshB = transpose;
- loadKeyTableB ();
+void setKeyboardTransposeB (void *mcfg, int transpose) {
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
+ m->nshB = transpose;
+ loadKeyTableB (m);
}
-void setKeyboardTransposeC (int transpose) {
- nshC = transpose;
- loadKeyTableC ();
+void setKeyboardTransposeC (void *mcfg, int transpose) {
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
+ m->nshC = transpose;
+ loadKeyTableC (m);
}
-void setKeyboardTranspose (int trsp) {
- transpose = trsp;
- loadKeyTableA ();
- loadKeyTableB ();
- loadKeyTableC ();
+void setKeyboardTranspose (void *mcfg, int trsp) {
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
+ m->transpose = trsp;
+ loadKeyTableA (m);
+ loadKeyTableB (m);
+ loadKeyTableC (m);
}
/*
@@ -512,19 +559,19 @@ void setKeyboardTranspose (int trsp) {
* to items used in the processing of the data in the message. For example,
* note on/off messages uses a pointer to a note-to-key translation table.
*/
-static void loadStatusTable () {
+static void loadStatusTable (struct b_midicfg * m) {
int i;
for (i = 0; i < 16; i++) {
- keyTable[i] = NULL;
- ctrlvec[i] = NULL;
+ m->keyTable[i] = NULL;
+ m->ctrlvec[i] = NULL;
}
- keyTable[rcvChA] = keyTableA;
- keyTable[rcvChB] = keyTableB;
- keyTable[rcvChC] = keyTableC;
+ m->keyTable[m->rcvChA] = m->keyTableA;
+ m->keyTable[m->rcvChB] = m->keyTableB;
+ m->keyTable[m->rcvChC] = m->keyTableC;
- ctrlvec[rcvChA] = (void *) ctrlvecA;
- ctrlvec[rcvChB] = (void *) ctrlvecB;
- ctrlvec[rcvChC] = (void *) ctrlvecC;
+ m->ctrlvec[m->rcvChA] = (void *) m->ctrlvecA;
+ m->ctrlvec[m->rcvChB] = (void *) m->ctrlvecB;
+ m->ctrlvec[m->rcvChC] = (void *) m->ctrlvecC;
}
/*
@@ -553,183 +600,186 @@ static void loadCCMap (char * cfname,
* when things move around.
* What we do is that we load the tables ctrlUseA, ctrlUseB and ctrlUseC
*/
-void midiPrimeControllerMapping () {
+void midiPrimeControllerMapping (void *mcfg) {
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
int i;
for (i = 0; i < CTRL_USE_MAX; i++) {
- ctrlUseA[i] = 255;
- ctrlUseB[i] = 255;
- ctrlUseC[i] = 255;
+ m->ctrlUseA[i] = 255;
+ m->ctrlUseB[i] = 255;
+ m->ctrlUseC[i] = 255;
}
- loadCCMap ("swellpedal1", 1, ctrlUseA, ctrlUseB, ctrlUseC);
- loadCCMap ("swellpedal2", 11, ctrlUseA, ctrlUseB, ctrlUseC);
+ loadCCMap ("swellpedal1", 1, m->ctrlUseA, m->ctrlUseB, m->ctrlUseC);
+ loadCCMap ("swellpedal2", 11, m->ctrlUseA, m->ctrlUseB, m->ctrlUseC);
- loadCCMap ("xov.ctl_biased", 3, ctrlUseA, NULL, NULL);
- loadCCMap ("xov.ctl_biased_fb", 9, ctrlUseA, NULL, NULL);
- loadCCMap ("xov.ctl_biased_fb2", 14, ctrlUseA, NULL, NULL);
- loadCCMap ("xov.ctl_biased_gfb", 15, ctrlUseA, NULL, NULL);
- loadCCMap ("xov.ctl_sagtobias", 20, ctrlUseA, NULL, NULL);
+ loadCCMap ("xov.ctl_biased", 3, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("xov.ctl_biased_fb", 9, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("xov.ctl_biased_fb2", 14, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("xov.ctl_biased_gfb", 15, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("xov.ctl_sagtobias", 20, m->ctrlUseA, NULL, NULL);
- loadCCMap ("overdrive.inputgain", 21, ctrlUseA, NULL, NULL);
- loadCCMap ("overdrive.outputgain", 22, ctrlUseA, NULL, NULL);
+ loadCCMap ("overdrive.inputgain", 21, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("overdrive.outputgain", 22, m->ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.drum.filter.type", 23, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.drum.filter.hz", 24, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.drum.filter.q", 25, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.drum.filter.gain", 26, ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.drum.filter.type", 23, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.drum.filter.hz", 24, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.drum.filter.q", 25, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.drum.filter.gain", 26, m->ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.horn.filter.a.type", 27, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.horn.filter.a.hz", 28, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.horn.filter.a.q", 29, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.horn.filter.a.gain", 30, ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.filter.a.type", 27, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.filter.a.hz", 28, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.filter.a.q", 29, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.filter.a.gain", 30, m->ctrlUseA, NULL, NULL);
/* 32-63 are least significant bits of controller 0-31 */
- loadCCMap ("rotary.speed-toggle", 64, ctrlUseA, ctrlUseB, ctrlUseC);
-
- loadCCMap ("upper.drawbar16", 70, ctrlUseA, NULL, NULL);
- loadCCMap ("upper.drawbar513", 71, ctrlUseA, NULL, NULL);
- loadCCMap ("upper.drawbar8", 72, ctrlUseA, NULL, NULL);
- loadCCMap ("upper.drawbar4", 73, ctrlUseA, NULL, NULL);
- loadCCMap ("upper.drawbar223", 74, ctrlUseA, NULL, NULL);
- loadCCMap ("upper.drawbar2", 75, ctrlUseA, NULL, NULL);
- loadCCMap ("upper.drawbar135", 76, ctrlUseA, NULL, NULL);
- loadCCMap ("upper.drawbar113", 77, ctrlUseA, NULL, NULL);
- loadCCMap ("upper.drawbar1", 78, ctrlUseA, NULL, NULL);
-
- loadCCMap ("lower.drawbar16", 70, NULL, ctrlUseB, NULL);
- loadCCMap ("lower.drawbar513", 71, NULL, ctrlUseB, NULL);
- loadCCMap ("lower.drawbar8", 72, NULL, ctrlUseB, NULL);
- loadCCMap ("lower.drawbar4", 73, NULL, ctrlUseB, NULL);
- loadCCMap ("lower.drawbar223", 74, NULL, ctrlUseB, NULL);
- loadCCMap ("lower.drawbar2", 75, NULL, ctrlUseB, NULL);
- loadCCMap ("lower.drawbar135", 76, NULL, ctrlUseB, NULL);
- loadCCMap ("lower.drawbar113", 77, NULL, ctrlUseB, NULL);
- loadCCMap ("lower.drawbar1", 78, NULL, ctrlUseB, NULL);
-
- loadCCMap ("pedal.drawbar16", 70, NULL, NULL, ctrlUseC);
- loadCCMap ("pedal.drawbar513", 71, NULL, NULL, ctrlUseC);
- loadCCMap ("pedal.drawbar8", 72, NULL, NULL, ctrlUseC);
- loadCCMap ("pedal.drawbar4", 73, NULL, NULL, ctrlUseC);
- loadCCMap ("pedal.drawbar223", 74, NULL, NULL, ctrlUseC);
- loadCCMap ("pedal.drawbar2", 75, NULL, NULL, ctrlUseC);
- loadCCMap ("pedal.drawbar135", 76, NULL, NULL, ctrlUseC);
- loadCCMap ("pedal.drawbar113", 77, NULL, NULL, ctrlUseC);
- loadCCMap ("pedal.drawbar1", 78, NULL, NULL, ctrlUseC);
-
- loadCCMap ("percussion.enable", 80, ctrlUseA, NULL, NULL);
- loadCCMap ("percussion.decay", 81, ctrlUseA, NULL, NULL);
- loadCCMap ("percussion.harmonic", 82, ctrlUseA, NULL, NULL);
-
- loadCCMap ("vibrato.knob", 83, ctrlUseA, NULL, NULL);
- loadCCMap ("vibrato.routing", 92, ctrlUseA, NULL, NULL);
-
- loadCCMap ("whirl.horn.filter.b.type", 85, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.horn.filter.b.hz", 86, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.horn.filter.b.q", 87, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.horn.filter.b.gain", 88, ctrlUseA, NULL, NULL);
+ loadCCMap ("rotary.speed-toggle", 64, m->ctrlUseA, m->ctrlUseB, m->ctrlUseC);
+
+ loadCCMap ("upper.drawbar16", 70, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("upper.drawbar513", 71, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("upper.drawbar8", 72, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("upper.drawbar4", 73, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("upper.drawbar223", 74, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("upper.drawbar2", 75, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("upper.drawbar135", 76, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("upper.drawbar113", 77, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("upper.drawbar1", 78, m->ctrlUseA, NULL, NULL);
+
+ loadCCMap ("lower.drawbar16", 70, NULL, m->ctrlUseB, NULL);
+ loadCCMap ("lower.drawbar513", 71, NULL, m->ctrlUseB, NULL);
+ loadCCMap ("lower.drawbar8", 72, NULL, m->ctrlUseB, NULL);
+ loadCCMap ("lower.drawbar4", 73, NULL, m->ctrlUseB, NULL);
+ loadCCMap ("lower.drawbar223", 74, NULL, m->ctrlUseB, NULL);
+ loadCCMap ("lower.drawbar2", 75, NULL, m->ctrlUseB, NULL);
+ loadCCMap ("lower.drawbar135", 76, NULL, m->ctrlUseB, NULL);
+ loadCCMap ("lower.drawbar113", 77, NULL, m->ctrlUseB, NULL);
+ loadCCMap ("lower.drawbar1", 78, NULL, m->ctrlUseB, NULL);
+
+ loadCCMap ("pedal.drawbar16", 70, NULL, NULL, m->ctrlUseC);
+ loadCCMap ("pedal.drawbar513", 71, NULL, NULL, m->ctrlUseC);
+ loadCCMap ("pedal.drawbar8", 72, NULL, NULL, m->ctrlUseC);
+ loadCCMap ("pedal.drawbar4", 73, NULL, NULL, m->ctrlUseC);
+ loadCCMap ("pedal.drawbar223", 74, NULL, NULL, m->ctrlUseC);
+ loadCCMap ("pedal.drawbar2", 75, NULL, NULL, m->ctrlUseC);
+ loadCCMap ("pedal.drawbar135", 76, NULL, NULL, m->ctrlUseC);
+ loadCCMap ("pedal.drawbar113", 77, NULL, NULL, m->ctrlUseC);
+ loadCCMap ("pedal.drawbar1", 78, NULL, NULL, m->ctrlUseC);
+
+ loadCCMap ("percussion.enable", 80, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("percussion.decay", 81, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("percussion.harmonic", 82, m->ctrlUseA, NULL, NULL);
+
+ loadCCMap ("vibrato.knob", 83, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("vibrato.routing", 92, m->ctrlUseA, NULL, NULL);
+
+ loadCCMap ("whirl.horn.filter.b.type", 85, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.filter.b.hz", 86, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.filter.b.q", 87, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.filter.b.gain", 88, m->ctrlUseA, NULL, NULL);
#ifdef HORN_COMB_FILTER // disabled in b_whirl/whirl.c
- loadCCMap ("whirl.horn.comb.a.feedback", 89, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.horn.comb.a.delay", 90, ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.comb.a.feedback", 89, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.comb.a.delay", 90, m->ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.horn.comb.b.feedback", 102, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.horn.comb.b.delay", 103, ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.comb.b.feedback", 102, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.comb.b.delay", 103, m->ctrlUseA, NULL, NULL);
#endif
- loadCCMap ("rotary.speed-preset", 91, ctrlUseA, NULL, NULL);
+ loadCCMap ("rotary.speed-preset", 91, m->ctrlUseA, NULL, NULL);
- loadCCMap ("overdrive.character", 93, ctrlUseA, NULL, NULL);
+ loadCCMap ("overdrive.character", 93, m->ctrlUseA, NULL, NULL);
- loadCCMap ("convolution.mix", 94, ctrlUseA, NULL, NULL);
+ loadCCMap ("convolution.mix", 94, m->ctrlUseA, NULL, NULL);
#if 0 // leslie testing
- loadCCMap ("whirl.horn.breakpos", 34, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.drum.breakpos", 35, ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.breakpos", 34, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.drum.breakpos", 35, m->ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.horn.acceleration", 36, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.horn.deceleration", 37, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.drum.acceleration", 38, ctrlUseA, NULL, NULL);
- loadCCMap ("whirl.drum.deceleration", 39, ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.acceleration", 36, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.horn.deceleration", 37, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.drum.acceleration", 38, m->ctrlUseA, NULL, NULL);
+ loadCCMap ("whirl.drum.deceleration", 39, m->ctrlUseA, NULL, NULL);
#endif
}
/*
* Sets global transpose (for playing in alternate scales).
*/
-void setMIDINoteShift (char offset) {
- transpose = offset;
- loadKeyTableA ();
- loadKeyTableB ();
- loadKeyTableC ();
+void setMIDINoteShift (void *mcfg, char offset) {
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
+ m->transpose = offset;
+ loadKeyTableA (m);
+ loadKeyTableB (m);
+ loadKeyTableC (m);
}
/*
* This call configures this module.
*/
-int midiConfig (ConfigContext * cfg) {
+int midiConfig (void *mcfg, ConfigContext * cfg) {
int v;
int ack = 0;
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
if ((ack = getConfigParameter_ir ("midi.upper.channel",
cfg,
&v,
1, 16)) == 1) {
- rcvChA = v - 1;
+ m->rcvChA = v - 1;
}
else if ((ack = getConfigParameter_ir ("midi.lower.channel",
cfg,
&v,
1, 16)) == 1) {
- rcvChB = v - 1;
+ m->rcvChB = v - 1;
}
else if ((ack = getConfigParameter_ir ("midi.pedals.channel",
cfg,
&v,
1, 16)) == 1) {
- rcvChC = v - 1;
+ m->rcvChC = v - 1;
}
else if ((ack = getConfigParameter_ir ("midi.transpose",
cfg,
&v,
-127, 127)) == 1) {
- transpose = v;
+ m->transpose = v;
}
else if ((ack = getConfigParameter_ir ("midi.upper.transpose",
cfg,
&v,
-127, 127)) == 1) {
- nshA = v;
+ m->nshA = v;
}
else if ((ack = getConfigParameter_ir ("midi.lower.transpose",
cfg,
&v,
-127, 127)) == 1) {
- nshB = v;
+ m->nshB = v;
}
else if ((ack = getConfigParameter_ir ("midi.pedals.transpose",
cfg,
&v,
-127, 127)) == 1) {
- nshC = v;
+ m->nshC = v;
}
else if ((ack = getConfigParameter_ir ("midi.pedals.transpose.split",
cfg,
&v,
-127, 127)) == 1) {
- nshA_PL = v;
+ m->nshA_PL = v;
}
else if ((ack = getConfigParameter_ir ("midi.lower.transpose.split",
cfg,
&v,
-127, 127)) == 1) {
- nshA_UL = v;
+ m->nshA_UL = v;
}
else if ((ack = getConfigParameter_ir ("midi.upper.transpose.split",
cfg,
&v,
-127, 127)) == 1) {
- nshA_U = v;
+ m->nshA_U = v;
}
/*
* The syntax for this config option is:
@@ -738,23 +788,23 @@ int midiConfig (ConfigContext * cfg) {
* <fname> is the symbolic name of a controllable function.
*/
else if (strncasecmp (cfg->name, "midi.controller.", 16) == 0) {
- unsigned char * ctrlUse = ctrlUseA;
- midiccflags_t * flagUse = ctrlflg[rcvChA];
+ unsigned char * ctrlUse = m->ctrlUseA;
+ midiccflags_t * flagUse = m->ctrlflg[m->rcvChA];
int ccIdx = 0;
if (strncasecmp ((cfg->name) + 16, "upper", 5) == 0) {
- ctrlUse = ctrlUseA;
- flagUse = ctrlflg[rcvChA];
+ ctrlUse = m->ctrlUseA;
+ flagUse = m->ctrlflg[m->rcvChA];
ccIdx = 22;
}
else if (strncasecmp ((cfg->name) + 16, "lower", 5) == 0) {
- ctrlUse = ctrlUseB;
- flagUse = ctrlflg[rcvChB];
+ ctrlUse = m->ctrlUseB;
+ flagUse = m->ctrlflg[m->rcvChB];
ccIdx = 22;
}
else if (strncasecmp ((cfg->name) + 16, "pedals", 6) == 0) {
- ctrlUse = ctrlUseC;
- flagUse = ctrlflg[rcvChC];
+ ctrlUse = m->ctrlUseC;
+ flagUse = m->ctrlflg[m->rcvChC];
ccIdx = 23;
}
else {
@@ -812,11 +862,12 @@ const ConfigDoc *midiDoc () {
return doc;
}
-void initMidiTables() {
- loadKeyTableA ();
- loadKeyTableB ();
- loadKeyTableC ();
- loadStatusTable ();
+void initMidiTables(void *mcfg) {
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
+ loadKeyTableA (m);
+ loadKeyTableB (m);
+ loadKeyTableC (m);
+ loadStatusTable (m);
}
@@ -842,19 +893,20 @@ struct bmidi_event_t {
};
void process_midi_event(b_instance *inst, const struct bmidi_event_t *ev) {
+ struct b_midicfg * m = (struct b_midicfg *) inst->midicfg;
switch(ev->type) {
case NOTE_ON:
- if(keyTable[ev->channel] && keyTable[ev->channel][ev->note] != 255) {
+ if(m->keyTable[ev->channel] && m->keyTable[ev->channel][ev->note] != 255) {
if (ev->velocity > 0){
- oscKeyOn (inst->synth, keyTable[ev->channel][ev->note]);
+ oscKeyOn (inst->synth, m->keyTable[ev->channel][ev->note]);
} else {
- oscKeyOff (inst->synth, keyTable[ev->channel][ev->note]);
+ oscKeyOff (inst->synth, m->keyTable[ev->channel][ev->note]);
}
}
break;
case NOTE_OFF:
- if(keyTable[ev->channel] && keyTable[ev->channel][ev->note] != 255)
- oscKeyOff (inst->synth, keyTable[ev->channel][ev->note]);
+ if(m->keyTable[ev->channel] && m->keyTable[ev->channel][ev->note] != 255)
+ oscKeyOff (inst->synth, m->keyTable[ev->channel][ev->note]);
break;
case PROGRAM_CHANGE:
installProgram(inst, ev->control_value);
@@ -867,9 +919,9 @@ void process_midi_event(b_instance *inst, const struct bmidi_event_t *ev) {
unsigned char * ctrlUse = NULL;
char *fn="";
int fid=-1;
- if (ev->channel == rcvChA) ctrlUse=ctrlUseA;
- else if (ev->channel == rcvChB) ctrlUse=ctrlUseB;
- else if (ev->channel == rcvChC) ctrlUse=ctrlUseC;
+ if (ev->channel == m->rcvChA) ctrlUse=m->ctrlUseA;
+ else if (ev->channel == m->rcvChB) ctrlUse=m->ctrlUseB;
+ else if (ev->channel == m->rcvChC) ctrlUse=m->ctrlUseC;
if (ctrlUse) {
int j;
for (j=0;j<CTRL_USE_MAX;++j) {
@@ -880,16 +932,16 @@ void process_midi_event(b_instance *inst, const struct bmidi_event_t *ev) {
}
}
printf("CC: %2d %03d -> %3d (%s) %s\n", ev->channel, ev->control_param, ev->control_value, fn,
- (ctrlvec[ev->channel] && ctrlvec[ev->channel][ev->control_param]!=emptyControlFunction)?"*":"-"
+ (m->ctrlvec[ev->channel] && m->ctrlvec[ev->channel][ev->control_param]!=emptyControlFunction)?"*":"-"
);
}
#endif
- if (ctrlvec[ev->channel] && ctrlvec[ev->channel][ev->control_param].fn) {
+ if (m->ctrlvec[ev->channel] && m->ctrlvec[ev->channel][ev->control_param].fn) {
uint8_t val = ev->control_value & 0x7f;
- if (ctrlflg[ev->channel][ev->control_param] & MFLAG_INV) {
+ if (m->ctrlflg[ev->channel][ev->control_param] & MFLAG_INV) {
val = 127 - val;
}
- (ctrlvec[ev->channel][ev->control_param].fn)(ctrlvec[ev->channel][ev->control_param].d, val);
+ (m->ctrlvec[ev->channel][ev->control_param].fn)(m->ctrlvec[ev->channel][ev->control_param].d, val);
}
break;
default:
@@ -1078,14 +1130,15 @@ void dumpCCAssigment(FILE * fp, unsigned char *ctrl, midiccflags_t *flags) {
}
}
-void listCCAssignments(FILE * fp) {
+void listCCAssignments(void *mcfg, FILE * fp) {
+ struct b_midicfg * m = (struct b_midicfg *) mcfg;
fprintf(fp,"MIDI CC Assigments:\n");
- fprintf(fp,"--- Upper Manual - Channel %2d ---\n", rcvChA);
- dumpCCAssigment(fp, ctrlUseA, ctrlflg[rcvChA]);
- fprintf(fp,"--- Lower Manual - Channel %2d ---\n", rcvChB);
- dumpCCAssigment(fp, ctrlUseB, ctrlflg[rcvChB]);
- fprintf(fp,"--- Pedal - Channel %2d ---\n", rcvChC);
- dumpCCAssigment(fp, ctrlUseC, ctrlflg[rcvChC]);
+ fprintf(fp,"--- Upper Manual - Channel %2d ---\n", m->rcvChA);
+ dumpCCAssigment(fp, m->ctrlUseA, m->ctrlflg[m->rcvChA]);
+ fprintf(fp,"--- Lower Manual - Channel %2d ---\n", m->rcvChB);
+ dumpCCAssigment(fp, m->ctrlUseB, m->ctrlflg[m->rcvChB]);
+ fprintf(fp,"--- Pedal - Channel %2d ---\n", m->rcvChC);
+ dumpCCAssigment(fp, m->ctrlUseC, m->ctrlflg[m->rcvChC]);
}
/* vi:set ts=8 sts=2 sw=2: */
View
26 src/midi.h
@@ -38,31 +38,35 @@
#define MIDI_PITCH_BEND 0xE0
#define MIDI_SYSTEM_PREFIX 0xF0
-extern void useMIDIControlFunction (char * cfname, void (* f) (void *, unsigned char), void *d);
+extern void useMIDIControlFunction (void *m, char * cfname, void (* f) (void *, unsigned char), void *d);
-extern void setKeyboardSplitMulti (int flags,
+extern void setKeyboardSplitMulti (void *mcfg,
+ int flags,
int p_splitA_PL,
int p_splitA_UL,
int p_nshA_PL,
int p_nshA_UL,
int p_nshA_U);
-extern void setKeyboardTransposeA (int t);
-extern void setKeyboardTransposeB (int t);
-extern void setKeyboardTransposeC (int t);
-extern void setKeyboardTranspose (int t);
+extern void setKeyboardTransposeA (void *mcfg, int t);
+extern void setKeyboardTransposeB (void *mcfg, int t);
+extern void setKeyboardTransposeC (void *mcfg, int t);
+extern void setKeyboardTranspose (void *mcfg, int t);
-extern void midiPrimeControllerMapping ();
+extern void midiPrimeControllerMapping (void *mcfg);
-extern int midiConfig (ConfigContext * cfg);
+extern int midiConfig (void *mcfg, ConfigContext * cfg);
extern const ConfigDoc *midiDoc ();
-extern void setMIDINoteShift (char offset);
+extern void setMIDINoteShift (void *mcfg, char offset);
-extern void initMidiTables();
-extern void initControllerTable ();
+extern void initMidiTables(void *mcfg);
+extern void initControllerTable (void *mcfg);
extern int getCCFunctionId (const char * name);
+extern void *allocMidiCfg();
+extern void freeMidiCfg(void *mcfg);
+
#ifdef HAVE_ASEQ
extern void *aseq_run(void *arg);
extern int aseq_open(char *port_name);
View
10 src/program.c
@@ -892,7 +892,7 @@ void installProgram (void *instance, unsigned char uc) {
b |= (flags0 & FL_TRA_PD) ? 4 : 0;
b |= (flags0 & FL_TRA_LM) ? 8 : 0;
b |= (flags0 & FL_TRA_UM) ? 16 : 0;
- setKeyboardSplitMulti (b,
+ setKeyboardSplitMulti (inst->midicfg, b,
PGM->keyboardSplitPedals,
PGM->keyboardSplitLower,
PGM->transpose[TR_CHA_PD],
@@ -901,19 +901,19 @@ void installProgram (void *instance, unsigned char uc) {
}
if (flags0 & FL_TRANSP) {
- setKeyboardTranspose (PGM->transpose[TR_TRANSP]);
+ setKeyboardTranspose (inst->midicfg, PGM->transpose[TR_TRANSP]);
}
if (flags0 & FL_TRCH_A) {
- setKeyboardTransposeA (PGM->transpose[TR_CHNL_A]);
+ setKeyboardTransposeA (inst->midicfg, PGM->transpose[TR_CHNL_A]);
}
if (flags0 & FL_TRCH_B) {
- setKeyboardTransposeB (PGM->transpose[TR_CHNL_B]);
+ setKeyboardTransposeB (inst->midicfg, PGM->transpose[TR_CHNL_B]);
}
if (flags0 & FL_TRCH_C) {
- setKeyboardTransposeC (PGM->transpose[TR_CHNL_C]);
+ setKeyboardTransposeC (inst->midicfg, PGM->transpose[TR_CHNL_C]);
}
}
View
74 src/tonegen.c
@@ -2896,7 +2896,7 @@ static void setSwellPedalFromMIDI (void *d, unsigned char u) {
* configuration files have already been read, so parameters should already
* be set.
*/
-void initToneGenerator (struct b_tonegen *t) {
+void initToneGenerator (struct b_tonegen *t, void *m) {
int i;
/* init global variables */
@@ -2981,42 +2981,42 @@ void initToneGenerator (struct b_tonegen *t) {
setPercussionFast (t, TRUE);
setPercussionEnabled (t, FALSE);
- useMIDIControlFunction ("swellpedal1", setSwellPedalFromMIDI, t);
- useMIDIControlFunction ("swellpedal2", setSwellPedalFromMIDI, t);
-
- useMIDIControlFunction ("upper.drawbar16", setDrawbar0, t);
- useMIDIControlFunction ("upper.drawbar513", setDrawbar1, t);
- useMIDIControlFunction ("upper.drawbar8", setDrawbar2, t);
- useMIDIControlFunction ("upper.drawbar4", setDrawbar3, t);
- useMIDIControlFunction ("upper.drawbar223", setDrawbar4, t);
- useMIDIControlFunction ("upper.drawbar2", setDrawbar5, t);
- useMIDIControlFunction ("upper.drawbar135", setDrawbar6, t);
- useMIDIControlFunction ("upper.drawbar113", setDrawbar7, t);
- useMIDIControlFunction ("upper.drawbar1", setDrawbar8, t);
-
- useMIDIControlFunction ("lower.drawbar16", setDrawbar9, t);
- useMIDIControlFunction ("lower.drawbar513", setDrawbar10, t);
- useMIDIControlFunction ("lower.drawbar8", setDrawbar11, t);
- useMIDIControlFunction ("lower.drawbar4", setDrawbar12, t);
- useMIDIControlFunction ("lower.drawbar223", setDrawbar13, t);
- useMIDIControlFunction ("lower.drawbar2", setDrawbar14, t);
- useMIDIControlFunction ("lower.drawbar135", setDrawbar15, t);
- useMIDIControlFunction ("lower.drawbar113", setDrawbar16, t);
- useMIDIControlFunction ("lower.drawbar1", setDrawbar17, t);
-
- useMIDIControlFunction ("pedal.drawbar16", setDrawbar18, t);
- useMIDIControlFunction ("pedal.drawbar513", setDrawbar19, t);
- useMIDIControlFunction ("pedal.drawbar8", setDrawbar20, t);
- useMIDIControlFunction ("pedal.drawbar4", setDrawbar21, t);
- useMIDIControlFunction ("pedal.drawbar223", setDrawbar22, t);
- useMIDIControlFunction ("pedal.drawbar2", setDrawbar23, t);
- useMIDIControlFunction ("pedal.drawbar135", setDrawbar24, t);
- useMIDIControlFunction ("pedal.drawbar113", setDrawbar25, t);
- useMIDIControlFunction ("pedal.drawbar1", setDrawbar26, t);
-
- useMIDIControlFunction ("percussion.enable", setPercVolumeFromMIDI, t);
- useMIDIControlFunction ("percussion.decay", setPercDecayFromMIDI, t);
- useMIDIControlFunction ("percussion.harmonic", setPercHarmonicFromMIDI, t);
+ useMIDIControlFunction (m, "swellpedal1", setSwellPedalFromMIDI, t);
+ useMIDIControlFunction (m, "swellpedal2", setSwellPedalFromMIDI, t);
+
+ useMIDIControlFunction (m, "upper.drawbar16", setDrawbar0, t);
+ useMIDIControlFunction (m, "upper.drawbar513", setDrawbar1, t);
+ useMIDIControlFunction (m, "upper.drawbar8", setDrawbar2, t);
+ useMIDIControlFunction (m, "upper.drawbar4", setDrawbar3, t);
+ useMIDIControlFunction (m, "upper.drawbar223", setDrawbar4, t);
+ useMIDIControlFunction (m, "upper.drawbar2", setDrawbar5, t);
+ useMIDIControlFunction (m, "upper.drawbar135", setDrawbar6, t);
+ useMIDIControlFunction (m, "upper.drawbar113", setDrawbar7, t);
+ useMIDIControlFunction (m, "upper.drawbar1", setDrawbar8, t);
+
+ useMIDIControlFunction (m, "lower.drawbar16", setDrawbar9, t);
+ useMIDIControlFunction (m, "lower.drawbar513", setDrawbar10, t);
+ useMIDIControlFunction (m, "lower.drawbar8", setDrawbar11, t);
+ useMIDIControlFunction (m, "lower.drawbar4", setDrawbar12, t);
+ useMIDIControlFunction (m, "lower.drawbar223", setDrawbar13, t);
+ useMIDIControlFunction (m, "lower.drawbar2", setDrawbar14, t);
+ useMIDIControlFunction (m, "lower.drawbar135", setDrawbar15, t);
+ useMIDIControlFunction (m, "lower.drawbar113", setDrawbar16, t);
+ useMIDIControlFunction (m, "lower.drawbar1", setDrawbar17, t);
+
+ useMIDIControlFunction (m, "pedal.drawbar16", setDrawbar18, t);
+ useMIDIControlFunction (m, "pedal.drawbar513", setDrawbar19, t);
+ useMIDIControlFunction (m, "pedal.drawbar8", setDrawbar20, t);
+ useMIDIControlFunction (m, "pedal.drawbar4", setDrawbar21, t);
+ useMIDIControlFunction (m, "pedal.drawbar223", setDrawbar22, t);
+ useMIDIControlFunction (m, "pedal.drawbar2", setDrawbar23, t);
+ useMIDIControlFunction (m, "pedal.drawbar135", setDrawbar24, t);
+ useMIDIControlFunction (m, "pedal.drawbar113", setDrawbar25, t);
+ useMIDIControlFunction (m, "pedal.drawbar1", setDrawbar26, t);
+
+ useMIDIControlFunction (m, "percussion.enable", setPercVolumeFromMIDI, t);
+ useMIDIControlFunction (m, "percussion.decay", setPercDecayFromMIDI, t);
+ useMIDIControlFunction (m, "percussion.harmonic", setPercHarmonicFromMIDI, t);
#if 0
dumpOscToText (t, "osc.txt");
View
2  src/tonegen.h
@@ -543,7 +543,7 @@ extern void setEnvReleaseClickLevel (struct b_tonegen *t, double u);
extern void setKeyClick (struct b_tonegen *t, int v);
extern int oscConfig (struct b_tonegen *t, ConfigContext * cfg);
extern const ConfigDoc *oscDoc ();
-extern void initToneGenerator (struct b_tonegen *t);
+extern void initToneGenerator (struct b_tonegen *t, void *m);
extern void freeToneGenerator (struct b_tonegen *t);
extern void oscKeyOff (struct b_tonegen *t, unsigned char midiNote);
View
6 src/vibrato.c
@@ -258,13 +258,13 @@ void resetVibrato (void *t) {
v->effectEnabled = FALSE;
}
-void initVibrato (void *t) {
+void initVibrato (void *t, void *m) {
struct b_vibrato *v = &(((struct b_tonegen*)t)->inst_vibrato);
setScannerFrequency (v, v->vibFqHertz);
initIncrementTables (v);
setVibrato (t, 0);
- useMIDIControlFunction ("vibrato.knob", setVibratoFromMIDI, t);
- useMIDIControlFunction ("vibrato.routing", setVibratoRoutingFromMIDI, t);
+ useMIDIControlFunction (m, "vibrato.knob", setVibratoFromMIDI, t);
+ useMIDIControlFunction (m, "vibrato.routing", setVibratoRoutingFromMIDI, t);
}
/*
View
2  src/vibrato.h
@@ -68,7 +68,7 @@ int effectEnabled;
extern void resetVibrato (void *tonegen);
-extern void initVibrato (void *tonegen);
+extern void initVibrato (void *tonegen, void *m);
extern void setVibrato (void *t, int select);

0 comments on commit 99e8d3a

Please sign in to comment.
Something went wrong with that request. Please try again.