Go Down

### Topic: Remap a midi setup (Read 767 times)previous topic - next topic

#### meilleur102

##### Jun 16, 2016, 03:22 pm
Hi guys!
I'm curently working on a Trigger system with piezo for a drum set.

I'm using this code for my base but I have a question for you.

Code: [Select]
`int pinRead;char pinAssignments[6] ={  'A0','A1','A2','A3','A4','A5','A6','A7','A8','A9','A10','A11'};byte PadNote[16] = {  57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72};         // MIDI notes from 0 to 127 int PadCutOff[16] = {  400,400,200,800,400,400,400,400,400,400,400,400,400,400,400,400};           // Minimum Analog value to cause a drum hitint MaxPlayTime[16] = {  90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90};               // Cycles before a 2nd hit is allowed#define  midichannel 1;                              // MIDI channel from 0 to 15 (+1 in "real world")boolean VelocityFlag  = true;                           // Velocity ON (true) or OFF (false)`

Can I just use the map function for remap the key.
For exemple If I press a switch so if digital 1=HIGH the key 57 become 62 for exemple?

Thanks.
Jc

#### Grumpy_Mike

#1
##### Jun 16, 2016, 06:29 pm
Quote
Can I just use the map function for remap the key.
No the map function only of use on continuous functions.

Quote
the key 57 become 62 for exemple?
The map function would only help here if you wanted to add 5 to all the key values, and if you want to do that then just add 5.

For an arbitrary mapping you need to use an array as a look up table in the way you use the pinAssingment array.
If you want to change the mapping you can change the numbers in the PadNote array, or make that a two dimensional array and have the second array index the mapping you want to use. This could be controlled by a switch or two.

#### meilleur102

#2
##### Jun 16, 2016, 08:06 pm
No the map function only of use on continuous functions.
The map function would only help here if you wanted to add 5 to all the key values, and if you want to do that then just add 5.

For an arbitrary mapping you need to use an array as a look up table in the way you use the pinAssingment array.
If you want to change the mapping you can change the numbers in the PadNote array, or make that a two dimensional array and have the second array index the mapping you want to use. This could be controlled by a switch or two.
Hi Mike.
I'm not sure that I understand relly well what your telling me.

Change the note in the padNote yes that's the goal.
But I want to have  the A1 (it's maped to 57) I want to be map to 60 when I press a switch, and back to 57 when I press the switch again.

#### Grumpy_Mike

#3
##### Jun 16, 2016, 10:57 pm
Quote
I want to have  the A1 (it's maped to 57) I want to be map to 60 when I press a switch, and back to 57 when I press the switch again.
Is that all? Or are there other shifts you want to make?

If it is all then you have an offset ( a variable ) that is set to zero or when the button is pushed it is set to 3. Then when you trigger A1 you add this offset to the value. To get the variable to toggle on alternat button presses look at the state change example in the IDE.

#### meilleur102

#4
##### Jun 16, 2016, 11:59 pm
Is that all? Or are there other shifts you want to make?

If it is all then you have an offset ( a variable ) that is set to zero or when the button is pushed it is set to 3. Then when you trigger A1 you add this offset to the value. To get the variable to toggle on alternat button presses look at the state change example in the IDE.
So if I understand correctly I just have to do a offset. So when digitalized high(the switch) A1 offset +3?

#### Grumpy_Mike

#5
##### Jun 17, 2016, 12:03 am
Quote
So when digitalized high(the switch) A1 offset +3?
That is not what you said, you said:-
Quote
I want to be map to 60 when I press a switch, and back to 57 when I press the switch again.
So you in effect have to count the number of switch presses there has been and if it is odd you have the offset value as zero and if even then 3.

You need to define exactly what you want to do before you can do it.

#### meilleur102

#6
##### Jun 17, 2016, 01:25 pm
That is not what you said, you said:-So you in effect have to count the number of switch presses there has been and if it is odd you have the offset value as zero and if even then 3.

You need to define exactly what you want to do before you can do it.
I know what I want to do, but maybee because i'm not english I don't understand well what your telling me.

So what I want to to.

57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72};

if ButtonPress
60,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72};

if ButtonPress again
57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72};

Simple as that. But it's look complicated to program it

Thanks.
Jc

#### Grumpy_Mike

#7
##### Jun 17, 2016, 03:18 pm

I can not be more specific because you have not posted ALL your code.

Look at the state change example in the IDE for seeing how you can detect a button push and count it.

#8