Modified Post. Rushed it first time. Apologies.
what should this formula do? The bracket is no mathmatical operator in C, so I don’t know what you’d like to express with “2(x)”
The intention was to show the idea in algebraic form. My query is whether the Pic can handle this type of function on the fly.
What’s it for?- This linkhttp://www.midibox.org/forum/index.php?topic=8276.0
The values I get from the resistors I used go from 55 to 126, almost sequntially- close enough for jazz. Reason- these were the resistors I had lying around, and there were no chances of me going to Maplin electronics during xmas/january sales.
So, moving along, I need to pass the signals to Native instruments B4, my clonewheel of choice. Values passed into this do not have to be exact, but close enough for jazz!!
Hence:
const unsigned char inputOutputMidiValues [9][2]={
{126,127}, {110,111}, {99,95}, {86,79}, {78,63}, {73,47}, {67,31}, {61,15}, {55,0},
};
.
First value is the value passed from the M1 drawbars, second value is what B4 will use for moving drawbar (ie the midi signal it sends on moving a drawbar), but it will accept a value close to latter for actually moving them eg will move to stop 8 from midi signal 121 and above.
This is a widespread error, that happens also to the pro’s from time to time:
The logical comparison operator for equality (“is the same as”) is this: ==
whereas the assignment operator that assigns the value of the right expression to the left side of the operator is this: =
This has made my day. I am not the only one doing it, yipppeee. And I must add- he he he.
So, passing the algebraic function into C
unsingned char midiInputValue = MIOS_AIN_7bitGet(pin); //Do I leave the underscores?
unsigned char midiOutputValue = (midiInputValue - 55) * 2;
//then sending the third value on pot movement:
MIOS_MIDI_TxBufferPut(midiOutputValue); // where normally this reads -
// MIOS_MIDI_TxBufferPut(MIOS_AIN_Pin7bitGet(pin));
How does it look? Has it a leg to stand on?