Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
Software apps and online services | ||||||
| ||||||
Hand tools and fabrication machines | ||||||
| ||||||
| ||||||
| ||||||
| ||||||
| ||||||
|
This project shows how to convert an old organ console so that it can be used to send out hardware MIDI messages from the manuals and pedals using a single Arduino Mega.
The project started as an attempt to send out midi messages while the original sound generation was still intact, however the original circuits proved quite difficult to reverse engineer. After spending some time with the code, I developed code for both bussed type manuals, and matrixed type ones.
Notes:
- This project modifies the organ so that the original keyboard switching no longer works.
- Inside an old organ, there are electrical components that can be dangerous. Always work with the organ unplugged, and be sure you have the experience and skills to work on this project safely. If in doubt, consult with a qualified local electronics technician before attempting this project.
- The components inside old organs are often quite old and on the verge of malfunctioning, so any modifications may result in damage to the organ. Following the instructions provided here is done at the user's own risk, and the author of this article assumes no responsibility for any damage that occurs to an organ, any equipment, or persons as a result of attempting to follow these instructions.
Updated Mar 26, 2022: Added an improved Matrixed code and schematic, with explanations at the end of this text.
Step 1: Examine organ- My first posted code assumed that the organ you are wishing to modify already has a matrixed keyboard, with discrete switches and diodes already in place. Since posting that first version, I have also developed code that will work with bussed keyboard designs. Simply follow the instructions and use the code for the version that applies to you (Matrixed vs. Bussed). For both designs, however, you will need diodes attached to every switch. These can be obtained cheaply. However, the code uploaded to the Arduino Mega is different with matrixed vs. a bussed design.
- The particular organ which was midified in this example has normally open (NO) switches for the keyboards, and normally closed switches (NC) for the pedals. Using a multimeter, you can check what kind of switches the organ you are planning to convert has. If the switch type is different than what was done for this organ, you will have to modify the code to suit the switch type (examples given in the code)
- Figure out how to open up the organ to access the keyboards and pedalboard contacts, and look for a suitable place to attach the Arduino inside the organ. You may have to drill holes or install plugs to provide power to the Arduino, and to mount the Midi plug. In this example, a 3 prong power plug was wired to a small power box inside the organ to provide power to the Arduino, and a hole was drilled, and a Midi DIN plug was attached to the hole.
- The particular organ shown here had two keyboards with 6x11 matrixes, and a pedalboard with a 6x7 matrix. If you plan to go the matrix route, and the particular organ already has a 8x8 matrix, either the code and wiring will need to be modified to suit an 8x8 matrix, or the original matrix will have to be rewired to support a 6x11 matrix.
-My Arduino Mega came with a small plastic plate to mount it to the wood of the organ. I attached it with small #4 wood screws, and #4 machine screws to attach the Arduino to the plate. It is a good idea to place the Arduino first, so that you will be able to estimate how long each cable needs to be. At this point, you can also find a way to supply power to the Arduino.
Step 3: Prepare cablesMatrixed Keyboard:
Each keyboard will have 61 switches. In the example used here, each keyboard had 6 rows, with a wire going from the first terminal of every switch to the first terminal of every other switch 6 switches away. The second terminal of the switch then went to a diode, then to the columns, of which the switches were divided into 11 columns for the manuals, and 7 columns for the pedals. For each manual and the pedals then, two lengths of the AWM wire recommended need to be cut so that they reach from each division to the Arduino board, preferably following a path that can be neatly organized, and always leaving more leeway than is needed. For the columns, it is preferable to have the cable extend the length of the keyboard or pedalboard before going to the Arduino. Measure each length of cable, and cut to size. Using the small nippers, separate the individual strands of the cable at the ends, and strip the plastic covering off the wire ends using the wire strippers.
Bussed Keyboard:
The keyboard can be divided up into 6 AWM cables, with an ordinary wire for the 61st switch. Separate the individual strands of the cable at the ends, then strip the plastic covering off the ends using the wire strippers.
Step 4: Solder cable ends to male headersBoth Matrixed and Bussed Keyboards: Either solder the appropriate cable ends to the male header pins, or if using the screw terminal board, attach the appropriate cables to the screw terminals.
Matrixed Keyboard:
-If the organ already has each contact wired, you will have to desolder or clip the original wires in order for this project to work. If the organ has a 6x11 matrix, it makes sense to preserve the row wires that go from each switch to the next switch 6 up. So, remove the row wires going from the first set of six to the original computer, and solder the 6 row wires to the position where the other 6 used to be. For the columns, if they already have diodes in place, then clip or desolder the lead going from the other end of the diodes to the original computer, then solder the column lead going to your Arduino in its place. Using plastic cable ties, you can organize the cables so they run neatly along where the other cables in the organ run. For the pedalboard on the organ pictured above, the panel on the front of the organ containing the reed switches had to be removed by removing the screws holding it on, and the cables routed through the small hole in the centre of the front panel of the organ.
Bussed Keyboard:
In the bussed keyboard code, it is necessary to solder a diode to the non bussed side of each switch, then solder this to one of the 10 wires in the cable, then repeat for each of the 6 cables, then repeat for the last wire (#61)
Step 6: Solder the resistor to the MIDI plug, and solder the other leads to the Arduino.
-Plug all of the headers into the Arduino as shown in the schematic.
-An alternative solution to soldering wires onto the male headers is to buy some ten pin IDC sockets, and connect these to the ends of the AWM cables, then use male to male jumpers to connect to the Arduino. While this solution isn't as permanent as soldering, it is advisable if you intend to try modifying the posted code, in case rewiring is necessary.
Step 8: Upload software to Arduino-Connect a USB cable from the Arduino to your computer, and ensure you have the Arduino software installed on your computer. Select the version of the code that applies to you (Matrixed vs. Bussed). Run the Arduino software, and copy and paste the provided code into a new blank sketch. Make sure the Arduino is connected via USB serial, and Click the "Upload" button at the top of the sketch.
Step 9: Test- If not done already, connect your MIDI adapter to the computer, and connect the organ MIDI out to the MIDI adapter.
- Using a software to monitor midi signals, make sure each key and pedal sends the appropriate MIDI message when you press the key, and depress each key.
- If you plan to use without being attached to your computer, you can attach a small 5v power supply to the power port of the Arduino, or attach a USB power plug to the end of the USB cable you used, and plug that into a wall outlet to power the Arduino.
- The code posted for bussed keyboards has not yet been tested, however it is expected to work. Please post in the comments if you have tried the bussed code and found some problem with it.
- Note that for the bussed version of the code, diodes are necessary for it to work properly. Also, when soldering the diodes onto the switches, it is important to solder the diode with the negative pole towards the switch. For the matrixed design, then negative pole of the diode should be away from the switch.
- Aside from adding the bussed design, I have also updated the original design and code to include potentiometers, such as those used in expression pedals.
- For the bussed design to work properly at pin 13, it is necessary to somehow disable the Arduino's built in LED. To do that, you can either remove it using two soldering irons, or use a pair of fine tipped pliers to carefully crush it.
- While the bussed design will work for many organs with a bussed keyboard, it may not work reliably if the bus is made of "phosphor bronze" material. Wiring all of the busses for a single manual together, and wiring all of the contacts for a single key together will help prevent intermittent contact, but for phosphor bronze bus bars, it is recommended to use 12V keying (which this project would not be able to do).
In the future, I hope to add more details about this, but for now I will briefly explain the design seen above. The connection to the expression pedal is an inexpensive "L" bracket available from a local hardware store. It is connected to an existing bracket here, but a second L bracket attached directly to the pedal can also be used. It articulates on a machine screw that is kept slightly loose by using a lock nut, and two washers. In the picture, I used a very long machine screw, but such a long one isn't needed, it just happened to be what I had on hand. For the metal rod, I used "JB weld" to attach an eye bolt to one end, and used an appropriate sized machine screw to attach it to the "L" bracket on the other end.
For the potentiometer mount itself, I purchased some clear acrylic sheets, scored them with a hobby knife, then broke them off along the line using pliers and clamps. To attach the potentiometer, I made a small piece of acrylic to elevate it off the larger piece, sanded the surface of the smaller piece of acrylic, and also sanded the surface of the potentiometer to be mounted, and the surface of the larger piece to which everything would be attached, then applied JB weld, and used a small clamp to hold everything together until the JB weld dried. The holes in the acrylic pieces were drilled with an electric drill and standard drill bits.
The bottom of the larger piece of acrylic is fastened to a small furniture hinge using #4 machine screws, and the other end of the furniture hinge is attached to the bottom of the organ using short #4 wood screws. I made an acrylic bracket to hold the furniture hinge off the wood floor, but depending on the design of the furniture hinge, that might not be necessary.
The white block that the rod slides through is a PFTE block that I bought from a robot parts supplier. The piece was cut off the larger piece using a hobby saw, and the three holes drilled using an electric drill and different size drill bits. The PFTE block was attached to the acrylic bracket using machine screws.
Detailed Instructions for expression pedal bracket:(Updated Dec. 9. 2021)
-8x10 inch acrylic sheet
-Teflon Block
-Aluminum rod (1/4 inch, available at local hardware or metal store)
-JB Weld
-Linear potentiometer
-Small furniture hinge
-Small furniture brace
-Small eye bolt
-Short #4 wood screws
-Assorted hardware:
-Lock washer X1 (preferably teflon) and matching machine screw to attach to pedal (diameter and length to match current pedal)
-Machine screws x2, washers x4 and nuts x2 to attach teflon to acrylic sheet (diameter and length depending on diameter of hole drilled)
-Machine screw to attach brace to 1/4 aluminum rod (diameter depending on the size of the internal hole)
-Machine screws x2, washers x4 and nuts x2 to attach hinge to bottom of acrylic sheet.
Tools:
-Hobby knife
-Straight edge
-Jeweler’s screwdriver/regular screwdriver (jewellers for the smallest screws)
-Crescent wrench (to tighten machine screws and nuts)
-Pliers
-Electric Drill and drill bits.
-Hobby saw
-Bench top vise
-Small wood clamp
-Fine grit sand paper
-Popsicle sticks and scrap cardboard.
-Damp cloth
Instructions:
-Examine current pedal. If there is a spare hole on the mounting bracket, you can use that, otherwise you can use an existing hole that is being used, and get a machine screw that is longer than the current one, but that will still fit in the hole.
-Make sure the wooden base of the organ is clear of any components or electronics, and move them if necessary.
-Unwrap the acrylic sheet, and using the straight edge and hobby knife, score the sheet on both sides into a 3” by 4.5” rectangle, then crack along the scoring lines to cut it using the bench top vise and the pliers (be sure to use eye protection!). Also cut a 3” by 0.5” piece, and a 2.4” by 0.3” piece.
-Cut the teflon block using the hobby saw approximately 3/4” off the end to create a 3’ by 1.5’ by 3/4 inch block.
-Drill 2 holes along the bottom edge of the large acrylic sheet so they match up with one side of the furniture hinge, and drill two holes on the 3x1.5 inch side of the teflon block so they are not in the way of the path the aluminum rod will take through it. Drill 2 holes that match up with the holes in the teflon block if the block is positioned at the top of the large acrylic sheet, opposite the holes previously drilled, with the edge of the teflon block right at the edge of the acrylic. Also drill 2 holes in the 2.4” by 0.3” piece so it matches up with the holes on the other side of the hinge.
-Gently sand one surface of the potentiometer, as well as the area on the large acrylic sheet to be glued, and both surfaces of the 3x0.5” piece of acrylic. Wipe off the surfaces with a damp cloth.
-Mix the JB weld on some scrap cardboard using a popsicle stick, then apply to the prepared surface of the acrylic sheet. Add the 3x0.5” piece, then add more JB weld, then the potentiometer, making sure JB weld is attached to a sanded surface. Gently clamp the assembly with a small wood clamp, and leave 24 hours to cure.
-Drill a hole slightly larger than 1/4 inch using a 1/4 inch drill bit by moving the bit around while it is in the block from one 3/4x3 inch side of the teflon block to the other. Drill it so that the line of the aluminum rod matches up with the line of the movement of the potentiometer.
-Cut the 1/4 inch aluminum rod so that it is roughly the correct length from the bottom of the potentiometer to the expression pedal when pushed fully down.
-Once the JB weld has cured, attach the hinge and the teflon block to the side of the large acrylic plate using machine screws, washers and nuts. Put the eye bolt on the movable part of the potentiometer, and attach it to the 1/4 inch aluminum rod moving through the teflon block. If the fit is a bit loose, you can also JB weld the eye bolt to the aluminum rod when applying JB weld in an earlier step. In that case, you will have to put the eye bolt on the potentiometer, move it through the teflon block, then attach the teflon block to the acrylic plate with machine screws after.
-Holding the eye bolt in the right position with pliers, attach the furniture brace to the other end of the 1/4 inch aluminum rod using a machine screw of the correct size. Make sure the eye bolt is in the right orientation to the furniture brace when it is tightened.
-If there is a free hole on the bracket of the potentiometer, put a new machine screw through it, then put on a teflon lock washer and tighten until the furniture bracket moves freely. If using an existing hole that is currently occupied by a prior machine screw, remove the old screw, and put in a new, longer screw, attach it as before, then on the extra length add the furniture bracket and a teflon lock washer.
-Move the bottom of the hinge back and forth on the bottom inside of the organ until it is in a position where the 1/4 inch aluminum rod is lined up straight, and with the smallest acrylic plate in place, the movement of the pedal approximates the movement of the potentiometer best. Attach the bottom of the potentiometer mount to the bottom of the organ using the 2 small wood screws, making sure the acrylic plate is between the hinge and the wood (this ensures proper travel of the hinge).
Update March 26, 2022:Since the first publication of this guide, I have been making some improvements to the original code.
-The main improvement is adding adjustable debounce to the keying. This was done because rarely, some instantaneous ciphers were observed on the development system (usually if someone was using the shower!). After discussion with regarding this issue with John Kinkennon (a contact of the author through the "Organ Forum." It may be because the Arduino internal pull-ups are sometimes slow to reset. The improved code appears to resolve the problem, and may also be a benefit to those trying to use this code in electrically noisy environments, since the debounce can be adjusted.
-In addition, the improved code adds a 12x6 matrix for the purpose of encoding pistons or other controls. If the matrix is used, then it needs to be wired according to the diagram on the schematic. Not all values in the arrays are used, so if wanting to wire more pistons than those found on my console, the code will have to be modified. To see what array values are used, refer to the code.
-In addition, I implemented Midi Thru according to an example posted by RIP Tutorial (see the reference to this web page in the credits section). This allows you to add one or more Arduinos connected via the outboard Tx to this arduino's Rx, with the grounds wired together. Any midi message sent by the other Arduino will be sent via this Arduino to the Midi Out port.
Update June 4, 2022: Notes on Midi Channel AssignmentsOne commenter sent me a private message on another platform asking about Midi assignment numbers, so I thought I would detail my approach in case it is useful to anyone. In the posted code, I use 144, 145, 146 as the byte definition for the Note on command on channel 1, 2, 3, and I use 128, 129, and 130 as the byte definition for Note off on channel 1, 2, and 3. For the control change/expression pedals, I use 181 and 182 as the control change command on channel 5 and 6.
So how does that work? Each midi message is sent as a byte, which has 8 positions, either 0 or 1 in binary. The first four digits of the byte tell the software what kind of command it is. The last four tell you what channel it is on. You can express this number as a hexadecimal, but I chose to use decimal.
144 stands for 10010000 in binary. The 1001 is the note on message, the 0000 is channel 1.
128 is 10000000. 1000 is note off, 0000 is channel 1, so 132 is channel 4, 133 is channel 5, etc.
181 is 10110101. 1011 is the control change message, 0101 is CC channel 5. 182 channel 6, 183 channel 7, etc.
Final note:Arduino Project Hub doesn't appear to have notification for posts and questions placed here. If you would like a speedier reply to your question, you can post it on this forum page, which will notify me.
Matrixed Keyboard code
Arduino// Name: Arduino Mega Midi Controller v21
// Created: Feb 4, 2021
// Author: Larason2
// Acknowledgements: Bald Engineer, Amanda Ghassaei, jeffb42, GrumpyMike
byte keysA[11][6];
byte keysB[11][6];
byte keysC[7][6];
byte lastA[11][6];
byte lastB[11][6];
byte lastC[7][6];
int noteOn1 = 144;
int noteOff1 = 128;
int noteOn2 = 145;
int noteOff2 = 129;
int noteOn3 = 146;
int noteOff3 = 130;
int velocity = 100;
int chan6 = 181;
int chan7 = 182;
int Exp = 11;
int LastPot6 = 1;
int LastPot7 = 1;
void setup() {
// Start Serial
Serial.begin(31250);
//Initialize Keyboard A
pinMode(2, INPUT);
pinMode(22, INPUT);
pinMode(24, INPUT);
pinMode(26, INPUT);
pinMode(28, INPUT);
pinMode(30, INPUT);
pinMode(32, INPUT);
pinMode(34, INPUT);
pinMode(36, INPUT);
pinMode(38, INPUT);
pinMode(40, INPUT);
pinMode(42, INPUT);
pinMode(44, INPUT);
pinMode(46, INPUT);
pinMode(48, INPUT);
pinMode(50, INPUT);
pinMode(52, INPUT);
//Initialize Keyboard B
pinMode(3, INPUT);
pinMode(23, INPUT);
pinMode(25, INPUT);
pinMode(27, INPUT);
pinMode(29, INPUT);
pinMode(31, INPUT);
pinMode(33, INPUT);
pinMode(35, INPUT);
pinMode(37, INPUT);
pinMode(39, INPUT);
pinMode(41, INPUT);
pinMode(43, INPUT);
pinMode(45, INPUT);
pinMode(47, INPUT);
pinMode(49, INPUT);
pinMode(51, INPUT);
pinMode(52, INPUT);
//Initialize Keyboard C
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
pinMode(A6, INPUT);
pinMode(A7, INPUT);
pinMode(A8, INPUT);
pinMode(A9, INPUT);
pinMode(A10, INPUT);
pinMode(A11, INPUT);
pinMode(A12, INPUT);
pinMode(A13, INPUT);
pinMode(A14, INPUT);
}
void loop() {
// Read Keyboard A
pinMode(22, INPUT_PULLUP);
pinMode(24, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
pinMode(28, INPUT_PULLUP);
pinMode(30, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(32, OUTPUT);
digitalWrite(32, LOW);
keysA[0][0] = digitalRead(2);
pinMode(32, INPUT);
pinMode(34, OUTPUT);
digitalWrite(34, LOW);
keysA[1][0] = digitalRead(22);
keysA[1][1] = digitalRead(24);
keysA[1][2] = digitalRead(26);
keysA[1][3] = digitalRead(28);
keysA[1][4] = digitalRead(30);
keysA[1][5] = digitalRead(2);
pinMode(34, INPUT);
pinMode(36, OUTPUT);
digitalWrite(36, LOW);
keysA[2][0] = digitalRead(22);
keysA[2][1] = digitalRead(24);
keysA[2][2] = digitalRead(26);
keysA[2][3] = digitalRead(28);
keysA[2][4] = digitalRead(30);
keysA[2][5] = digitalRead(2);
pinMode(36, INPUT);
pinMode(38, OUTPUT);
digitalWrite(38, LOW);
keysA[3][0] = digitalRead(22);
keysA[3][1] = digitalRead(24);
keysA[3][2] = digitalRead(26);
keysA[3][3] = digitalRead(28);
keysA[3][4] = digitalRead(30);
keysA[3][5] = digitalRead(2);
pinMode(38, INPUT);
pinMode(40, OUTPUT);
digitalWrite(40, LOW);
keysA[4][0] = digitalRead(22);
keysA[4][1] = digitalRead(24);
keysA[4][2] = digitalRead(26);
keysA[4][3] = digitalRead(28);
keysA[4][4] = digitalRead(30);
keysA[4][5] = digitalRead(2);
pinMode(40, INPUT);
pinMode(42, OUTPUT);
digitalWrite(42, LOW);
keysA[5][0] = digitalRead(22);
keysA[5][1] = digitalRead(24);
keysA[5][2] = digitalRead(26);
keysA[5][3] = digitalRead(28);
keysA[5][4] = digitalRead(30);
keysA[5][5] = digitalRead(2);
pinMode(42, INPUT);
pinMode(44, OUTPUT);
digitalWrite(44, LOW);
keysA[6][0] = digitalRead(22);
keysA[6][1] = digitalRead(24);
keysA[6][2] = digitalRead(26);
keysA[6][3] = digitalRead(28);
keysA[6][4] = digitalRead(30);
keysA[6][5] = digitalRead(2);
pinMode(44, INPUT);
pinMode(46, OUTPUT);
digitalWrite(46, LOW);
keysA[7][0] = digitalRead(22);
keysA[7][1] = digitalRead(24);
keysA[7][2] = digitalRead(26);
keysA[7][3] = digitalRead(28);
keysA[7][4] = digitalRead(30);
keysA[7][5] = digitalRead(2);
pinMode(46, INPUT);
pinMode(48, OUTPUT);
digitalWrite(48, LOW);
keysA[8][0] = digitalRead(22);
keysA[8][1] = digitalRead(24);
keysA[8][2] = digitalRead(26);
keysA[8][3] = digitalRead(28);
keysA[8][4] = digitalRead(30);
keysA[8][5] = digitalRead(2);
pinMode(48, INPUT);
pinMode(50, OUTPUT);
digitalWrite(50, LOW);
keysA[9][0] = digitalRead(22);
keysA[9][1] = digitalRead(24);
keysA[9][2] = digitalRead(26);
keysA[9][3] = digitalRead(28);
keysA[9][4] = digitalRead(30);
keysA[9][5] = digitalRead(2);
pinMode(50, INPUT);
pinMode(52, OUTPUT);
digitalWrite(52, LOW);
keysA[10][0] = digitalRead(22);
keysA[10][1] = digitalRead(24);
keysA[10][2] = digitalRead(26);
keysA[10][3] = digitalRead(28);
keysA[10][4] = digitalRead(30);
keysA[10][5] = digitalRead(2);
pinMode(52, INPUT);
pinMode(22, INPUT);
pinMode(24, INPUT);
pinMode(26, INPUT);
pinMode(28, INPUT);
pinMode(30, INPUT);
pinMode(2, INPUT);
// Read Keyboard B
pinMode(23, INPUT_PULLUP);
pinMode(25, INPUT_PULLUP);
pinMode(27, INPUT_PULLUP);
pinMode(29, INPUT_PULLUP);
pinMode(31, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(33, OUTPUT);
digitalWrite(33, LOW);
keysB[0][0] = digitalRead(3);
pinMode(33, INPUT);
pinMode(35, OUTPUT);
digitalWrite(35, LOW);
keysB[1][0] = digitalRead(23);
keysB[1][1] = digitalRead(25);
keysB[1][2] = digitalRead(27);
keysB[1][3] = digitalRead(29);
keysB[1][4] = digitalRead(31);
keysB[1][5] = digitalRead(3);
pinMode(35, INPUT);
pinMode(37, OUTPUT);
digitalWrite(37, LOW);
keysB[2][0] = digitalRead(23);
keysB[2][1] = digitalRead(25);
keysB[2][2] = digitalRead(27);
keysB[2][3] = digitalRead(29);
keysB[2][4] = digitalRead(31);
keysB[2][5] = digitalRead(3);
pinMode(37, INPUT);
pinMode(39, OUTPUT);
digitalWrite(39, LOW);
keysB[3][0] = digitalRead(23);
keysB[3][1] = digitalRead(25);
keysB[3][2] = digitalRead(27);
keysB[3][3] = digitalRead(29);
keysB[3][4] = digitalRead(31);
keysB[3][5] = digitalRead(3);
pinMode(39, INPUT);
pinMode(41, OUTPUT);
digitalWrite(41, LOW);
keysB[4][0] = digitalRead(23);
keysB[4][1] = digitalRead(25);
keysB[4][2] = digitalRead(27);
keysB[4][3] = digitalRead(29);
keysB[4][4] = digitalRead(31);
keysB[4][5] = digitalRead(3);
pinMode(41, INPUT);
pinMode(43, OUTPUT);
digitalWrite(43, LOW);
keysB[5][0] = digitalRead(23);
keysB[5][1] = digitalRead(25);
keysB[5][2] = digitalRead(27);
keysB[5][3] = digitalRead(29);
keysB[5][4] = digitalRead(31);
keysB[5][5] = digitalRead(3);
pinMode(43, INPUT);
pinMode(45, OUTPUT);
digitalWrite(45, LOW);
keysB[6][0] = digitalRead(23);
keysB[6][1] = digitalRead(25);
keysB[6][2] = digitalRead(27);
keysB[6][3] = digitalRead(29);
keysB[6][4] = digitalRead(31);
keysB[6][5] = digitalRead(3);
pinMode(45, INPUT);
pinMode(47, OUTPUT);
digitalWrite(47, LOW);
keysB[7][0] = digitalRead(23);
keysB[7][1] = digitalRead(25);
keysB[7][2] = digitalRead(27);
keysB[7][3] = digitalRead(29);
keysB[7][4] = digitalRead(31);
keysB[7][5] = digitalRead(3);
pinMode(47, INPUT);
pinMode(49, OUTPUT);
digitalWrite(49, LOW);
keysB[8][0] = digitalRead(23);
keysB[8][1] = digitalRead(25);
keysB[8][2] = digitalRead(27);
keysB[8][3] = digitalRead(29);
keysB[8][4] = digitalRead(31);
keysB[8][5] = digitalRead(3);
pinMode(49, INPUT);
pinMode(51, OUTPUT);
digitalWrite(51, LOW);
keysB[9][0] = digitalRead(23);
keysB[9][1] = digitalRead(25);
keysB[9][2] = digitalRead(27);
keysB[9][3] = digitalRead(29);
keysB[9][4] = digitalRead(31);
keysB[9][5] = digitalRead(3);
pinMode(51, INPUT);
pinMode(53, OUTPUT);
digitalWrite(53, LOW);
keysB[10][0] = digitalRead(23);
keysB[10][1] = digitalRead(25);
keysB[10][2] = digitalRead(27);
keysB[10][3] = digitalRead(29);
keysB[10][4] = digitalRead(31);
keysB[10][5] = digitalRead(3);
pinMode(53, INPUT);
pinMode(23, INPUT);
pinMode(25, INPUT);
pinMode(27, INPUT);
pinMode(29, INPUT);
pinMode(31, INPUT);
pinMode(3, INPUT);
// Read Keyboard C
//Set Row pins to read
pinMode(A3, INPUT_PULLUP);
pinMode(A4, INPUT_PULLUP);
pinMode(A5, INPUT_PULLUP);
pinMode(A6, INPUT_PULLUP);
pinMode(A7, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);
pinMode(A8, OUTPUT);
digitalWrite(A8, LOW);
keysC[0][0] = digitalRead(A2);
pinMode(A8, INPUT);
pinMode(A9, OUTPUT);
digitalWrite(A9, LOW);
keysC[1][0] = digitalRead(A3);
keysC[1][1] = digitalRead(A4);
keysC[1][2] = digitalRead(A5);
keysC[1][3] = digitalRead(A6);
keysC[1][4] = digitalRead(A7);
keysC[1][5] = digitalRead(A2);
pinMode(A9, INPUT);
pinMode(A10, OUTPUT);
digitalWrite(A10, LOW);
keysC[2][0] = digitalRead(A3);
keysC[2][1] = digitalRead(A4);
keysC[2][2] = digitalRead(A5);
keysC[2][3] = digitalRead(A6);
keysC[2][4] = digitalRead(A7);
keysC[2][5] = digitalRead(A2);
pinMode(A10, INPUT);
pinMode(A11, OUTPUT);
digitalWrite(A11, LOW);
keysC[3][0] = digitalRead(A3);
keysC[3][1] = digitalRead(A4);
keysC[3][2] = digitalRead(A5);
keysC[3][3] = digitalRead(A6);
keysC[3][4] = digitalRead(A7);
keysC[3][5] = digitalRead(A2);
pinMode(A11, INPUT);
pinMode(A12, OUTPUT);
digitalWrite(A12, LOW);
keysC[4][0] = digitalRead(A3);
keysC[4][1] = digitalRead(A4);
keysC[4][2] = digitalRead(A5);
keysC[4][3] = digitalRead(A6);
keysC[4][4] = digitalRead(A7);
keysC[4][5] = digitalRead(A2);
pinMode(A12, INPUT);
pinMode(A13, OUTPUT);
digitalWrite(A13, LOW);
keysC[5][0] = digitalRead(A3);
keysC[5][1] = digitalRead(A4);
keysC[5][2] = digitalRead(A5);
keysC[5][3] = digitalRead(A6);
keysC[5][4] = digitalRead(A7);
keysC[5][5] = digitalRead(A2);
pinMode(A13, INPUT);
pinMode(A14, OUTPUT);
digitalWrite(A14, LOW);
keysC[6][0] = digitalRead(A3);
pinMode(A14, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
pinMode(A6, INPUT);
pinMode(A7, INPUT);
pinMode(A2, INPUT);
//Invert Keyboard C data
//(For switches that are Normally Closed)
//Column 1
if (keysC[0][0] == 0) {
keysC[0][0] = 1;
}
else
if (keysC[0][0] == 1) {
keysC[0][0] = 0;
}
//Column 2
if (keysC[1][0] == 0) {
keysC[1][0] = 1;
}
else
if (keysC[1][0] == 1) {
keysC[1][0] = 0;
}
if (keysC[1][1] == 0) {
keysC[1][1] = 1;
}
else
if (keysC[1][1] == 1) {
keysC[1][1] = 0;
}
if (keysC[1][2] == 0) {
keysC[1][2] = 1;
}
else
if (keysC[1][2] == 1) {
keysC[1][2] = 0;
}
if (keysC[1][3] == 0) {
keysC[1][3] = 1;
}
else
if (keysC[1][3] == 1) {
keysC[1][3] = 0;
}
if (keysC[1][4] == 0) {
keysC[1][4] = 1;
}
else
if (keysC[1][4] == 1) {
keysC[1][4] = 0;
}
if (keysC[1][5] == 0) {
keysC[1][5] = 1;
}
else
if (keysC[1][5] == 1) {
keysC[1][5] = 0;
}
//Column 3
if (keysC[2][0] == 0) {
keysC[2][0] = 1;
}
else
if (keysC[2][0] == 1) {
keysC[2][0] = 0;
}
if (keysC[2][1] == 0) {
keysC[2][1] = 1;
}
else
if (keysC[2][1] == 1) {
keysC[2][1] = 0;
}
if (keysC[2][2] == 0) {
keysC[2][2] = 1;
}
else
if (keysC[2][2] == 1) {
keysC[2][2] = 0;
}
if (keysC[2][3] == 0) {
keysC[2][3] = 1;
}
else
if (keysC[2][3] == 1) {
keysC[2][3] = 0;
}
if (keysC[2][4] == 0) {
keysC[2][4] = 1;
}
else
if (keysC[2][4] == 1) {
keysC[2][4] = 0;
}
if (keysC[2][5] == 0) {
keysC[2][5] = 1;
}
else
if (keysC[2][5] == 1) {
keysC[2][5] = 0;
}
//Column 4
if (keysC[3][0] == 0) {
keysC[3][0] = 1;
}
else
if (keysC[3][0] == 1) {
keysC[3][0] = 0;
}
if (keysC[3][1] == 0) {
keysC[3][1] = 1;
}
else
if (keysC[3][1] == 1) {
keysC[3][1] = 0;
}
if (keysC[3][2] == 0) {
keysC[3][2] = 1;
}
else
if (keysC[3][2] == 1) {
keysC[3][2] = 0;
}
if (keysC[3][3] == 0) {
keysC[3][3] = 1;
}
else
if (keysC[3][3] == 1) {
keysC[3][3] = 0;
}
if (keysC[3][4] == 0) {
keysC[3][4] = 1;
}
else
if (keysC[3][4] == 1) {
keysC[3][4] = 0;
}
if (keysC[3][5] == 0) {
keysC[3][5] = 1;
}
else
if (keysC[3][5] == 1) {
keysC[3][5] = 0;
}
//Column 5
if (keysC[4][0] == 0) {
keysC[4][0] = 1;
}
else
if (keysC[4][0] == 1) {
keysC[4][0] = 0;
}
if (keysC[4][1] == 0) {
keysC[4][1] = 1;
}
else
if (keysC[4][1] == 1) {
keysC[4][1] = 0;
}
if (keysC[4][2] == 0) {
keysC[4][2] = 1;
}
else
if (keysC[4][2] == 1) {
keysC[4][2] = 0;
}
if (keysC[4][3] == 0) {
keysC[4][3] = 1;
}
else
if (keysC[4][3] == 1) {
keysC[4][3] = 0;
}
if (keysC[4][4] == 0) {
keysC[4][4] = 1;
}
else
if (keysC[4][4] == 1) {
keysC[4][4] = 0;
}
if (keysC[4][5] == 0) {
keysC[4][5] = 1;
}
else
if (keysC[4][5] == 1) {
keysC[4][5] = 0;
}
//Column 6
if (keysC[5][0] == 0) {
keysC[5][0] = 1;
}
else
if (keysC[5][0] == 1) {
keysC[5][0] = 0;
}
if (keysC[5][1] == 0) {
keysC[5][1] = 1;
}
else
if (keysC[5][1] == 1) {
keysC[5][1] = 0;
}
if (keysC[5][2] == 0) {
keysC[5][2] = 1;
}
else
if (keysC[5][2] == 1) {
keysC[5][2] = 0;
}
if (keysC[5][3] == 0) {
keysC[5][3] = 1;
}
else
if (keysC[5][3] == 1) {
keysC[5][3] = 0;
}
if (keysC[5][4] == 0) {
keysC[5][4] = 1;
}
else
if (keysC[5][4] == 1) {
keysC[5][4] = 0;
}
if (keysC[5][5] == 0) {
keysC[5][5] = 1;
}
else
if (keysC[5][5] == 1) {
keysC[5][5] = 0;
}
//Column 7
if (keysC[6][0] == 0) {
keysC[6][0] = 1;
}
else
if (keysC[6][0] == 1) {
keysC[6][0] = 0;
}
//Write Keyboard A
//A36
if ((keysA[0][0] == 0) and (lastA[0][0] == 0)) {
MidiSend(noteOn1, 36, velocity);
lastA[0][0] = 7;
}
if ((keysA[0][0] == 1) and (lastA[0][0] == 7)) {
MidiSend(noteOff1, 36, velocity);
lastA[0][0] = 0;
}
//A37
if ((keysA[1][0] == 0) and (lastA[1][0] == 0)) {
MidiSend(noteOn1, 37, velocity);
lastA[1][0] = 7;
}
if ((keysA[1][0] == 1) and (lastA[1][0] == 7)) {
MidiSend(noteOff1, 37, velocity);
lastA[1][0] = 0;
}
//A38
if ((keysA[1][1] == 0) and (lastA[1][1] == 0)) {
MidiSend(noteOn1, 38, velocity);
lastA[1][1] = 7;
}
//Write Midi Note Off
if ((keysA[1][1] == 1) and (lastA[1][1] == 7)) {
MidiSend(noteOff1, 38, velocity);
lastA[1][1] = 0;
}
//A39
if ((keysA[1][2] == 0) and (lastA[1][2] == 0)) {
MidiSend(noteOn1, 39, velocity);
lastA[1][2] = 7;
}
//Write Midi Note Off
if ((keysA[1][2] == 1) and (lastA[1][2] == 7)) {
MidiSend(noteOff1, 39, velocity);
lastA[1][2] = 0;
}
//A40
if ((keysA[1][3] == 0) and (lastA[1][3] == 0)) {
MidiSend(noteOn1, 40, velocity);
lastA[1][3] = 7;
}
//Write Midi Note Off
if ((keysA[1][3] == 1) and (lastA[1][3] == 7)) {
MidiSend(noteOff1, 40, velocity);
lastA[1][3] = 0;
}
//A41
if ((keysA[1][4] == 0) and (lastA[1][4] == 0)) {
MidiSend(noteOn1, 41, velocity);
lastA[1][4] = 7;
}
//Write Midi Note Off
if ((keysA[1][4] == 1) and (lastA[1][4] == 7)) {
MidiSend(noteOff1, 41, velocity);
lastA[1][4] = 0;
}
//A42
if ((keysA[1][5] == 0) and (lastA[1][5] == 0)) {
MidiSend(noteOn1, 42, velocity);
lastA[1][5] = 7;
}
//Write Midi Note Off
if ((keysA[1][5] == 1) and (lastA[1][5] == 7)) {
MidiSend(noteOff1, 42, velocity);
lastA[1][5] = 0;
}
//A43
if ((keysA[2][0] == 0) and (lastA[2][0] == 0)) {
MidiSend(noteOn1, 43, velocity);
lastA[2][0] = 7;
}
//Write Midi Note Off
if ((keysA[2][0] == 1) and (lastA[2][0] == 7)) {
MidiSend(noteOff1, 43, velocity);
lastA[2][0] = 0;
}
//A44
if ((keysA[2][1] == 0) and (lastA[2][1] == 0)) {
MidiSend(noteOn1, 44, velocity);
lastA[2][1] = 7;
}
//Write Midi Note Off
if ((keysA[2][1] == 1) and (lastA[2][1] == 7)) {
MidiSend(noteOff1, 44, velocity);
lastA[2][1] = 0;
}
//A45
if ((keysA[2][2] == 0) and (lastA[2][2] == 0)) {
MidiSend(noteOn1, 45, velocity);
lastA[2][2] = 7;
}
//Write Midi Note Off
if ((keysA[2][2] == 1) and (lastA[2][2] == 7)) {
MidiSend(noteOff1, 45, velocity);
lastA[2][2] = 0;
}
//A46
if ((keysA[2][3] == 0) and (lastA[2][3] == 0)) {
MidiSend(noteOn1, 46, velocity);
lastA[2][3] = 7;
}
//Write Midi Note Off
if ((keysA[2][3] == 1) and (lastA[2][3] == 7)) {
MidiSend(noteOff1, 46, velocity);
lastA[2][3] = 0;
}
//A47
if ((keysA[2][4] == 0) and (lastA[2][4] == 0)) {
MidiSend(noteOn1, 47, velocity);
lastA[2][4] = 7;
}
//Write Midi Note Off
if ((keysA[2][4] == 1) and (lastA[2][4] == 7)) {
MidiSend(noteOff1, 47, velocity);
lastA[2][4] = 0;
}
//A48
if ((keysA[2][5] == 0) and (lastA[2][5] == 0)) {
MidiSend(noteOn1, 48, velocity);
lastA[2][5] = 7;
}
//Write Midi Note Off
if ((keysA[2][5] == 1) and (lastA[2][5] == 7)) {
MidiSend(noteOff1, 48, velocity);
lastA[2][5] = 0;
}
//A49
if ((keysA[3][0] == 0) and (lastA[3][0] == 0)) {
MidiSend(noteOn1, 49, velocity);
lastA[3][0] = 7;
}
//Write Midi Note Off
if ((keysA[3][0] == 1) and (lastA[3][0] == 7)) {
MidiSend(noteOff1, 49, velocity);
lastA[3][0] = 0;
}
//A50
if ((keysA[3][1] == 0) and (lastA[3][1] == 0)) {
MidiSend(noteOn1, 50, velocity);
lastA[3][1] = 7;
}
//Write Midi Note Off
if ((keysA[3][1] == 1) and (lastA[3][1] == 7)) {
MidiSend(noteOff1, 50, velocity);
lastA[3][1] = 0;
}
//A51
if ((keysA[3][2] == 0) and (lastA[3][2] == 0)) {
MidiSend(noteOn1, 51, velocity);
lastA[3][2] = 7;
}
//Write Midi Note Off
if ((keysA[3][2] == 1) and (lastA[3][2] == 7)) {
MidiSend(noteOff1, 51, velocity);
lastA[3][2] = 0;
}
//A52
if ((keysA[3][3] == 0) and (lastA[3][3] == 0)) {
MidiSend(noteOn1, 52, velocity);
lastA[3][3] = 7;
}
//Write Midi Note Off
if ((keysA[3][3] == 1) and (lastA[3][3] == 7)) {
MidiSend(noteOff1, 52, velocity);
lastA[3][3] = 0;
}
//A53
if ((keysA[3][4] == 0) and (lastA[3][4] == 0)) {
MidiSend(noteOn1, 53, velocity);
lastA[3][4] = 7;
}
//Write Midi Note Off
if ((keysA[3][4] == 1) and (lastA[3][4] == 7)) {
MidiSend(noteOff1, 53, velocity);
lastA[3][4] = 0;
}
//A54
if ((keysA[3][5] == 0) and (lastA[3][5] == 0)) {
MidiSend(noteOn1, 54, velocity);
lastA[3][5] = 7;
}
//Write Midi Note Off
if ((keysA[3][5] == 1) and (lastA[3][5] == 7)) {
MidiSend(noteOff1, 54, velocity);
lastA[3][5] = 0;
}
//A55
if ((keysA[4][0] == 0) and (lastA[4][0] == 0)) {
MidiSend(noteOn1, 55, velocity);
lastA[4][0] = 7;
}
//Write Midi Note Off
if ((keysA[4][0] == 1) and (lastA[4][0] == 7)) {
MidiSend(noteOff1, 55, velocity);
lastA[4][0] = 0;
}
//A56
if ((keysA[4][1] == 0) and (lastA[4][1] == 0)) {
MidiSend(noteOn1, 56, velocity);
lastA[4][1] = 7;
}
//Write Midi Note Off
if ((keysA[4][1] == 1) and (lastA[4][1] == 7)) {
MidiSend(noteOff1, 56, velocity);
lastA[4][1] = 0;
}
//A57
if ((keysA[4][2] == 0) and (lastA[4][2] == 0)) {
MidiSend(noteOn1, 57, velocity);
lastA[4][2] = 7;
}
//Write Midi Note Off
if ((keysA[4][2] == 1) and (lastA[4][2] == 7)) {
MidiSend(noteOff1, 57, velocity);
lastA[4][2] = 0;
}
//A58
if ((keysA[4][3] == 0) and (lastA[4][3] == 0)) {
MidiSend(noteOn1, 58, velocity);
lastA[4][3] = 7;
}
//Write Midi Note Off
if ((keysA[4][3] == 1) and (lastA[4][3] == 7)) {
MidiSend(noteOff1, 58, velocity);
lastA[4][3] = 0;
}
//59
if ((keysA[4][4] == 0) and (lastA[4][4] == 0)) {
MidiSend(noteOn1, 59, velocity);
lastA[4][4] = 7;
}
//Write Midi Note Off
if ((keysA[4][4] == 1) and (lastA[4][4] == 7)) {
MidiSend(noteOff1, 59, velocity);
lastA[4][4] = 0;
}
//A60
if ((keysA[4][5] == 0) and (lastA[4][5] == 0)) {
MidiSend(noteOn1, 60, velocity);
lastA[4][5] = 7;
}
//Write Midi Note Off
if ((keysA[4][5] == 1) and (lastA[4][5] == 7)) {
MidiSend(noteOff1, 60, velocity);
lastA[4][5] = 0;
}
//A61
if ((keysA[5][0] == 0) and (lastA[5][0] == 0)) {
MidiSend(noteOn1, 61, velocity);
lastA[5][0] = 7;
}
//Write Midi Note Off
if ((keysA[5][0] == 1) and (lastA[5][0] == 7)) {
MidiSend(noteOff1, 61, velocity);
lastA[5][0] = 0;
}
//A62
if ((keysA[5][1] == 0) and (lastA[5][1] == 0)) {
MidiSend(noteOn1, 62, velocity);
lastA[5][1] = 7;
}
//Write Midi Note Off
if ((keysA[5][1] == 1) and (lastA[5][1] == 7)) {
MidiSend(noteOff1, 62, velocity);
lastA[5][1] = 0;
}
//A63
if ((keysA[5][2] == 0) and (lastA[5][2] == 0)) {
MidiSend(noteOn1, 63, velocity);
lastA[5][2] = 7;
}
//Write Midi Note Off
if ((keysA[5][2] == 1) and (lastA[5][2] == 7)) {
MidiSend(noteOff1, 63, velocity);
lastA[5][2] = 0;
}
//A64
if ((keysA[5][3] == 0) and (lastA[5][3] == 0)) {
MidiSend(noteOn1, 64, velocity);
lastA[5][3] = 7;
}
//Write Midi Note Off
if ((keysA[5][3] == 1) and (lastA[5][3] == 7)) {
MidiSend(noteOff1, 64, velocity);
lastA[5][3] = 0;
}
//A65
if ((keysA[5][4] == 0) and (lastA[5][4] == 0)) {
MidiSend(noteOn1, 65, velocity);
lastA[5][4] = 7;
}
//Write Midi Note Off
if ((keysA[5][4] == 1) and (lastA[5][4] == 7)) {
MidiSend(noteOff1, 65, velocity);
lastA[5][4] = 0;
}
//A66
if ((keysA[5][5] == 0) and (lastA[5][5] == 0)) {
MidiSend(noteOn1, 66, velocity);
lastA[5][5] = 7;
}
//Write Midi Note Off
if ((keysA[5][5] == 1) and (lastA[5][5] == 7)) {
MidiSend(noteOff1, 66, velocity);
lastA[5][5] = 0;
}
//A67
if ((keysA[6][0] == 0) and (lastA[6][0] == 0)) {
MidiSend(noteOn1, 67, velocity);
lastA[6][0] = 7;
}
//Write Midi Note Off
if ((keysA[6][0] == 1) and (lastA[6][0] == 7)) {
MidiSend(noteOff1, 67, velocity);
lastA[6][0] = 0;
}
//A68
if ((keysA[6][1] == 0) and (lastA[6][1] == 0)) {
MidiSend(noteOn1, 68, velocity);
lastA[6][1] = 7;
}
//Write Midi Note Off
if ((keysA[6][1] == 1) and (lastA[6][1] == 7)) {
MidiSend(noteOff1, 68, velocity);
lastA[6][1] = 0;
}
//A69
if ((keysA[6][2] == 0) and (lastA[6][2] == 0)) {
MidiSend(noteOn1, 69, velocity);
lastA[6][2] = 7;
}
//Write Midi Note Off
if ((keysA[6][2] == 1) and (lastA[6][2] == 7)) {
MidiSend(noteOff1, 69, velocity);
lastA[6][2] = 0;
}
//A70
if ((keysA[6][3] == 0) and (lastA[6][3] == 0)) {
MidiSend(noteOn1, 70, velocity);
lastA[6][3] = 7;
}
//Write Midi Note Off
if ((keysA[6][3] == 1) and (lastA[6][3] == 7)) {
MidiSend(noteOff1, 70, velocity);
lastA[6][3] = 0;
}
//A71
if ((keysA[6][4] == 0) and (lastA[6][4] == 0)) {
MidiSend(noteOn1, 71, velocity);
lastA[6][4] = 7;
}
//Write Midi Note Off
if ((keysA[6][4] == 1) and (lastA[6][4] == 7)) {
MidiSend(noteOff1, 71, velocity);
lastA[6][4] = 0;
}
//A72
if ((keysA[6][5] == 0) and (lastA[6][5] == 0)) {
MidiSend(noteOn1, 72, velocity);
lastA[6][5] = 7;
}
//Write Midi Note Off
if ((keysA[6][5] == 1) and (lastA[6][5] == 7)) {
MidiSend(noteOff1, 72, velocity);
lastA[6][5] = 0;
}
//A73
if ((keysA[7][0] == 0) and (lastA[7][0] == 0)) {
MidiSend(noteOn1, 73, velocity);
lastA[7][0] = 7;
}
//Write Midi Note Off
if ((keysA[7][0] == 1) and (lastA[7][0] == 7)) {
MidiSend(noteOff1, 73, velocity);
lastA[7][0] = 0;
}
//A74
if ((keysA[7][1] == 0) and (lastA[7][1] == 0)) {
MidiSend(noteOn1, 74, velocity);
lastA[7][1] = 7;
}
//Write Midi Note Off
if ((keysA[7][1] == 1) and (lastA[7][1] == 7)) {
MidiSend(noteOff1, 74, velocity);
lastA[7][1] = 0;
}
//A75
if ((keysA[7][2] == 0) and (lastA[7][2] == 0)) {
MidiSend(noteOn1, 75, velocity);
lastA[7][2] = 7;
}
//Write Midi Note Off
if ((keysA[7][2] == 1) and (lastA[7][2] == 7)) {
MidiSend(noteOff1, 75, velocity);
lastA[7][2] = 0;
}
//A76
if ((keysA[7][3] == 0) and (lastA[7][3] == 0)) {
MidiSend(noteOn1, 76, velocity);
lastA[7][3] = 7;
}
//Write Midi Note Off
if ((keysA[7][3] == 1) and (lastA[7][3] == 7)) {
MidiSend(noteOff1, 76, velocity);
lastA[7][3] = 0;
}
//A77
if ((keysA[7][4] == 0) and (lastA[7][4] == 0)) {
MidiSend(noteOn1, 77, velocity);
lastA[7][4] = 7;
}
//Write Midi Note Off
if ((keysA[7][4] == 1) and (lastA[7][4] == 7)) {
MidiSend(noteOff1, 77, velocity);
lastA[7][4] = 0;
}
//A78
if ((keysA[7][5] == 0) and (lastA[7][5] == 0)) {
MidiSend(noteOn1, 78, velocity);
lastA[7][5] = 7;
}
//Write Midi Note Off
if ((keysA[7][5] == 1) and (lastA[7][5] == 7)) {
MidiSend(noteOff1, 78, velocity);
lastA[7][5] = 0;
}
//A79
if ((keysA[8][0] == 0) and (lastA[8][0] == 0)) {
MidiSend(noteOn1, 79, velocity);
lastA[8][0] = 7;
}
//Write Midi Note Off
if ((keysA[8][0] == 1) and (lastA[8][0] == 7)) {
MidiSend(noteOff1, 79, velocity);
lastA[8][0] = 0;
}
//A80
if ((keysA[8][1] == 0) and (lastA[8][1] == 0)) {
MidiSend(noteOn1, 80, velocity);
lastA[8][1] = 7;
}
//Write Midi Note Off
if ((keysA[8][1] == 1) and (lastA[8][1] == 7)) {
MidiSend(noteOff1, 80, velocity);
lastA[8][1] = 0;
}
//A81
if ((keysA[8][2] == 0) and (lastA[8][2] == 0)) {
MidiSend(noteOn1, 81, velocity);
lastA[8][2] = 7;
}
//Write Midi Note Off
if ((keysA[8][2] == 1) and (lastA[8][2] == 7)) {
MidiSend(noteOff1, 81, velocity);
lastA[8][2] = 0;
}
//A82
if ((keysA[8][3] == 0) and (lastA[8][3] == 0)) {
MidiSend(noteOn1, 82, velocity);
lastA[8][3] = 7;
}
//Write Midi Note Off
if ((keysA[8][3] == 1) and (lastA[8][3] == 7)) {
MidiSend(noteOff1, 82, velocity);
lastA[8][3] = 0;
}
//A83
if ((keysA[8][4] == 0) and (lastA[8][4] == 0)) {
MidiSend(noteOn1, 83, velocity);
lastA[8][4] = 7;
}
//Write Midi Note Off
if ((keysA[8][4] == 1) and (lastA[8][4] == 7)) {
MidiSend(noteOff1, 83, velocity);
lastA[8][4] = 0;
}
//A84
if ((keysA[8][5] == 0) and (lastA[8][5] == 0)) {
MidiSend(noteOn1, 84, velocity);
lastA[8][5] = 7;
}
//Write Midi Note Off
if ((keysA[8][5] == 1) and (lastA[8][5] == 7)) {
MidiSend(noteOff1, 84, velocity);
lastA[8][5] = 0;
}
//A85
if ((keysA[9][0] == 0) and (lastA[9][0] == 0)) {
MidiSend(noteOn1, 85, velocity);
lastA[9][0] = 7;
}
//Write Midi Note Off
if ((keysA[9][0] == 1) and (lastA[9][0] == 7)) {
MidiSend(noteOff1, 85, velocity);
lastA[9][0] = 0;
}
//A86
if ((keysA[9][1] == 0) and (lastA[9][1] == 0)) {
MidiSend(noteOn1, 86, velocity);
lastA[9][1] = 7;
}
//Write Midi Note Off
if ((keysA[9][1] == 1) and (lastA[9][1] == 7)) {
MidiSend(noteOff1, 86, velocity);
lastA[9][1] = 0;
}
//A87
if ((keysA[9][2] == 0) and (lastA[9][2] == 0)) {
MidiSend(noteOn1, 87, velocity);
lastA[9][2] = 7;
}
//Write Midi Note Off
if ((keysA[9][2] == 1) and (lastA[9][2] == 7)) {
MidiSend(noteOff1, 87, velocity);
lastA[9][2] = 0;
}
//A88
if ((keysA[9][3] == 0) and (lastA[9][3] == 0)) {
MidiSend(noteOn1, 88, velocity);
lastA[9][3] = 7;
}
//Write Midi Note Off
if ((keysA[9][3] == 1) and (lastA[9][3] == 7)) {
MidiSend(noteOff1, 88, velocity);
lastA[9][3] = 0;
}
//A89
if ((keysA[9][4] == 0) and (lastA[9][4] == 0)) {
MidiSend(noteOn1, 89, velocity);
lastA[9][4] = 7;
}
//Write Midi Note Off
if ((keysA[9][4] == 1) and (lastA[9][4] == 7)) {
MidiSend(noteOff1, 89, velocity);
lastA[9][4] = 0;
}
//A90
if ((keysA[9][5] == 0) and (lastA[9][5] == 0)) {
MidiSend(noteOn1, 90, velocity);
lastA[9][5] = 7;
}
//Write Midi Note Off
if ((keysA[9][5] == 1) and (lastA[9][5] == 7)) {
MidiSend(noteOff1, 90, velocity);
lastA[9][5] = 0;
}
//A91
if ((keysA[10][0] == 0) and (lastA[10][0] == 0)) {
MidiSend(noteOn1, 91, velocity);
lastA[10][0] = 7;
}
//Write Midi Note Off
if ((keysA[10][0] == 1) and (lastA[10][0] == 7)) {
MidiSend(noteOff1, 91, velocity);
lastA[10][0] = 0;
}
//A92
if ((keysA[10][1] == 0) and (lastA[10][1] == 0)) {
MidiSend(noteOn1, 92, velocity);
lastA[10][1] = 7;
}
//Write Midi Note Off
if ((keysA[10][1] == 1) and (lastA[10][1] == 7)) {
MidiSend(noteOff1, 92, velocity);
lastA[10][1] = 0;
}
//A93
if ((keysA[10][2] == 0) and (lastA[10][2] == 0)) {
MidiSend(noteOn1, 93, velocity);
lastA[10][2] = 7;
}
//Write Midi Note Off
if ((keysA[10][2] == 1) and (lastA[10][2] == 7)) {
MidiSend(noteOff1, 93, velocity);
lastA[10][2] = 0;
}
//A94
if ((keysA[10][3] == 0) and (lastA[10][3] == 0)) {
MidiSend(noteOn1, 94, velocity);
lastA[10][3] = 7;
}
//Write Midi Note Off
if ((keysA[10][3] == 1) and (lastA[10][3] == 7)) {
MidiSend(noteOff1, 94, velocity);
lastA[10][3] = 0;
}
//A95
if ((keysA[10][4] == 0) and (lastA[10][4] == 0)) {
MidiSend(noteOn1, 95, velocity);
lastA[10][4] = 7;
}
//Write Midi Note Off
if ((keysA[10][4] == 1) and (lastA[10][4] == 7)) {
MidiSend(noteOff1, 95, velocity);
lastA[10][4] = 0;
}
//A96
if ((keysA[10][5] == 0) and (lastA[10][5] == 0)) {
MidiSend(noteOn1, 96, velocity);
lastA[10][5] = 7;
}
//Write Midi Note Off
if ((keysA[10][5] == 1) and (lastA[10][5] == 7)) {
MidiSend(noteOff1, 96, velocity);
lastA[10][5] = 0;
}
//Write Keyboard B
//B36
if ((keysB[0][0] == 0) and (lastB[0][0] == 0)) {
MidiSend(noteOn2, 36, velocity);
lastB[0][0] = 7;
}
if ((keysB[0][0] == 1) and (lastB[0][0] == 7)) {
MidiSend(noteOff2, 36, velocity);
lastB[0][0] = 0;
}
//B37
if ((keysB[1][0] == 0) and (lastB[1][0] == 0)) {
MidiSend(noteOn2, 37, velocity);
lastB[1][0] = 7;
}
if ((keysB[1][0] == 1) and (lastB[1][0] == 7)) {
MidiSend(noteOff2, 37, velocity);
lastB[1][0] = 0;
}
//B38
if ((keysB[1][1] == 0) and (lastB[1][1] == 0)) {
MidiSend(noteOn2, 38, velocity);
lastB[1][1] = 7;
}
//Write Midi Note Off
if ((keysB[1][1] == 1) and (lastB[1][1] == 7)) {
MidiSend(noteOff2, 38, velocity);
lastB[1][1] = 0;
}
//B39
if ((keysB[1][2] == 0) and (lastB[1][2] == 0)) {
MidiSend(noteOn2, 39, velocity);
lastB[1][2] = 7;
}
//Write Midi Note Off
if ((keysB[1][2] == 1) and (lastB[1][2] == 7)) {
MidiSend(noteOff2, 39, velocity);
lastB[1][2] = 0;
}
//B40
if ((keysB[1][3] == 0) and (lastB[1][3] == 0)) {
MidiSend(noteOn2, 40, velocity);
lastB[1][3] = 7;
}
//Write Midi Note Off
if ((keysB[1][3] == 1) and (lastB[1][3] == 7)) {
MidiSend(noteOff2, 40, velocity);
lastB[1][3] = 0;
}
//B41
if ((keysB[1][4] == 0) and (lastB[1][4] == 0)) {
MidiSend(noteOn2, 41, velocity);
lastB[1][4] = 7;
}
//Write Midi Note Off
if ((keysB[1][4] == 1) and (lastB[1][4] == 7)) {
MidiSend(noteOff2, 41, velocity);
lastB[1][4] = 0;
}
//B42
if ((keysB[1][5] == 0) and (lastB[1][5] == 0)) {
MidiSend(noteOn2, 42, velocity);
lastB[1][5] = 7;
}
//Write Midi Note Off
if ((keysB[1][5] == 1) and (lastB[1][5] == 7)) {
MidiSend(noteOff2, 42, velocity);
lastB[1][5] = 0;
}
//B43
if ((keysB[2][0] == 0) and (lastB[2][0] == 0)) {
MidiSend(noteOn2, 43, velocity);
lastB[2][0] = 7;
}
//Write Midi Note Off
if ((keysB[2][0] == 1) and (lastB[2][0] == 7)) {
MidiSend(noteOff2, 43, velocity);
lastB[2][0] = 0;
}
//B44
if ((keysB[2][1] == 0) and (lastB[2][1] == 0)) {
MidiSend(noteOn2, 44, velocity);
lastB[2][1] = 7;
}
//Write Midi Note Off
if ((keysB[2][1] == 1) and (lastB[2][1] == 7)) {
MidiSend(noteOff2, 44, velocity);
lastB[2][1] = 0;
}
//B45
if ((keysB[2][2] == 0) and (lastB[2][2] == 0)) {
MidiSend(noteOn2, 45, velocity);
lastB[2][2] = 7;
}
//Write Midi Note Off
if ((keysB[2][2] == 1) and (lastB[2][2] == 7)) {
MidiSend(noteOff2, 45, velocity);
lastB[2][2] = 0;
}
//B46
if ((keysB[2][3] == 0) and (lastB[2][3] == 0)) {
MidiSend(noteOn2, 46, velocity);
lastB[2][3] = 7;
}
//Write Midi Note Off
if ((keysB[2][3] == 1) and (lastB[2][3] == 7)) {
MidiSend(noteOff2, 46, velocity);
lastB[2][3] = 0;
}
//B47
if ((keysB[2][4] == 0) and (lastB[2][4] == 0)) {
MidiSend(noteOn2, 47, velocity);
lastB[2][4] = 7;
}
//Write Midi Note Off
if ((keysB[2][4] == 1) and (lastB[2][4] == 7)) {
MidiSend(noteOff2, 47, velocity);
lastB[2][4] = 0;
}
//B48
if ((keysB[2][5] == 0) and (lastB[2][5] == 0)) {
MidiSend(noteOn2, 48, velocity);
lastB[2][5] = 7;
}
//Write Midi Note Off
if ((keysB[2][5] == 1) and (lastB[2][5] == 7)) {
MidiSend(noteOff2, 48, velocity);
lastB[2][5] = 0;
}
//B49
if ((keysB[3][0] == 0) and (lastB[3][0] == 0)) {
MidiSend(noteOn2, 49, velocity);
lastB[3][0] = 7;
}
//Write Midi Note Off
if ((keysB[3][0] == 1) and (lastB[3][0] == 7)) {
MidiSend(noteOff2, 49, velocity);
lastB[3][0] = 0;
}
//B50
if ((keysB[3][1] == 0) and (lastB[3][1] == 0)) {
MidiSend(noteOn2, 50, velocity);
lastB[3][1] = 7;
}
//Write Midi Note Off
if ((keysB[3][1] == 1) and (lastB[3][1] == 7)) {
MidiSend(noteOff2, 50, velocity);
lastB[3][1] = 0;
}
//B51
if ((keysB[3][2] == 0) and (lastB[3][2] == 0)) {
MidiSend(noteOn2, 51, velocity);
lastB[3][2] = 7;
}
//Write Midi Note Off
if ((keysB[3][2] == 1) and (lastB[3][2] == 7)) {
MidiSend(noteOff2, 51, velocity);
lastB[3][2] = 0;
}
//B52
if ((keysB[3][3] == 0) and (lastB[3][3] == 0)) {
MidiSend(noteOn2, 52, velocity);
lastB[3][3] = 7;
}
//Write Midi Note Off
if ((keysB[3][3] == 1) and (lastB[3][3] == 7)) {
MidiSend(noteOff2, 52, velocity);
lastB[3][3] = 0;
}
//B53
if ((keysB[3][4] == 0) and (lastB[3][4] == 0)) {
MidiSend(noteOn2, 53, velocity);
lastB[3][4] = 7;
}
//Write Midi Note Off
if ((keysB[3][4] == 1) and (lastB[3][4] == 7)) {
MidiSend(noteOff2, 53, velocity);
lastB[3][4] = 0;
}
//B54
if ((keysB[3][5] == 0) and (lastB[3][5] == 0)) {
MidiSend(noteOn2, 54, velocity);
lastB[3][5] = 7;
}
//Write Midi Note Off
if ((keysB[3][5] == 1) and (lastB[3][5] == 7)) {
MidiSend(noteOff2, 54, velocity);
lastB[3][5] = 0;
}
//B55
if ((keysB[4][0] == 0) and (lastB[4][0] == 0)) {
MidiSend(noteOn2, 55, velocity);
lastB[4][0] = 7;
}
//Write Midi Note Off
if ((keysB[4][0] == 1) and (lastB[4][0] == 7)) {
MidiSend(noteOff2, 55, velocity);
lastB[4][0] = 0;
}
//B56
if ((keysB[4][1] == 0) and (lastB[4][1] == 0)) {
MidiSend(noteOn2, 56, velocity);
lastB[4][1] = 7;
}
//Write Midi Note Off
if ((keysB[4][1] == 1) and (lastB[4][1] == 7)) {
MidiSend(noteOff2, 56, velocity);
lastB[4][1] = 0;
}
//B57
if ((keysB[4][2] == 0) and (lastB[4][2] == 0)) {
MidiSend(noteOn2, 57, velocity);
lastB[4][2] = 7;
}
//Write Midi Note Off
if ((keysB[4][2] == 1) and (lastB[4][2] == 7)) {
MidiSend(noteOff2, 57, velocity);
lastB[4][2] = 0;
}
//B58
if ((keysB[4][3] == 0) and (lastB[4][3] == 0)) {
MidiSend(noteOn2, 58, velocity);
lastB[4][3] = 7;
}
//Write Midi Note Off
if ((keysB[4][3] == 1) and (lastB[4][3] == 7)) {
MidiSend(noteOff2, 58, velocity);
lastB[4][3] = 0;
}
//B59
if ((keysB[4][4] == 0) and (lastB[4][4] == 0)) {
MidiSend(noteOn2, 59, velocity);
lastB[4][4] = 7;
}
//Write Midi Note Off
if ((keysB[4][4] == 1) and (lastB[4][4] == 7)) {
MidiSend(noteOff2, 59, velocity);
lastB[4][4] = 0;
}
//B60
if ((keysB[4][5] == 0) and (lastB[4][5] == 0)) {
MidiSend(noteOn2, 60, velocity);
lastB[4][5] = 7;
}
//Write Midi Note Off
if ((keysB[4][5] == 1) and (lastB[4][5] == 7)) {
MidiSend(noteOff2, 60, velocity);
lastB[4][5] = 0;
}
//B61
if ((keysB[5][0] == 0) and (lastB[5][0] == 0)) {
MidiSend(noteOn2, 61, velocity);
lastB[5][0] = 7;
}
//Write Midi Note Off
if ((keysB[5][0] == 1) and (lastB[5][0] == 7)) {
MidiSend(noteOff2, 61, velocity);
lastB[5][0] = 0;
}
//B62
if ((keysB[5][1] == 0) and (lastB[5][1] == 0)) {
MidiSend(noteOn2, 62, velocity);
lastB[5][1] = 7;
}
//Write Midi Note Off
if ((keysB[5][1] == 1) and (lastB[5][1] == 7)) {
MidiSend(noteOff2, 62, velocity);
lastB[5][1] = 0;
}
//B63
if ((keysB[5][2] == 0) and (lastB[5][2] == 0)) {
MidiSend(noteOn2, 63, velocity);
lastB[5][2] = 7;
}
//Write Midi Note Off
if ((keysB[5][2] == 1) and (lastB[5][2] == 7)) {
MidiSend(noteOff2, 63, velocity);
lastB[5][2] = 0;
}
//B64
if ((keysB[5][3] == 0) and (lastB[5][3] == 0)) {
MidiSend(noteOn2, 64, velocity);
lastB[5][3] = 7;
}
//Write Midi Note Off
if ((keysB[5][3] == 1) and (lastB[5][3] == 7)) {
MidiSend(noteOff2, 64, velocity);
lastB[5][3] = 0;
}
//B65
if ((keysB[5][4] == 0) and (lastB[5][4] == 0)) {
MidiSend(noteOn2, 65, velocity);
lastB[5][4] = 7;
}
//Write Midi Note Off
if ((keysB[5][4] == 1) and (lastB[5][4] == 7)) {
MidiSend(noteOff2, 65, velocity);
lastB[5][4] = 0;
}
//B66
if ((keysB[5][5] == 0) and (lastB[5][5] == 0)) {
MidiSend(noteOn2, 66, velocity);
lastB[5][5] = 7;
}
//Write Midi Note Off
if ((keysB[5][5] == 1) and (lastB[5][5] == 7)) {
MidiSend(noteOff2, 66, velocity);
lastB[5][5] = 0;
}
//B67
if ((keysB[6][0] == 0) and (lastB[6][0] == 0)) {
MidiSend(noteOn2, 67, velocity);
lastB[6][0] = 7;
}
//Write Midi Note Off
if ((keysB[6][0] == 1) and (lastB[6][0] == 7)) {
MidiSend(noteOff2, 67, velocity);
lastB[6][0] = 0;
}
//B68
if ((keysB[6][1] == 0) and (lastB[6][1] == 0)) {
MidiSend(noteOn2, 68, velocity);
lastB[6][1] = 7;
}
//Write Midi Note Off
if ((keysB[6][1] == 1) and (lastB[6][1] == 7)) {
MidiSend(noteOff2, 68, velocity);
lastB[6][1] = 0;
}
//B69
if ((keysB[6][2] == 0) and (lastB[6][2] == 0)) {
MidiSend(noteOn2, 69, velocity);
lastB[6][2] = 7;
}
//Write Midi Note Off
if ((keysB[6][2] == 1) and (lastB[6][2] == 7)) {
MidiSend(noteOff2, 69, velocity);
lastB[6][2] = 0;
}
//B70
if ((keysB[6][3] == 0) and (lastB[6][3] == 0)) {
MidiSend(noteOn2, 70, velocity);
lastB[6][3] = 7;
}
//Write Midi Note Off
if ((keysB[6][3] == 1) and (lastB[6][3] == 7)) {
MidiSend(noteOff2, 70, velocity);
lastB[6][3] = 0;
}
//B71
if ((keysB[6][4] == 0) and (lastB[6][4] == 0)) {
MidiSend(noteOn2, 71, velocity);
lastB[6][4] = 7;
}
//Write Midi Note Off
if ((keysB[6][4] == 1) and (lastB[6][4] == 7)) {
MidiSend(noteOff2, 71, velocity);
lastB[6][4] = 0;
}
//B72
if ((keysB[6][5] == 0) and (lastB[6][5] == 0)) {
MidiSend(noteOn2, 72, velocity);
lastB[6][5] = 7;
}
//Write Midi Note Off
if ((keysB[6][5] == 1) and (lastB[6][5] == 7)) {
MidiSend(noteOff2, 72, velocity);
lastB[6][5] = 0;
}
//B73
if ((keysB[7][0] == 0) and (lastB[7][0] == 0)) {
MidiSend(noteOn2, 73, velocity);
lastB[7][0] = 7;
}
//Write Midi Note Off
if ((keysB[7][0] == 1) and (lastB[7][0] == 7)) {
MidiSend(noteOff2, 73, velocity);
lastB[7][0] = 0;
}
//B74
if ((keysB[7][1] == 0) and (lastB[7][1] == 0)) {
MidiSend(noteOn2, 74, velocity);
lastB[7][1] = 7;
}
//Write Midi Note Off
if ((keysB[7][1] == 1) and (lastB[7][1] == 7)) {
MidiSend(noteOff2, 74, velocity);
lastB[7][1] = 0;
}
//B75
if ((keysB[7][2] == 0) and (lastB[7][2] == 0)) {
MidiSend(noteOn2, 75, velocity);
lastB[7][2] = 7;
}
//Write Midi Note Off
if ((keysB[7][2] == 1) and (lastB[7][2] == 7)) {
MidiSend(noteOff2, 75, velocity);
lastB[7][2] = 0;
}
//B76
if ((keysB[7][3] == 0) and (lastB[7][3] == 0)) {
MidiSend(noteOn2, 76, velocity);
lastB[7][3] = 7;
}
//Write Midi Note Off
if ((keysB[7][3] == 1) and (lastB[7][3] == 7)) {
MidiSend(noteOff2, 76, velocity);
lastB[7][3] = 0;
}
//B77
if ((keysB[7][4] == 0) and (lastB[7][4] == 0)) {
MidiSend(noteOn2, 77, velocity);
lastB[7][4] = 7;
}
//Write Midi Note Off
if ((keysB[7][4] == 1) and (lastB[7][4] == 7)) {
MidiSend(noteOff2, 77, velocity);
lastB[7][4] = 0;
}
//B78
if ((keysB[7][5] == 0) and (lastB[7][5] == 0)) {
MidiSend(noteOn2, 78, velocity);
lastB[7][5] = 7;
}
//Write Midi Note Off
if ((keysB[7][5] == 1) and (lastB[7][5] == 7)) {
MidiSend(noteOff2, 78, velocity);
lastB[7][5] = 0;
}
//B79
if ((keysB[8][0] == 0) and (lastB[8][0] == 0)) {
MidiSend(noteOn2, 79, velocity);
lastB[8][0] = 7;
}
//Write Midi Note Off
if ((keysB[8][0] == 1) and (lastB[8][0] == 7)) {
MidiSend(noteOff2, 79, velocity);
lastB[8][0] = 0;
}
//B80
if ((keysB[8][1] == 0) and (lastB[8][1] == 0)) {
MidiSend(noteOn2, 80, velocity);
lastB[8][1] = 7;
}
//Write Midi Note Off
if ((keysB[8][1] == 1) and (lastB[8][1] == 7)) {
MidiSend(noteOff2, 80, velocity);
lastB[8][1] = 0;
}
//B81
if ((keysB[8][2] == 0) and (lastB[8][2] == 0)) {
MidiSend(noteOn2, 81, velocity);
lastB[8][2] = 7;
}
//Write Midi Note Off
if ((keysB[8][2] == 1) and (lastB[8][2] == 7)) {
MidiSend(noteOff2, 81, velocity);
lastB[8][2] = 0;
}
//B82
if ((keysB[8][3] == 0) and (lastB[8][3] == 0)) {
MidiSend(noteOn2, 82, velocity);
lastB[8][3] = 7;
}
//Write Midi Note Off
if ((keysB[8][3] == 1) and (lastB[8][3] == 7)) {
MidiSend(noteOff2, 82, velocity);
lastB[8][3] = 0;
}
//B83
if ((keysB[8][4] == 0) and (lastB[8][4] == 0)) {
MidiSend(noteOn2, 83, velocity);
lastB[8][4] = 7;
}
//Write Midi Note Off
if ((keysB[8][4] == 1) and (lastB[8][4] == 7)) {
MidiSend(noteOff2, 83, velocity);
lastB[8][4] = 0;
}
//B84
if ((keysB[8][5] == 0) and (lastB[8][5] == 0)) {
MidiSend(noteOn2, 84, velocity);
lastB[8][5] = 7;
}
//Write Midi Note Off
if ((keysB[8][5] == 1) and (lastB[8][5] == 7)) {
MidiSend(noteOff2, 84, velocity);
lastB[8][5] = 0;
}
//B85
if ((keysB[9][0] == 0) and (lastB[9][0] == 0)) {
MidiSend(noteOn2, 85, velocity);
lastB[9][0] = 7;
}
//Write Midi Note Off
if ((keysB[9][0] == 1) and (lastB[9][0] == 7)) {
MidiSend(noteOff2, 85, velocity);
lastB[9][0] = 0;
}
//B86
if ((keysB[9][1] == 0) and (lastB[9][1] == 0)) {
MidiSend(noteOn2, 86, velocity);
lastB[9][1] = 7;
}
//Write Midi Note Off
if ((keysB[9][1] == 1) and (lastB[9][1] == 7)) {
MidiSend(noteOff2, 86, velocity);
lastB[9][1] = 0;
}
//B87
if ((keysB[9][2] == 0) and (lastB[9][2] == 0)) {
MidiSend(noteOn2, 87, velocity);
lastB[9][2] = 7;
}
//Write Midi Note Off
if ((keysB[9][2] == 1) and (lastB[9][2] == 7)) {
MidiSend(noteOff2, 87, velocity);
lastB[9][2] = 0;
}
//B88
if ((keysB[9][3] == 0) and (lastB[9][3] == 0)) {
MidiSend(noteOn2, 88, velocity);
lastB[9][3] = 7;
}
//Write Midi Note Off
if ((keysB[9][3] == 1) and (lastB[9][3] == 7)) {
MidiSend(noteOff2, 88, velocity);
lastB[9][3] = 0;
}
//B89
if ((keysB[9][4] == 0) and (lastB[9][4] == 0)) {
MidiSend(noteOn2, 89, velocity);
lastB[9][4] = 7;
}
//Write Midi Note Off
if ((keysB[9][4] == 1) and (lastB[9][4] == 7)) {
MidiSend(noteOff2, 89, velocity);
lastB[9][4] = 0;
}
//B90
if ((keysB[9][5] == 0) and (lastB[9][5] == 0)) {
MidiSend(noteOn2, 90, velocity);
lastB[9][5] = 7;
}
//Write Midi Note Off
if ((keysB[9][5] == 1) and (lastB[9][5] == 7)) {
MidiSend(noteOff2, 90, velocity);
lastB[9][5] = 0;
}
//B91
if ((keysB[10][0] == 0) and (lastB[10][0] == 0)) {
MidiSend(noteOn2, 91, velocity);
lastB[10][0] = 7;
}
//Write Midi Note Off
if ((keysB[10][0] == 1) and (lastB[10][0] == 7)) {
MidiSend(noteOff2, 91, velocity);
lastB[10][0] = 0;
}
//B92
if ((keysB[10][1] == 0) and (lastB[10][1] == 0)) {
MidiSend(noteOn2, 92, velocity);
lastB[10][1] = 7;
}
//Write Midi Note Off
if ((keysB[10][1] == 1) and (lastB[10][1] == 7)) {
MidiSend(noteOff2, 92, velocity);
lastB[10][1] = 0;
}
//B93
if ((keysB[10][2] == 0) and (lastB[10][2] == 0)) {
MidiSend(noteOn2, 93, velocity);
lastB[10][2] = 7;
}
//Write Midi Note Off
if ((keysB[10][2] == 1) and (lastB[10][2] == 7)) {
MidiSend(noteOff2, 93, velocity);
lastB[10][2] = 0;
}
//B94
if ((keysB[10][3] == 0) and (lastB[10][3] == 0)) {
MidiSend(noteOn2, 94, velocity);
lastB[10][3] = 7;
}
//Write Midi Note Off
if ((keysB[10][3] == 1) and (lastB[10][3] == 7)) {
MidiSend(noteOff2, 94, velocity);
lastB[10][3] = 0;
}
//B95
if ((keysB[10][4] == 0) and (lastB[10][4] == 0)) {
MidiSend(noteOn2, 95, velocity);
lastB[10][4] = 7;
}
//Write Midi Note Off
if ((keysB[10][4] == 1) and (lastB[10][4] == 7)) {
MidiSend(noteOff2, 95, velocity);
lastB[10][4] = 0;
}
//B96
if ((keysB[10][5] == 0) and (lastB[10][5] == 0)) {
MidiSend(noteOn2, 96, velocity);
lastB[10][5] = 7;
}
//Write Midi Note Off
if ((keysB[10][5] == 1) and (lastB[10][5] == 7)) {
MidiSend(noteOff2, 96, velocity);
lastB[10][5] = 0;
}
//Write Keyboard C
//C36
if ((keysC[0][0] == 0) and (lastC[0][0] == 0)) {
MidiSend(noteOff3, 36, velocity);
lastC[0][0] = 7;
}
if ((keysC[0][0] == 1) and (lastC[0][0] == 7)) {
MidiSend(noteOn3, 36, velocity);
lastC[0][0] = 0;
}
//C37
if ((keysC[1][0] == 0) and (lastC[1][0] == 0)) {
MidiSend(noteOff3, 37, velocity);
lastC[1][0] = 7;
}
if ((keysC[1][0] == 1) and (lastC[1][0] == 7)) {
MidiSend(noteOn3, 37, velocity);
lastC[1][0] = 0;
}
//C38
if ((keysC[1][1] == 0) and (lastC[1][1] == 0)) {
MidiSend(noteOff3, 38, velocity);
lastC[1][1] = 7;
}
//Write Midi Note Off
if ((keysC[1][1] == 1) and (lastC[1][1] == 7)) {
MidiSend(noteOn3, 38, velocity);
lastC[1][1] = 0;
}
//C39
if ((keysC[1][2] == 0) and (lastC[1][2] == 0)) {
MidiSend(noteOff3, 39, velocity);
lastC[1][2] = 7;
}
//Write Midi Note Off
if ((keysC[1][2] == 1) and (lastC[1][2] == 7)) {
MidiSend(noteOn3, 39, velocity);
lastC[1][2] = 0;
}
//C40
if ((keysC[1][3] == 0) and (lastC[1][3] == 0)) {
MidiSend(noteOff3, 40, velocity);
lastC[1][3] = 7;
}
//Write Midi Note Off
if ((keysC[1][3] == 1) and (lastC[1][3] == 7)) {
MidiSend(noteOn3, 40, velocity);
lastC[1][3] = 0;
}
//C41
if ((keysC[1][4] == 0) and (lastC[1][4] == 0)) {
MidiSend(noteOff3, 41, velocity);
lastC[1][4] = 7;
}
//Write Midi Note Off
if ((keysC[1][4] == 1) and (lastC[1][4] == 7)) {
MidiSend(noteOn3, 41, velocity);
lastC[1][4] = 0;
}
//C42
if ((keysC[1][5] == 0) and (lastC[1][5] == 0)) {
MidiSend(noteOff3, 42, velocity);
lastC[1][5] = 7;
}
//Write Midi Note Off
if ((keysC[1][5] == 1) and (lastC[1][5] == 7)) {
MidiSend(noteOn3, 42, velocity);
lastC[1][5] = 0;
}
//C43
if ((keysC[2][0] == 0) and (lastC[2][0] == 0)) {
MidiSend(noteOff3, 43, velocity);
lastC[2][0] = 7;
}
//Write Midi Note Off
if ((keysC[2][0] == 1) and (lastC[2][0] == 7)) {
MidiSend(noteOn3, 43, velocity);
lastC[2][0] = 0;
}
//C44
if ((keysC[2][1] == 0) and (lastC[2][1] == 0)) {
MidiSend(noteOff3, 44, velocity);
lastC[2][1] = 7;
}
//Write Midi Note Off
if ((keysC[2][1] == 1) and (lastC[2][1] == 7)) {
MidiSend(noteOn3, 44, velocity);
lastC[2][1] = 0;
}
//C45
if ((keysC[2][2] == 0) and (lastC[2][2] == 0)) {
MidiSend(noteOff3, 45, velocity);
lastC[2][2] = 7;
}
//Write Midi Note Off
if ((keysC[2][2] == 1) and (lastC[2][2] == 7)) {
MidiSend(noteOn3, 45, velocity);
lastC[2][2] = 0;
}
//C46
if ((keysC[2][3] == 0) and (lastC[2][3] == 0)) {
MidiSend(noteOff3, 46, velocity);
lastC[2][3] = 7;
}
//Write Midi Note Off
if ((keysC[2][3] == 1) and (lastC[2][3] == 7)) {
MidiSend(noteOn3, 46, velocity);
lastC[2][3] = 0;
}
//C47
if ((keysC[2][4] == 0) and (lastC[2][4] == 0)) {
MidiSend(noteOff3, 47, velocity);
lastC[2][4] = 7;
}
//Write Midi Note Off
if ((keysC[2][4] == 1) and (lastC[2][4] == 7)) {
MidiSend(noteOn3, 47, velocity);
lastC[2][4] = 0;
}
//C48
if ((keysC[2][5] == 0) and (lastC[2][5] == 0)) {
MidiSend(noteOff3, 48, velocity);
lastC[2][5] = 7;
}
//Write Midi Note Off
if ((keysC[2][5] == 1) and (lastC[2][5] == 7)) {
MidiSend(noteOn3, 48, velocity);
lastC[2][5] = 0;
}
//C49
if ((keysC[3][0] == 0) and (lastC[3][0] == 0)) {
MidiSend(noteOff3, 49, velocity);
lastC[3][0] = 7;
}
//Write Midi Note Off
if ((keysC[3][0] == 1) and (lastC[3][0] == 7)) {
MidiSend(noteOn3, 49, velocity);
lastC[3][0] = 0;
}
//C50
if ((keysC[3][1] == 0) and (lastC[3][1] == 0)) {
MidiSend(noteOff3, 50, velocity);
lastC[3][1] = 7;
}
//Write Midi Note Off
if ((keysC[3][1] == 1) and (lastC[3][1] == 7)) {
MidiSend(noteOn3, 50, velocity);
lastC[3][1] = 0;
}
//C51
if ((keysC[3][2] == 0) and (lastC[3][2] == 0)) {
MidiSend(noteOff3, 51, velocity);
lastC[3][2] = 7;
}
//Write Midi Note Off
if ((keysC[3][2] == 1) and (lastC[3][2] == 7)) {
MidiSend(noteOn3, 51, velocity);
lastC[3][2] = 0;
}
//C52
if ((keysC[3][3] == 0) and (lastC[3][3] == 0)) {
MidiSend(noteOff3, 52, velocity);
lastC[3][3] = 7;
}
//Write Midi Note Off
if ((keysC[3][3] == 1) and (lastC[3][3] == 7)) {
MidiSend(noteOn3, 52, velocity);
lastC[3][3] = 0;
}
//C53
if ((keysC[3][4] == 0) and (lastC[3][4] == 0)) {
MidiSend(noteOff3, 53, velocity);
lastC[3][4] = 7;
}
//Write Midi Note Off
if ((keysC[3][4] == 1) and (lastC[3][4] == 7)) {
MidiSend(noteOn3, 53, velocity);
lastC[3][4] = 0;
}
//C54
if ((keysC[3][5] == 0) and (lastC[3][5] == 0)) {
MidiSend(noteOff3, 54, velocity);
lastC[3][5] = 7;
}
//Write Midi Note Off
if ((keysC[3][5] == 1) and (lastC[3][5] == 7)) {
MidiSend(noteOn3, 54, velocity);
lastC[3][5] = 0;
}
//C55
if ((keysC[4][0] == 0) and (lastC[4][0] == 0)) {
MidiSend(noteOff3, 55, velocity);
lastC[4][0] = 7;
}
//Write Midi Note Off
if ((keysC[4][0] == 1) and (lastC[4][0] == 7)) {
MidiSend(noteOn3, 55, velocity);
lastC[4][0] = 0;
}
//C56
if ((keysC[4][1] == 0) and (lastC[4][1] == 0)) {
MidiSend(noteOff3, 56, velocity);
lastC[4][1] = 7;
}
//Write Midi Note Off
if ((keysC[4][1] == 1) and (lastC[4][1] == 7)) {
MidiSend(noteOn3, 56, velocity);
lastC[4][1] = 0;
}
//C57
if ((keysC[4][2] == 0) and (lastC[4][2] == 0)) {
MidiSend(noteOff3, 57, velocity);
lastC[4][2] = 7;
}
//Write Midi Note Off
if ((keysC[4][2] == 1) and (lastC[4][2] == 7)) {
MidiSend(noteOn3, 57, velocity);
lastC[4][2] = 0;
}
//C58
if ((keysC[4][3] == 0) and (lastC[4][3] == 0)) {
MidiSend(noteOff3, 58, velocity);
lastC[4][3] = 7;
}
//Write Midi Note Off
if ((keysC[4][3] == 1) and (lastC[4][3] == 7)) {
MidiSend(noteOn3, 58, velocity);
lastC[4][3] = 0;
}
//C59
if ((keysC[4][4] == 0) and (lastC[4][4] == 0)) {
MidiSend(noteOff3, 59, velocity);
lastC[4][4] = 7;
}
//Write Midi Note Off
if ((keysC[4][4] == 1) and (lastC[4][4] == 7)) {
MidiSend(noteOn3, 59, velocity);
lastC[4][4] = 0;
}
//C60
if ((keysC[4][5] == 0) and (lastC[4][5] == 0)) {
MidiSend(noteOff3, 60, velocity);
lastC[4][5] = 7;
}
//Write Midi Note Off
if ((keysC[4][5] == 1) and (lastC[4][5] == 7)) {
MidiSend(noteOn3, 60, velocity);
lastC[4][5] = 0;
}
//C61
if ((keysC[5][0] == 0) and (lastC[5][0] == 0)) {
MidiSend(noteOff3, 61, velocity);
lastC[5][0] = 7;
}
//Write Midi Note Off
if ((keysC[5][0] == 1) and (lastC[5][0] == 7)) {
MidiSend(noteOn3, 61, velocity);
lastC[5][0] = 0;
}
//C62
if ((keysC[5][1] == 0) and (lastC[5][1] == 0)) {
MidiSend(noteOff3, 62, velocity);
lastC[5][1] = 7;
}
//Write Midi Note Off
if ((keysC[5][1] == 1) and (lastC[5][1] == 7)) {
MidiSend(noteOn3, 62, velocity);
lastC[5][1] = 0;
}
//C63
if ((keysC[5][2] == 0) and (lastC[5][2] == 0)) {
MidiSend(noteOff3, 63, velocity);
lastC[5][2] = 7;
}
//Write Midi Note Off
if ((keysC[5][2] == 1) and (lastC[5][2] == 7)) {
MidiSend(noteOn3, 63, velocity);
lastC[5][2] = 0;
}
//C64
if ((keysC[5][3] == 0) and (lastC[5][3] == 0)) {
MidiSend(noteOff3, 64, velocity);
lastC[5][3] = 7;
}
//Write Midi Note Off
if ((keysC[5][3] == 1) and (lastC[5][3] == 7)) {
MidiSend(noteOn3, 64, velocity);
lastC[5][3] = 0;
}
//C65
if ((keysC[5][4] == 0) and (lastC[5][4] == 0)) {
MidiSend(noteOff3, 65, velocity);
lastC[5][4] = 7;
}
//Write Midi Note Off
if ((keysC[5][4] == 1) and (lastC[5][4] == 7)) {
MidiSend(noteOn3, 65, velocity);
lastC[5][4] = 0;
}
//C66
if ((keysC[5][5] == 0) and (lastC[5][5] == 0)) {
MidiSend(noteOff3, 66, velocity);
lastC[5][5] = 7;
}
//Write Midi Note Off
if ((keysC[5][5] == 1) and (lastC[5][5] == 7)) {
MidiSend(noteOn3, 66, velocity);
lastC[5][5] = 0;
}
//C67
if ((keysC[6][0] == 0) and (lastC[6][0] == 0)) {
MidiSend(noteOff3, 67, velocity);
lastC[6][0] = 7;
}
//Write Midi Note Off
if ((keysC[6][0] == 1) and (lastC[6][0] == 7)) {
MidiSend(noteOn3, 67, velocity);
lastC[6][0] = 0;
}
//Expression pedal on analog pin 0 to Channel 6
int Cur6 = analogRead(0);
int Map6 = map(Cur6, 0, 1023, 0, 127);
if (abs(Cur6 - LastPot6) >= 8) {
MidiSend(chan6,Exp,Map6);
LastPot6 = Cur6;
}
//Expression pedal on analog pin 1 to Channel 7
int Cur7 = analogRead(1);
int Map7 = map(Cur7, 0, 1023, 0, 127);
if (abs(Cur7 - LastPot7) >= 8) {
MidiSend(chan7,Exp,Map7);
LastPot7 = Cur7;
}
}
void MidiSend(int one, int two, int three) {
Serial.write(one);
Serial.write(two);
Serial.write(three);
}
Bussed Keyboard Code
Arduino// Name: Arduino Mega Midi Controller 61x4 plus 3 potentiometers.
// Version 1.0
// Created: April 12, 2021
// Author: Larason2
// Acknowledgements: Bald Engineer, Amanda Ghassaei, jeffb42, GrumpyMike
//Note Data
byte keysA[11][6];
byte keysB[11][6];
byte keysC[11][6];
byte keysD[11][6];
//Last Key State
byte lastA[11][6];
byte lastB[11][6];
byte lastC[11][6];
byte lastD[11][6];
//Midi Messages Sent
int noteOn1 = 144;
int noteOff1 = 128;
int noteOn2 = 145;
int noteOff2 = 129;
int noteOn3 = 146;
int noteOff3 = 130;
int noteOn4 = 147;
int noteOff4 = 131;
int velocity = 100;
int chan6 = 181;
int chan7 = 182;
int chan8 = 183;
int Exp = 11;
//Last Potentiometer State
int LastPot6 = 1;
int LastPot7 = 1;
int LastPot8 = 1;
void setup() {
// Start Serial at Midi rate
Serial.begin(31250);
//Initialize Pins 1-10
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(11, INPUT);
//Pins 11-20
pinMode(12, INPUT);
pinMode(13, INPUT);
pinMode(14, INPUT);
pinMode(15, INPUT);
pinMode(16, INPUT);
pinMode(17, INPUT);
pinMode(18, INPUT);
pinMode(19, INPUT);
pinMode(20, INPUT);
pinMode(21, INPUT);
//Pins 21-30
pinMode(22, INPUT);
pinMode(23, INPUT);
pinMode(24, INPUT);
pinMode(25, INPUT);
pinMode(26, INPUT);
pinMode(27, INPUT);
pinMode(28, INPUT);
pinMode(29, INPUT);
pinMode(30, INPUT);
pinMode(31, INPUT);
//Pins 31-40
pinMode(32, INPUT);
pinMode(33, INPUT);
pinMode(34, INPUT);
pinMode(35, INPUT);
pinMode(36, INPUT);
pinMode(37, INPUT);
pinMode(38, INPUT);
pinMode(39, INPUT);
pinMode(40, INPUT);
pinMode(41, INPUT);
//Pins 41-50
pinMode(42, INPUT);
pinMode(43, INPUT);
pinMode(44, INPUT);
pinMode(45, INPUT);
pinMode(46, INPUT);
pinMode(47, INPUT);
pinMode(48, INPUT);
pinMode(49, INPUT);
pinMode(50, INPUT);
pinMode(51, INPUT);
//Pins 51-61
pinMode(52, INPUT);
pinMode(53, INPUT);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
pinMode(A6, INPUT);
pinMode(A7, INPUT);
pinMode(A8, INPUT);
//Column Pins
pinMode(A9, INPUT);
pinMode(A10, INPUT);
pinMode(A11, INPUT);
pinMode(A12, INPUT);
//Pot Pins
pinMode(A13, INPUT);
pinMode(A14, INPUT);
pinMode(A15, INPUT);
}
void loop() {
// Setup pins for keyboards
//Pins 1-10
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
//Pins 11-20
pinMode(12, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(17, INPUT_PULLUP);
pinMode(18, INPUT_PULLUP);
pinMode(19, INPUT_PULLUP);
pinMode(20, INPUT_PULLUP);
pinMode(21, INPUT_PULLUP);
//Pins 21-30
pinMode(22, INPUT_PULLUP);
pinMode(23, INPUT_PULLUP);
pinMode(24, INPUT_PULLUP);
pinMode(25, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
pinMode(27, INPUT_PULLUP);
pinMode(28, INPUT_PULLUP);
pinMode(29, INPUT_PULLUP);
pinMode(30, INPUT_PULLUP);
pinMode(31, INPUT_PULLUP);
//Pins 31-40
pinMode(32, INPUT_PULLUP);
pinMode(33, INPUT_PULLUP);
pinMode(34, INPUT_PULLUP);
pinMode(35, INPUT_PULLUP);
pinMode(36, INPUT_PULLUP);
pinMode(37, INPUT_PULLUP);
pinMode(38, INPUT_PULLUP);
pinMode(39, INPUT_PULLUP);
pinMode(40, INPUT_PULLUP);
pinMode(41, INPUT_PULLUP);
//Pins 41-50
pinMode(42, INPUT_PULLUP);
pinMode(43, INPUT_PULLUP);
pinMode(44, INPUT_PULLUP);
pinMode(45, INPUT_PULLUP);
pinMode(46, INPUT_PULLUP);
pinMode(47, INPUT_PULLUP);
pinMode(48, INPUT_PULLUP);
pinMode(49, INPUT_PULLUP);
pinMode(50, INPUT_PULLUP);
pinMode(51, INPUT_PULLUP);
//Pins 51-61
pinMode(52, INPUT_PULLUP);
pinMode(53, INPUT_PULLUP);
pinMode(A0, INPUT_PULLUP);
pinMode(A1, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);
pinMode(A3, INPUT_PULLUP);
pinMode(A4, INPUT_PULLUP);
pinMode(A5, INPUT_PULLUP);
pinMode(A6, INPUT_PULLUP);
pinMode(A7, INPUT_PULLUP);
pinMode(A8, INPUT_PULLUP);
//Read Keyboard A
pinMode(A9, OUTPUT);
digitalWrite(A9, LOW);
//Keys 1-10
keysA[0][0] = digitalRead(2);
keysA[1][0] = digitalRead(3);
keysA[1][1] = digitalRead(4);
keysA[1][2] = digitalRead(5);
keysA[1][3] = digitalRead(6);
keysA[1][4] = digitalRead(7);
keysA[1][5] = digitalRead(8);
keysA[2][0] = digitalRead(9);
keysA[2][1] = digitalRead(10);
keysA[2][2] = digitalRead(11);
//Keys 11-20
keysA[2][3] = digitalRead(12);
keysA[2][4] = digitalRead(13);
keysA[2][5] = digitalRead(14);
keysA[3][0] = digitalRead(15);
keysA[3][1] = digitalRead(16);
keysA[3][2] = digitalRead(17);
keysA[3][3] = digitalRead(18);
keysA[3][4] = digitalRead(19);
keysA[3][5] = digitalRead(20);
keysA[4][0] = digitalRead(21);
//Keys 21-30
keysA[4][1] = digitalRead(22);
keysA[4][2] = digitalRead(23);
keysA[4][3] = digitalRead(24);
keysA[4][4] = digitalRead(25);
keysA[4][5] = digitalRead(26);
keysA[5][0] = digitalRead(27);
keysA[5][1] = digitalRead(28);
keysA[5][2] = digitalRead(29);
keysA[5][3] = digitalRead(30);
keysA[5][4] = digitalRead(31);
//Keys 31-40
keysA[5][5] = digitalRead(32);
keysA[6][0] = digitalRead(33);
keysA[6][1] = digitalRead(34);
keysA[6][2] = digitalRead(35);
keysA[6][3] = digitalRead(36);
keysA[6][4] = digitalRead(37);
keysA[6][5] = digitalRead(38);
keysA[7][0] = digitalRead(39);
keysA[7][1] = digitalRead(40);
keysA[7][2] = digitalRead(41);
//Keys 41-50
keysA[7][3] = digitalRead(42);
keysA[7][4] = digitalRead(43);
keysA[7][5] = digitalRead(44);
keysA[8][0] = digitalRead(45);
keysA[8][1] = digitalRead(46);
keysA[8][2] = digitalRead(47);
keysA[8][3] = digitalRead(48);
keysA[8][4] = digitalRead(49);
keysA[8][5] = digitalRead(50);
keysA[9][0] = digitalRead(51);
//Keys 51-61
keysA[9][1] = digitalRead(52);
keysA[9][2] = digitalRead(53);
keysA[9][3] = digitalRead(A0);
keysA[9][4] = digitalRead(A1);
keysA[9][5] = digitalRead(A2);
keysA[10][0] = digitalRead(A3);
keysA[10][1] = digitalRead(A4);
keysA[10][2] = digitalRead(A5);
keysA[10][3] = digitalRead(A6);
keysA[10][4] = digitalRead(A7);
keysA[10][5] = digitalRead(A8);
pinMode(A9, INPUT);
// Read Keyboard B
pinMode(A10, OUTPUT);
digitalWrite(A10, LOW);
//Keys 1-10
keysB[0][0] = digitalRead(2);
keysB[1][0] = digitalRead(3);
keysB[1][1] = digitalRead(4);
keysB[1][2] = digitalRead(5);
keysB[1][3] = digitalRead(6);
keysB[1][4] = digitalRead(7);
keysB[1][5] = digitalRead(8);
keysB[2][0] = digitalRead(9);
keysB[2][1] = digitalRead(10);
keysB[2][2] = digitalRead(11);
//Keys 11-20
keysB[2][3] = digitalRead(12);
keysB[2][4] = digitalRead(13);
keysB[2][5] = digitalRead(14);
keysB[3][0] = digitalRead(15);
keysB[3][1] = digitalRead(16);
keysB[3][2] = digitalRead(17);
keysB[3][3] = digitalRead(18);
keysB[3][4] = digitalRead(19);
keysB[3][5] = digitalRead(20);
keysB[4][0] = digitalRead(21);
//Keys 21-30
keysB[4][1] = digitalRead(22);
keysB[4][2] = digitalRead(23);
keysB[4][3] = digitalRead(24);
keysB[4][4] = digitalRead(25);
keysB[4][5] = digitalRead(26);
keysB[5][0] = digitalRead(27);
keysB[5][1] = digitalRead(28);
keysB[5][2] = digitalRead(29);
keysB[5][3] = digitalRead(30);
keysB[5][4] = digitalRead(31);
//Keys 31-40
keysB[5][5] = digitalRead(32);
keysB[6][0] = digitalRead(33);
keysB[6][1] = digitalRead(34);
keysB[6][2] = digitalRead(35);
keysB[6][3] = digitalRead(36);
keysB[6][4] = digitalRead(37);
keysB[6][5] = digitalRead(38);
keysB[7][0] = digitalRead(39);
keysB[7][1] = digitalRead(40);
keysB[7][2] = digitalRead(41);
//Keys 41-50
keysB[7][3] = digitalRead(42);
keysB[7][4] = digitalRead(43);
keysB[7][5] = digitalRead(44);
keysB[8][0] = digitalRead(45);
keysB[8][1] = digitalRead(46);
keysB[8][2] = digitalRead(47);
keysB[8][3] = digitalRead(48);
keysB[8][4] = digitalRead(49);
keysB[8][5] = digitalRead(50);
keysB[9][0] = digitalRead(51);
//Keys 51-61
keysB[9][1] = digitalRead(52);
keysB[9][2] = digitalRead(53);
keysB[9][3] = digitalRead(A0);
keysB[9][4] = digitalRead(A1);
keysB[9][5] = digitalRead(A2);
keysB[10][0] = digitalRead(A3);
keysB[10][1] = digitalRead(A4);
keysB[10][2] = digitalRead(A5);
keysB[10][3] = digitalRead(A6);
keysB[10][4] = digitalRead(A7);
keysB[10][5] = digitalRead(A8);
pinMode(A10, INPUT);
// Read Keyboard C
pinMode(A11, OUTPUT);
digitalWrite(A11, LOW);
//Keys 1-10
keysC[0][0] = digitalRead(2);
keysC[1][0] = digitalRead(3);
keysC[1][1] = digitalRead(4);
keysC[1][2] = digitalRead(5);
keysC[1][3] = digitalRead(6);
keysC[1][4] = digitalRead(7);
keysC[1][5] = digitalRead(8);
keysC[2][0] = digitalRead(9);
keysC[2][1] = digitalRead(10);
keysC[2][2] = digitalRead(11);
//Keys 11-20
keysC[2][3] = digitalRead(12);
keysC[2][4] = digitalRead(13);
keysC[2][5] = digitalRead(14);
keysC[3][0] = digitalRead(15);
keysC[3][1] = digitalRead(16);
keysC[3][2] = digitalRead(17);
keysC[3][3] = digitalRead(18);
keysC[3][4] = digitalRead(19);
keysC[3][5] = digitalRead(20);
keysC[4][0] = digitalRead(21);
//Keys 21-30
keysC[4][1] = digitalRead(22);
keysC[4][2] = digitalRead(23);
keysC[4][3] = digitalRead(24);
keysC[4][4] = digitalRead(25);
keysC[4][5] = digitalRead(26);
keysC[5][0] = digitalRead(27);
keysC[5][1] = digitalRead(28);
keysC[5][2] = digitalRead(29);
keysC[5][3] = digitalRead(30);
keysC[5][4] = digitalRead(31);
//Keys 31-40
keysC[5][5] = digitalRead(32);
keysC[6][0] = digitalRead(33);
keysC[6][1] = digitalRead(34);
keysC[6][2] = digitalRead(35);
keysC[6][3] = digitalRead(36);
keysC[6][4] = digitalRead(37);
keysC[6][5] = digitalRead(38);
keysC[7][0] = digitalRead(39);
keysC[7][1] = digitalRead(40);
keysC[7][2] = digitalRead(41);
//Keys 41-50
keysC[7][3] = digitalRead(42);
keysC[7][4] = digitalRead(43);
keysC[7][5] = digitalRead(44);
keysC[8][0] = digitalRead(45);
keysC[8][1] = digitalRead(46);
keysC[8][2] = digitalRead(47);
keysC[8][3] = digitalRead(48);
keysC[8][4] = digitalRead(49);
keysC[8][5] = digitalRead(50);
keysC[9][0] = digitalRead(51);
//Keys 51-61
keysC[9][1] = digitalRead(52);
keysC[9][2] = digitalRead(53);
keysC[9][3] = digitalRead(A0);
keysC[9][4] = digitalRead(A1);
keysC[9][5] = digitalRead(A2);
keysC[10][0] = digitalRead(A3);
keysC[10][1] = digitalRead(A4);
keysC[10][2] = digitalRead(A5);
keysC[10][3] = digitalRead(A6);
keysC[10][4] = digitalRead(A7);
keysC[10][5] = digitalRead(A8);
pinMode(A11, INPUT);
// Read Keyboard D
pinMode(A12, OUTPUT);
digitalWrite(A12, LOW);
//Keys 1-10
keysD[0][0] = digitalRead(2);
keysD[1][0] = digitalRead(3);
keysD[1][1] = digitalRead(4);
keysD[1][2] = digitalRead(5);
keysD[1][3] = digitalRead(6);
keysD[1][4] = digitalRead(7);
keysD[1][5] = digitalRead(8);
keysD[2][0] = digitalRead(9);
keysD[2][1] = digitalRead(10);
keysD[2][2] = digitalRead(11);
//Keys 11-20
keysD[2][3] = digitalRead(12);
keysD[2][4] = digitalRead(13);
keysD[2][5] = digitalRead(14);
keysD[3][0] = digitalRead(15);
keysD[3][1] = digitalRead(16);
keysD[3][2] = digitalRead(17);
keysD[3][3] = digitalRead(18);
keysD[3][4] = digitalRead(19);
keysD[3][5] = digitalRead(20);
keysD[4][0] = digitalRead(21);
//Keys 21-30
keysD[4][1] = digitalRead(22);
keysD[4][2] = digitalRead(23);
keysD[4][3] = digitalRead(24);
keysD[4][4] = digitalRead(25);
keysD[4][5] = digitalRead(26);
keysD[5][0] = digitalRead(27);
keysD[5][1] = digitalRead(28);
keysD[5][2] = digitalRead(29);
keysD[5][3] = digitalRead(30);
keysD[5][4] = digitalRead(31);
//Keys 31-40
keysD[5][5] = digitalRead(32);
keysD[6][0] = digitalRead(33);
keysD[6][1] = digitalRead(34);
keysD[6][2] = digitalRead(35);
keysD[6][3] = digitalRead(36);
keysD[6][4] = digitalRead(37);
keysD[6][5] = digitalRead(38);
keysD[7][0] = digitalRead(39);
keysD[7][1] = digitalRead(40);
keysD[7][2] = digitalRead(41);
//Keys 41-50
keysD[7][3] = digitalRead(42);
keysD[7][4] = digitalRead(43);
keysD[7][5] = digitalRead(44);
keysD[8][0] = digitalRead(45);
keysD[8][1] = digitalRead(46);
keysD[8][2] = digitalRead(47);
keysD[8][3] = digitalRead(48);
keysD[8][4] = digitalRead(49);
keysD[8][5] = digitalRead(50);
keysD[9][0] = digitalRead(51);
//Keys 51-61
keysD[9][1] = digitalRead(52);
keysD[9][2] = digitalRead(53);
keysD[9][3] = digitalRead(A0);
keysD[9][4] = digitalRead(A1);
keysD[9][5] = digitalRead(A2);
keysD[10][0] = digitalRead(A3);
keysD[10][1] = digitalRead(A4);
keysD[10][2] = digitalRead(A5);
keysD[10][3] = digitalRead(A6);
keysD[10][4] = digitalRead(A7);
keysD[10][5] = digitalRead(A8);
pinMode(A12, INPUT);
//Return pins to Initialized state
//Pins 1-10
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(11, INPUT);
//Pins 11-20
pinMode(12, INPUT);
pinMode(13, INPUT);
pinMode(14, INPUT);
pinMode(15, INPUT);
pinMode(16, INPUT);
pinMode(17, INPUT);
pinMode(18, INPUT);
pinMode(19, INPUT);
pinMode(20, INPUT);
pinMode(21, INPUT);
//Pins 21-30
pinMode(22, INPUT);
pinMode(23, INPUT);
pinMode(24, INPUT);
pinMode(25, INPUT);
pinMode(26, INPUT);
pinMode(27, INPUT);
pinMode(28, INPUT);
pinMode(29, INPUT);
pinMode(30, INPUT);
pinMode(31, INPUT);
//Pins 31-40
pinMode(32, INPUT);
pinMode(33, INPUT);
pinMode(34, INPUT);
pinMode(35, INPUT);
pinMode(36, INPUT);
pinMode(37, INPUT);
pinMode(38, INPUT);
pinMode(39, INPUT);
pinMode(40, INPUT);
pinMode(41, INPUT);
//Pins 41-50
pinMode(42, INPUT);
pinMode(43, INPUT);
pinMode(44, INPUT);
pinMode(45, INPUT);
pinMode(46, INPUT);
pinMode(47, INPUT);
pinMode(48, INPUT);
pinMode(49, INPUT);
pinMode(50, INPUT);
pinMode(51, INPUT);
//Pins 51-61
pinMode(52, INPUT);
pinMode(53, INPUT);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
pinMode(A6, INPUT);
pinMode(A7, INPUT);
pinMode(A8, INPUT);
//Column Pins
pinMode(A9, INPUT);
pinMode(A10, INPUT);
pinMode(A11, INPUT);
pinMode(A12, INPUT);
//Pot Pins
pinMode(A13, INPUT);
pinMode(A14, INPUT);
pinMode(A15, INPUT);
/*
//Invert Keyboard data only if needed.
//Example only for 32 pedals of a pedalboard, first 32 keys of keyboard C.
//Column 1
if (keysC[0][0] == 0) {
keysC[0][0] = 1;
}
else
if (keysC[0][0] == 1) {
keysC[0][0] = 0;
}
//Column 2
if (keysC[1][0] == 0) {
keysC[1][0] = 1;
}
else
if (keysC[1][0] == 1) {
keysC[1][0] = 0;
}
if (keysC[1][1] == 0) {
keysC[1][1] = 1;
}
else
if (keysC[1][1] == 1) {
keysC[1][1] = 0;
}
if (keysC[1][2] == 0) {
keysC[1][2] = 1;
}
else
if (keysC[1][2] == 1) {
keysC[1][2] = 0;
}
if (keysC[1][3] == 0) {
keysC[1][3] = 1;
}
else
if (keysC[1][3] == 1) {
keysC[1][3] = 0;
}
if (keysC[1][4] == 0) {
keysC[1][4] = 1;
}
else
if (keysC[1][4] == 1) {
keysC[1][4] = 0;
}
if (keysC[1][5] == 0) {
keysC[1][5] = 1;
}
else
if (keysC[1][5] == 1) {
keysC[1][5] = 0;
}
//Column 3
if (keysC[2][0] == 0) {
keysC[2][0] = 1;
}
else
if (keysC[2][0] == 1) {
keysC[2][0] = 0;
}
if (keysC[2][1] == 0) {
keysC[2][1] = 1;
}
else
if (keysC[2][1] == 1) {
keysC[2][1] = 0;
}
if (keysC[2][2] == 0) {
keysC[2][2] = 1;
}
else
if (keysC[2][2] == 1) {
keysC[2][2] = 0;
}
if (keysC[2][3] == 0) {
keysC[2][3] = 1;
}
else
if (keysC[2][3] == 1) {
keysC[2][3] = 0;
}
if (keysC[2][4] == 0) {
keysC[2][4] = 1;
}
else
if (keysC[2][4] == 1) {
keysC[2][4] = 0;
}
if (keysC[2][5] == 0) {
keysC[2][5] = 1;
}
else
if (keysC[2][5] == 1) {
keysC[2][5] = 0;
}
//Column 4
if (keysC[3][0] == 0) {
keysC[3][0] = 1;
}
else
if (keysC[3][0] == 1) {
keysC[3][0] = 0;
}
if (keysC[3][1] == 0) {
keysC[3][1] = 1;
}
else
if (keysC[3][1] == 1) {
keysC[3][1] = 0;
}
if (keysC[3][2] == 0) {
keysC[3][2] = 1;
}
else
if (keysC[3][2] == 1) {
keysC[3][2] = 0;
}
if (keysC[3][3] == 0) {
keysC[3][3] = 1;
}
else
if (keysC[3][3] == 1) {
keysC[3][3] = 0;
}
if (keysC[3][4] == 0) {
keysC[3][4] = 1;
}
else
if (keysC[3][4] == 1) {
keysC[3][4] = 0;
}
if (keysC[3][5] == 0) {
keysC[3][5] = 1;
}
else
if (keysC[3][5] == 1) {
keysC[3][5] = 0;
}
//Column 5
if (keysC[4][0] == 0) {
keysC[4][0] = 1;
}
else
if (keysC[4][0] == 1) {
keysC[4][0] = 0;
}
if (keysC[4][1] == 0) {
keysC[4][1] = 1;
}
else
if (keysC[4][1] == 1) {
keysC[4][1] = 0;
}
if (keysC[4][2] == 0) {
keysC[4][2] = 1;
}
else
if (keysC[4][2] == 1) {
keysC[4][2] = 0;
}
if (keysC[4][3] == 0) {
keysC[4][3] = 1;
}
else
if (keysC[4][3] == 1) {
keysC[4][3] = 0;
}
if (keysC[4][4] == 0) {
keysC[4][4] = 1;
}
else
if (keysC[4][4] == 1) {
keysC[4][4] = 0;
}
if (keysC[4][5] == 0) {
keysC[4][5] = 1;
}
else
if (keysC[4][5] == 1) {
keysC[4][5] = 0;
}
//Column 6
if (keysC[5][0] == 0) {
keysC[5][0] = 1;
}
else
if (keysC[5][0] == 1) {
keysC[5][0] = 0;
}
if (keysC[5][1] == 0) {
keysC[5][1] = 1;
}
else
if (keysC[5][1] == 1) {
keysC[5][1] = 0;
}
if (keysC[5][2] == 0) {
keysC[5][2] = 1;
}
else
if (keysC[5][2] == 1) {
keysC[5][2] = 0;
}
if (keysC[5][3] == 0) {
keysC[5][3] = 1;
}
else
if (keysC[5][3] == 1) {
keysC[5][3] = 0;
}
if (keysC[5][4] == 0) {
keysC[5][4] = 1;
}
else
if (keysC[5][4] == 1) {
keysC[5][4] = 0;
}
if (keysC[5][5] == 0) {
keysC[5][5] = 1;
}
else
if (keysC[5][5] == 1) {
keysC[5][5] = 0;
}
//Column 7
if (keysC[6][0] == 0) {
keysC[6][0] = 1;
}
else
if (keysC[6][0] == 1) {
keysC[6][0] = 0;
}
*/
//Write Keyboard A
//A36
if ((keysA[0][0] == 0) and (lastA[0][0] == 0)) {
MidiSend(noteOn1, 36, velocity);
lastA[0][0] = 7;
}
if ((keysA[0][0] == 1) and (lastA[0][0] == 7)) {
MidiSend(noteOff1, 36, velocity);
lastA[0][0] = 0;
}
//A37
if ((keysA[1][0] == 0) and (lastA[1][0] == 0)) {
MidiSend(noteOn1, 37, velocity);
lastA[1][0] = 7;
}
if ((keysA[1][0] == 1) and (lastA[1][0] == 7)) {
MidiSend(noteOff1, 37, velocity);
lastA[1][0] = 0;
}
//A38
if ((keysA[1][1] == 0) and (lastA[1][1] == 0)) {
MidiSend(noteOn1, 38, velocity);
lastA[1][1] = 7;
}
//Write Midi Note Off
if ((keysA[1][1] == 1) and (lastA[1][1] == 7)) {
MidiSend(noteOff1, 38, velocity);
lastA[1][1] = 0;
}
//A39
if ((keysA[1][2] == 0) and (lastA[1][2] == 0)) {
MidiSend(noteOn1, 39, velocity);
lastA[1][2] = 7;
}
//Write Midi Note Off
if ((keysA[1][2] == 1) and (lastA[1][2] == 7)) {
MidiSend(noteOff1, 39, velocity);
lastA[1][2] = 0;
}
//A40
if ((keysA[1][3] == 0) and (lastA[1][3] == 0)) {
MidiSend(noteOn1, 40, velocity);
lastA[1][3] = 7;
}
//Write Midi Note Off
if ((keysA[1][3] == 1) and (lastA[1][3] == 7)) {
MidiSend(noteOff1, 40, velocity);
lastA[1][3] = 0;
}
//A41
if ((keysA[1][4] == 0) and (lastA[1][4] == 0)) {
MidiSend(noteOn1, 41, velocity);
lastA[1][4] = 7;
}
//Write Midi Note Off
if ((keysA[1][4] == 1) and (lastA[1][4] == 7)) {
MidiSend(noteOff1, 41, velocity);
lastA[1][4] = 0;
}
//A42
if ((keysA[1][5] == 0) and (lastA[1][5] == 0)) {
MidiSend(noteOn1, 42, velocity);
lastA[1][5] = 7;
}
//Write Midi Note Off
if ((keysA[1][5] == 1) and (lastA[1][5] == 7)) {
MidiSend(noteOff1, 42, velocity);
lastA[1][5] = 0;
}
//A43
if ((keysA[2][0] == 0) and (lastA[2][0] == 0)) {
MidiSend(noteOn1, 43, velocity);
lastA[2][0] = 7;
}
//Write Midi Note Off
if ((keysA[2][0] == 1) and (lastA[2][0] == 7)) {
MidiSend(noteOff1, 43, velocity);
lastA[2][0] = 0;
}
//A44
if ((keysA[2][1] == 0) and (lastA[2][1] == 0)) {
MidiSend(noteOn1, 44, velocity);
lastA[2][1] = 7;
}
//Write Midi Note Off
if ((keysA[2][1] == 1) and (lastA[2][1] == 7)) {
MidiSend(noteOff1, 44, velocity);
lastA[2][1] = 0;
}
//A45
if ((keysA[2][2] == 0) and (lastA[2][2] == 0)) {
MidiSend(noteOn1, 45, velocity);
lastA[2][2] = 7;
}
//Write Midi Note Off
if ((keysA[2][2] == 1) and (lastA[2][2] == 7)) {
MidiSend(noteOff1, 45, velocity);
lastA[2][2] = 0;
}
//A46
if ((keysA[2][3] == 0) and (lastA[2][3] == 0)) {
MidiSend(noteOn1, 46, velocity);
lastA[2][3] = 7;
}
//Write Midi Note Off
if ((keysA[2][3] == 1) and (lastA[2][3] == 7)) {
MidiSend(noteOff1, 46, velocity);
lastA[2][3] = 0;
}
//A47
if ((keysA[2][4] == 0) and (lastA[2][4] == 0)) {
MidiSend(noteOn1, 47, velocity);
lastA[2][4] = 7;
}
//Write Midi Note Off
if ((keysA[2][4] == 1) and (lastA[2][4] == 7)) {
MidiSend(noteOff1, 47, velocity);
lastA[2][4] = 0;
}
//A48
if ((keysA[2][5] == 0) and (lastA[2][5] == 0)) {
MidiSend(noteOn1, 48, velocity);
lastA[2][5] = 7;
}
//Write Midi Note Off
if ((keysA[2][5] == 1) and (lastA[2][5] == 7)) {
MidiSend(noteOff1, 48, velocity);
lastA[2][5] = 0;
}
//A49
if ((keysA[3][0] == 0) and (lastA[3][0] == 0)) {
MidiSend(noteOn1, 49, velocity);
lastA[3][0] = 7;
}
//Write Midi Note Off
if ((keysA[3][0] == 1) and (lastA[3][0] == 7)) {
MidiSend(noteOff1, 49, velocity);
lastA[3][0] = 0;
}
//A50
if ((keysA[3][1] == 0) and (lastA[3][1] == 0)) {
MidiSend(noteOn1, 50, velocity);
lastA[3][1] = 7;
}
//Write Midi Note Off
if ((keysA[3][1] == 1) and (lastA[3][1] == 7)) {
MidiSend(noteOff1, 50, velocity);
lastA[3][1] = 0;
}
//A51
if ((keysA[3][2] == 0) and (lastA[3][2] == 0)) {
MidiSend(noteOn1, 51, velocity);
lastA[3][2] = 7;
}
//Write Midi Note Off
if ((keysA[3][2] == 1) and (lastA[3][2] == 7)) {
MidiSend(noteOff1, 51, velocity);
lastA[3][2] = 0;
}
//A52
if ((keysA[3][3] == 0) and (lastA[3][3] == 0)) {
MidiSend(noteOn1, 52, velocity);
lastA[3][3] = 7;
}
//Write Midi Note Off
if ((keysA[3][3] == 1) and (lastA[3][3] == 7)) {
MidiSend(noteOff1, 52, velocity);
lastA[3][3] = 0;
}
//A53
if ((keysA[3][4] == 0) and (lastA[3][4] == 0)) {
MidiSend(noteOn1, 53, velocity);
lastA[3][4] = 7;
}
//Write Midi Note Off
if ((keysA[3][4] == 1) and (lastA[3][4] == 7)) {
MidiSend(noteOff1, 53, velocity);
lastA[3][4] = 0;
}
//A54
if ((keysA[3][5] == 0) and (lastA[3][5] == 0)) {
MidiSend(noteOn1, 54, velocity);
lastA[3][5] = 7;
}
//Write Midi Note Off
if ((keysA[3][5] == 1) and (lastA[3][5] == 7)) {
MidiSend(noteOff1, 54, velocity);
lastA[3][5] = 0;
}
//A55
if ((keysA[4][0] == 0) and (lastA[4][0] == 0)) {
MidiSend(noteOn1, 55, velocity);
lastA[4][0] = 7;
}
//Write Midi Note Off
if ((keysA[4][0] == 1) and (lastA[4][0] == 7)) {
MidiSend(noteOff1, 55, velocity);
lastA[4][0] = 0;
}
//A56
if ((keysA[4][1] == 0) and (lastA[4][1] == 0)) {
MidiSend(noteOn1, 56, velocity);
lastA[4][1] = 7;
}
//Write Midi Note Off
if ((keysA[4][1] == 1) and (lastA[4][1] == 7)) {
MidiSend(noteOff1, 56, velocity);
lastA[4][1] = 0;
}
//A57
if ((keysA[4][2] == 0) and (lastA[4][2] == 0)) {
MidiSend(noteOn1, 57, velocity);
lastA[4][2] = 7;
}
//Write Midi Note Off
if ((keysA[4][2] == 1) and (lastA[4][2] == 7)) {
MidiSend(noteOff1, 57, velocity);
lastA[4][2] = 0;
}
//A58
if ((keysA[4][3] == 0) and (lastA[4][3] == 0)) {
MidiSend(noteOn1, 58, velocity);
lastA[4][3] = 7;
}
//Write Midi Note Off
if ((keysA[4][3] == 1) and (lastA[4][3] == 7)) {
MidiSend(noteOff1, 58, velocity);
lastA[4][3] = 0;
}
//59
if ((keysA[4][4] == 0) and (lastA[4][4] == 0)) {
MidiSend(noteOn1, 59, velocity);
lastA[4][4] = 7;
}
//Write Midi Note Off
if ((keysA[4][4] == 1) and (lastA[4][4] == 7)) {
MidiSend(noteOff1, 59, velocity);
lastA[4][4] = 0;
}
//A60
if ((keysA[4][5] == 0) and (lastA[4][5] == 0)) {
MidiSend(noteOn1, 60, velocity);
lastA[4][5] = 7;
}
//Write Midi Note Off
if ((keysA[4][5] == 1) and (lastA[4][5] == 7)) {
MidiSend(noteOff1, 60, velocity);
lastA[4][5] = 0;
}
//A61
if ((keysA[5][0] == 0) and (lastA[5][0] == 0)) {
MidiSend(noteOn1, 61, velocity);
lastA[5][0] = 7;
}
//Write Midi Note Off
if ((keysA[5][0] == 1) and (lastA[5][0] == 7)) {
MidiSend(noteOff1, 61, velocity);
lastA[5][0] = 0;
}
//A62
if ((keysA[5][1] == 0) and (lastA[5][1] == 0)) {
MidiSend(noteOn1, 62, velocity);
lastA[5][1] = 7;
}
//Write Midi Note Off
if ((keysA[5][1] == 1) and (lastA[5][1] == 7)) {
MidiSend(noteOff1, 62, velocity);
lastA[5][1] = 0;
}
//A63
if ((keysA[5][2] == 0) and (lastA[5][2] == 0)) {
MidiSend(noteOn1, 63, velocity);
lastA[5][2] = 7;
}
//Write Midi Note Off
if ((keysA[5][2] == 1) and (lastA[5][2] == 7)) {
MidiSend(noteOff1, 63, velocity);
lastA[5][2] = 0;
}
//A64
if ((keysA[5][3] == 0) and (lastA[5][3] == 0)) {
MidiSend(noteOn1, 64, velocity);
lastA[5][3] = 7;
}
//Write Midi Note Off
if ((keysA[5][3] == 1) and (lastA[5][3] == 7)) {
MidiSend(noteOff1, 64, velocity);
lastA[5][3] = 0;
}
//A65
if ((keysA[5][4] == 0) and (lastA[5][4] == 0)) {
MidiSend(noteOn1, 65, velocity);
lastA[5][4] = 7;
}
//Write Midi Note Off
if ((keysA[5][4] == 1) and (lastA[5][4] == 7)) {
MidiSend(noteOff1, 65, velocity);
lastA[5][4] = 0;
}
//A66
if ((keysA[5][5] == 0) and (lastA[5][5] == 0)) {
MidiSend(noteOn1, 66, velocity);
lastA[5][5] = 7;
}
//Write Midi Note Off
if ((keysA[5][5] == 1) and (lastA[5][5] == 7)) {
MidiSend(noteOff1, 66, velocity);
lastA[5][5] = 0;
}
//A67
if ((keysA[6][0] == 0) and (lastA[6][0] == 0)) {
MidiSend(noteOn1, 67, velocity);
lastA[6][0] = 7;
}
//Write Midi Note Off
if ((keysA[6][0] == 1) and (lastA[6][0] == 7)) {
MidiSend(noteOff1, 67, velocity);
lastA[6][0] = 0;
}
//A68
if ((keysA[6][1] == 0) and (lastA[6][1] == 0)) {
MidiSend(noteOn1, 68, velocity);
lastA[6][1] = 7;
}
//Write Midi Note Off
if ((keysA[6][1] == 1) and (lastA[6][1] == 7)) {
MidiSend(noteOff1, 68, velocity);
lastA[6][1] = 0;
}
//A69
if ((keysA[6][2] == 0) and (lastA[6][2] == 0)) {
MidiSend(noteOn1, 69, velocity);
lastA[6][2] = 7;
}
//Write Midi Note Off
if ((keysA[6][2] == 1) and (lastA[6][2] == 7)) {
MidiSend(noteOff1, 69, velocity);
lastA[6][2] = 0;
}
//A70
if ((keysA[6][3] == 0) and (lastA[6][3] == 0)) {
MidiSend(noteOn1, 70, velocity);
lastA[6][3] = 7;
}
//Write Midi Note Off
if ((keysA[6][3] == 1) and (lastA[6][3] == 7)) {
MidiSend(noteOff1, 70, velocity);
lastA[6][3] = 0;
}
//A71
if ((keysA[6][4] == 0) and (lastA[6][4] == 0)) {
MidiSend(noteOn1, 71, velocity);
lastA[6][4] = 7;
}
//Write Midi Note Off
if ((keysA[6][4] == 1) and (lastA[6][4] == 7)) {
MidiSend(noteOff1, 71, velocity);
lastA[6][4] = 0;
}
//A72
if ((keysA[6][5] == 0) and (lastA[6][5] == 0)) {
MidiSend(noteOn1, 72, velocity);
lastA[6][5] = 7;
}
//Write Midi Note Off
if ((keysA[6][5] == 1) and (lastA[6][5] == 7)) {
MidiSend(noteOff1, 72, velocity);
lastA[6][5] = 0;
}
//A73
if ((keysA[7][0] == 0) and (lastA[7][0] == 0)) {
MidiSend(noteOn1, 73, velocity);
lastA[7][0] = 7;
}
//Write Midi Note Off
if ((keysA[7][0] == 1) and (lastA[7][0] == 7)) {
MidiSend(noteOff1, 73, velocity);
lastA[7][0] = 0;
}
//A74
if ((keysA[7][1] == 0) and (lastA[7][1] == 0)) {
MidiSend(noteOn1, 74, velocity);
lastA[7][1] = 7;
}
//Write Midi Note Off
if ((keysA[7][1] == 1) and (lastA[7][1] == 7)) {
MidiSend(noteOff1, 74, velocity);
lastA[7][1] = 0;
}
//A75
if ((keysA[7][2] == 0) and (lastA[7][2] == 0)) {
MidiSend(noteOn1, 75, velocity);
lastA[7][2] = 7;
}
//Write Midi Note Off
if ((keysA[7][2] == 1) and (lastA[7][2] == 7)) {
MidiSend(noteOff1, 75, velocity);
lastA[7][2] = 0;
}
//A76
if ((keysA[7][3] == 0) and (lastA[7][3] == 0)) {
MidiSend(noteOn1, 76, velocity);
lastA[7][3] = 7;
}
//Write Midi Note Off
if ((keysA[7][3] == 1) and (lastA[7][3] == 7)) {
MidiSend(noteOff1, 76, velocity);
lastA[7][3] = 0;
}
//A77
if ((keysA[7][4] == 0) and (lastA[7][4] == 0)) {
MidiSend(noteOn1, 77, velocity);
lastA[7][4] = 7;
}
//Write Midi Note Off
if ((keysA[7][4] == 1) and (lastA[7][4] == 7)) {
MidiSend(noteOff1, 77, velocity);
lastA[7][4] = 0;
}
//A78
if ((keysA[7][5] == 0) and (lastA[7][5] == 0)) {
MidiSend(noteOn1, 78, velocity);
lastA[7][5] = 7;
}
//Write Midi Note Off
if ((keysA[7][5] == 1) and (lastA[7][5] == 7)) {
MidiSend(noteOff1, 78, velocity);
lastA[7][5] = 0;
}
//A79
if ((keysA[8][0] == 0) and (lastA[8][0] == 0)) {
MidiSend(noteOn1, 79, velocity);
lastA[8][0] = 7;
}
//Write Midi Note Off
if ((keysA[8][0] == 1) and (lastA[8][0] == 7)) {
MidiSend(noteOff1, 79, velocity);
lastA[8][0] = 0;
}
//A80
if ((keysA[8][1] == 0) and (lastA[8][1] == 0)) {
MidiSend(noteOn1, 80, velocity);
lastA[8][1] = 7;
}
//Write Midi Note Off
if ((keysA[8][1] == 1) and (lastA[8][1] == 7)) {
MidiSend(noteOff1, 80, velocity);
lastA[8][1] = 0;
}
//A81
if ((keysA[8][2] == 0) and (lastA[8][2] == 0)) {
MidiSend(noteOn1, 81, velocity);
lastA[8][2] = 7;
}
//Write Midi Note Off
if ((keysA[8][2] == 1) and (lastA[8][2] == 7)) {
MidiSend(noteOff1, 81, velocity);
lastA[8][2] = 0;
}
//A82
if ((keysA[8][3] == 0) and (lastA[8][3] == 0)) {
MidiSend(noteOn1, 82, velocity);
lastA[8][3] = 7;
}
//Write Midi Note Off
if ((keysA[8][3] == 1) and (lastA[8][3] == 7)) {
MidiSend(noteOff1, 82, velocity);
lastA[8][3] = 0;
}
//A83
if ((keysA[8][4] == 0) and (lastA[8][4] == 0)) {
MidiSend(noteOn1, 83, velocity);
lastA[8][4] = 7;
}
//Write Midi Note Off
if ((keysA[8][4] == 1) and (lastA[8][4] == 7)) {
MidiSend(noteOff1, 83, velocity);
lastA[8][4] = 0;
}
//A84
if ((keysA[8][5] == 0) and (lastA[8][5] == 0)) {
MidiSend(noteOn1, 84, velocity);
lastA[8][5] = 7;
}
//Write Midi Note Off
if ((keysA[8][5] == 1) and (lastA[8][5] == 7)) {
MidiSend(noteOff1, 84, velocity);
lastA[8][5] = 0;
}
//A85
if ((keysA[9][0] == 0) and (lastA[9][0] == 0)) {
MidiSend(noteOn1, 85, velocity);
lastA[9][0] = 7;
}
//Write Midi Note Off
if ((keysA[9][0] == 1) and (lastA[9][0] == 7)) {
MidiSend(noteOff1, 85, velocity);
lastA[9][0] = 0;
}
//A86
if ((keysA[9][1] == 0) and (lastA[9][1] == 0)) {
MidiSend(noteOn1, 86, velocity);
lastA[9][1] = 7;
}
//Write Midi Note Off
if ((keysA[9][1] == 1) and (lastA[9][1] == 7)) {
MidiSend(noteOff1, 86, velocity);
lastA[9][1] = 0;
}
//A87
if ((keysA[9][2] == 0) and (lastA[9][2] == 0)) {
MidiSend(noteOn1, 87, velocity);
lastA[9][2] = 7;
}
//Write Midi Note Off
if ((keysA[9][2] == 1) and (lastA[9][2] == 7)) {
MidiSend(noteOff1, 87, velocity);
lastA[9][2] = 0;
}
//A88
if ((keysA[9][3] == 0) and (lastA[9][3] == 0)) {
MidiSend(noteOn1, 88, velocity);
lastA[9][3] = 7;
}
//Write Midi Note Off
if ((keysA[9][3] == 1) and (lastA[9][3] == 7)) {
MidiSend(noteOff1, 88, velocity);
lastA[9][3] = 0;
}
//A89
if ((keysA[9][4] == 0) and (lastA[9][4] == 0)) {
MidiSend(noteOn1, 89, velocity);
lastA[9][4] = 7;
}
//Write Midi Note Off
if ((keysA[9][4] == 1) and (lastA[9][4] == 7)) {
MidiSend(noteOff1, 89, velocity);
lastA[9][4] = 0;
}
//A90
if ((keysA[9][5] == 0) and (lastA[9][5] == 0)) {
MidiSend(noteOn1, 90, velocity);
lastA[9][5] = 7;
}
//Write Midi Note Off
if ((keysA[9][5] == 1) and (lastA[9][5] == 7)) {
MidiSend(noteOff1, 90, velocity);
lastA[9][5] = 0;
}
//A91
if ((keysA[10][0] == 0) and (lastA[10][0] == 0)) {
MidiSend(noteOn1, 91, velocity);
lastA[10][0] = 7;
}
//Write Midi Note Off
if ((keysA[10][0] == 1) and (lastA[10][0] == 7)) {
MidiSend(noteOff1, 91, velocity);
lastA[10][0] = 0;
}
//A92
if ((keysA[10][1] == 0) and (lastA[10][1] == 0)) {
MidiSend(noteOn1, 92, velocity);
lastA[10][1] = 7;
}
//Write Midi Note Off
if ((keysA[10][1] == 1) and (lastA[10][1] == 7)) {
MidiSend(noteOff1, 92, velocity);
lastA[10][1] = 0;
}
//A93
if ((keysA[10][2] == 0) and (lastA[10][2] == 0)) {
MidiSend(noteOn1, 93, velocity);
lastA[10][2] = 7;
}
//Write Midi Note Off
if ((keysA[10][2] == 1) and (lastA[10][2] == 7)) {
MidiSend(noteOff1, 93, velocity);
lastA[10][2] = 0;
}
//A94
if ((keysA[10][3] == 0) and (lastA[10][3] == 0)) {
MidiSend(noteOn1, 94, velocity);
lastA[10][3] = 7;
}
//Write Midi Note Off
if ((keysA[10][3] == 1) and (lastA[10][3] == 7)) {
MidiSend(noteOff1, 94, velocity);
lastA[10][3] = 0;
}
//A95
if ((keysA[10][4] == 0) and (lastA[10][4] == 0)) {
MidiSend(noteOn1, 95, velocity);
lastA[10][4] = 7;
}
//Write Midi Note Off
if ((keysA[10][4] == 1) and (lastA[10][4] == 7)) {
MidiSend(noteOff1, 95, velocity);
lastA[10][4] = 0;
}
//A96
if ((keysA[10][5] == 0) and (lastA[10][5] == 0)) {
MidiSend(noteOn1, 96, velocity);
lastA[10][5] = 7;
}
//Write Midi Note Off
if ((keysA[10][5] == 1) and (lastA[10][5] == 7)) {
MidiSend(noteOff1, 96, velocity);
lastA[10][5] = 0;
}
//Write Keyboard B
//B36
if ((keysB[0][0] == 0) and (lastB[0][0] == 0)) {
MidiSend(noteOn2, 36, velocity);
lastB[0][0] = 7;
}
if ((keysB[0][0] == 1) and (lastB[0][0] == 7)) {
MidiSend(noteOff2, 36, velocity);
lastB[0][0] = 0;
}
//B37
if ((keysB[1][0] == 0) and (lastB[1][0] == 0)) {
MidiSend(noteOn2, 37, velocity);
lastB[1][0] = 7;
}
if ((keysB[1][0] == 1) and (lastB[1][0] == 7)) {
MidiSend(noteOff2, 37, velocity);
lastB[1][0] = 0;
}
//B38
if ((keysB[1][1] == 0) and (lastB[1][1] == 0)) {
MidiSend(noteOn2, 38, velocity);
lastB[1][1] = 7;
}
//Write Midi Note Off
if ((keysB[1][1] == 1) and (lastB[1][1] == 7)) {
MidiSend(noteOff2, 38, velocity);
lastB[1][1] = 0;
}
//B39
if ((keysB[1][2] == 0) and (lastB[1][2] == 0)) {
MidiSend(noteOn2, 39, velocity);
lastB[1][2] = 7;
}
//Write Midi Note Off
if ((keysB[1][2] == 1) and (lastB[1][2] == 7)) {
MidiSend(noteOff2, 39, velocity);
lastB[1][2] = 0;
}
//B40
if ((keysB[1][3] == 0) and (lastB[1][3] == 0)) {
MidiSend(noteOn2, 40, velocity);
lastB[1][3] = 7;
}
//Write Midi Note Off
if ((keysB[1][3] == 1) and (lastB[1][3] == 7)) {
MidiSend(noteOff2, 40, velocity);
lastB[1][3] = 0;
}
//B41
if ((keysB[1][4] == 0) and (lastB[1][4] == 0)) {
MidiSend(noteOn2, 41, velocity);
lastB[1][4] = 7;
}
//Write Midi Note Off
if ((keysB[1][4] == 1) and (lastB[1][4] == 7)) {
MidiSend(noteOff2, 41, velocity);
lastB[1][4] = 0;
}
//B42
if ((keysB[1][5] == 0) and (lastB[1][5] == 0)) {
MidiSend(noteOn2, 42, velocity);
lastB[1][5] = 7;
}
//Write Midi Note Off
if ((keysB[1][5] == 1) and (lastB[1][5] == 7)) {
MidiSend(noteOff2, 42, velocity);
lastB[1][5] = 0;
}
//B43
if ((keysB[2][0] == 0) and (lastB[2][0] == 0)) {
MidiSend(noteOn2, 43, velocity);
lastB[2][0] = 7;
}
//Write Midi Note Off
if ((keysB[2][0] == 1) and (lastB[2][0] == 7)) {
MidiSend(noteOff2, 43, velocity);
lastB[2][0] = 0;
}
//B44
if ((keysB[2][1] == 0) and (lastB[2][1] == 0)) {
MidiSend(noteOn2, 44, velocity);
lastB[2][1] = 7;
}
//Write Midi Note Off
if ((keysB[2][1] == 1) and (lastB[2][1] == 7)) {
MidiSend(noteOff2, 44, velocity);
lastB[2][1] = 0;
}
//B45
if ((keysB[2][2] == 0) and (lastB[2][2] == 0)) {
MidiSend(noteOn2, 45, velocity);
lastB[2][2] = 7;
}
//Write Midi Note Off
if ((keysB[2][2] == 1) and (lastB[2][2] == 7)) {
MidiSend(noteOff2, 45, velocity);
lastB[2][2] = 0;
}
//B46
if ((keysB[2][3] == 0) and (lastB[2][3] == 0)) {
MidiSend(noteOn2, 46, velocity);
lastB[2][3] = 7;
}
//Write Midi Note Off
if ((keysB[2][3] == 1) and (lastB[2][3] == 7)) {
MidiSend(noteOff2, 46, velocity);
lastB[2][3] = 0;
}
//B47
if ((keysB[2][4] == 0) and (lastB[2][4] == 0)) {
MidiSend(noteOn2, 47, velocity);
lastB[2][4] = 7;
}
//Write Midi Note Off
if ((keysB[2][4] == 1) and (lastB[2][4] == 7)) {
MidiSend(noteOff2, 47, velocity);
lastB[2][4] = 0;
}
//B48
if ((keysB[2][5] == 0) and (lastB[2][5] == 0)) {
MidiSend(noteOn2, 48, velocity);
lastB[2][5] = 7;
}
//Write Midi Note Off
if ((keysB[2][5] == 1) and (lastB[2][5] == 7)) {
MidiSend(noteOff2, 48, velocity);
lastB[2][5] = 0;
}
//B49
if ((keysB[3][0] == 0) and (lastB[3][0] == 0)) {
MidiSend(noteOn2, 49, velocity);
lastB[3][0] = 7;
}
//Write Midi Note Off
if ((keysB[3][0] == 1) and (lastB[3][0] == 7)) {
MidiSend(noteOff2, 49, velocity);
lastB[3][0] = 0;
}
//B50
if ((keysB[3][1] == 0) and (lastB[3][1] == 0)) {
MidiSend(noteOn2, 50, velocity);
lastB[3][1] = 7;
}
//Write Midi Note Off
if ((keysB[3][1] == 1) and (lastB[3][1] == 7)) {
MidiSend(noteOff2, 50, velocity);
lastB[3][1] = 0;
}
//B51
if ((keysB[3][2] == 0) and (lastB[3][2] == 0)) {
MidiSend(noteOn2, 51, velocity);
lastB[3][2] = 7;
}
//Write Midi Note Off
if ((keysB[3][2] == 1) and (lastB[3][2] == 7)) {
MidiSend(noteOff2, 51, velocity);
lastB[3][2] = 0;
}
//B52
if ((keysB[3][3] == 0) and (lastB[3][3] == 0)) {
MidiSend(noteOn2, 52, velocity);
lastB[3][3] = 7;
}
//Write Midi Note Off
if ((keysB[3][3] == 1) and (lastB[3][3] == 7)) {
MidiSend(noteOff2, 52, velocity);
lastB[3][3] = 0;
}
//B53
if ((keysB[3][4] == 0) and (lastB[3][4] == 0)) {
MidiSend(noteOn2, 53, velocity);
lastB[3][4] = 7;
}
//Write Midi Note Off
if ((keysB[3][4] == 1) and (lastB[3][4] == 7)) {
MidiSend(noteOff2, 53, velocity);
lastB[3][4] = 0;
}
//B54
if ((keysB[3][5] == 0) and (lastB[3][5] == 0)) {
MidiSend(noteOn2, 54, velocity);
lastB[3][5] = 7;
}
//Write Midi Note Off
if ((keysB[3][5] == 1) and (lastB[3][5] == 7)) {
MidiSend(noteOff2, 54, velocity);
lastB[3][5] = 0;
}
//B55
if ((keysB[4][0] == 0) and (lastB[4][0] == 0)) {
MidiSend(noteOn2, 55, velocity);
lastB[4][0] = 7;
}
//Write Midi Note Off
if ((keysB[4][0] == 1) and (lastB[4][0] == 7)) {
MidiSend(noteOff2, 55, velocity);
lastB[4][0] = 0;
}
//B56
if ((keysB[4][1] == 0) and (lastB[4][1] == 0)) {
MidiSend(noteOn2, 56, velocity);
lastB[4][1] = 7;
}
//Write Midi Note Off
if ((keysB[4][1] == 1) and (lastB[4][1] == 7)) {
MidiSend(noteOff2, 56, velocity);
lastB[4][1] = 0;
}
//B57
if ((keysB[4][2] == 0) and (lastB[4][2] == 0)) {
MidiSend(noteOn2, 57, velocity);
lastB[4][2] = 7;
}
//Write Midi Note Off
if ((keysB[4][2] == 1) and (lastB[4][2] == 7)) {
MidiSend(noteOff2, 57, velocity);
lastB[4][2] = 0;
}
//B58
if ((keysB[4][3] == 0) and (lastB[4][3] == 0)) {
MidiSend(noteOn2, 58, velocity);
lastB[4][3] = 7;
}
//Write Midi Note Off
if ((keysB[4][3] == 1) and (lastB[4][3] == 7)) {
MidiSend(noteOff2, 58, velocity);
lastB[4][3] = 0;
}
//B59
if ((keysB[4][4] == 0) and (lastB[4][4] == 0)) {
MidiSend(noteOn2, 59, velocity);
lastB[4][4] = 7;
}
//Write Midi Note Off
if ((keysB[4][4] == 1) and (lastB[4][4] == 7)) {
MidiSend(noteOff2, 59, velocity);
lastB[4][4] = 0;
}
//B60
if ((keysB[4][5] == 0) and (lastB[4][5] == 0)) {
MidiSend(noteOn2, 60, velocity);
lastB[4][5] = 7;
}
//Write Midi Note Off
if ((keysB[4][5] == 1) and (lastB[4][5] == 7)) {
MidiSend(noteOff2, 60, velocity);
lastB[4][5] = 0;
}
//B61
if ((keysB[5][0] == 0) and (lastB[5][0] == 0)) {
MidiSend(noteOn2, 61, velocity);
lastB[5][0] = 7;
}
//Write Midi Note Off
if ((keysB[5][0] == 1) and (lastB[5][0] == 7)) {
MidiSend(noteOff2, 61, velocity);
lastB[5][0] = 0;
}
//B62
if ((keysB[5][1] == 0) and (lastB[5][1] == 0)) {
MidiSend(noteOn2, 62, velocity);
lastB[5][1] = 7;
}
//Write Midi Note Off
if ((keysB[5][1] == 1) and (lastB[5][1] == 7)) {
MidiSend(noteOff2, 62, velocity);
lastB[5][1] = 0;
}
//B63
if ((keysB[5][2] == 0) and (lastB[5][2] == 0)) {
MidiSend(noteOn2, 63, velocity);
lastB[5][2] = 7;
}
//Write Midi Note Off
if ((keysB[5][2] == 1) and (lastB[5][2] == 7)) {
MidiSend(noteOff2, 63, velocity);
lastB[5][2] = 0;
}
//B64
if ((keysB[5][3] == 0) and (lastB[5][3] == 0)) {
MidiSend(noteOn2, 64, velocity);
lastB[5][3] = 7;
}
//Write Midi Note Off
if ((keysB[5][3] == 1) and (lastB[5][3] == 7)) {
MidiSend(noteOff2, 64, velocity);
lastB[5][3] = 0;
}
//B65
if ((keysB[5][4] == 0) and (lastB[5][4] == 0)) {
MidiSend(noteOn2, 65, velocity);
lastB[5][4] = 7;
}
//Write Midi Note Off
if ((keysB[5][4] == 1) and (lastB[5][4] == 7)) {
MidiSend(noteOff2, 65, velocity);
lastB[5][4] = 0;
}
//B66
if ((keysB[5][5] == 0) and (lastB[5][5] == 0)) {
MidiSend(noteOn2, 66, velocity);
lastB[5][5] = 7;
}
//Write Midi Note Off
if ((keysB[5][5] == 1) and (lastB[5][5] == 7)) {
MidiSend(noteOff2, 66, velocity);
lastB[5][5] = 0;
}
//B67
if ((keysB[6][0] == 0) and (lastB[6][0] == 0)) {
MidiSend(noteOn2, 67, velocity);
lastB[6][0] = 7;
}
//Write Midi Note Off
if ((keysB[6][0] == 1) and (lastB[6][0] == 7)) {
MidiSend(noteOff2, 67, velocity);
lastB[6][0] = 0;
}
//B68
if ((keysB[6][1] == 0) and (lastB[6][1] == 0)) {
MidiSend(noteOn2, 68, velocity);
lastB[6][1] = 7;
}
//Write Midi Note Off
if ((keysB[6][1] == 1) and (lastB[6][1] == 7)) {
MidiSend(noteOff2, 68, velocity);
lastB[6][1] = 0;
}
//B69
if ((keysB[6][2] == 0) and (lastB[6][2] == 0)) {
MidiSend(noteOn2, 69, velocity);
lastB[6][2] = 7;
}
//Write Midi Note Off
if ((keysB[6][2] == 1) and (lastB[6][2] == 7)) {
MidiSend(noteOff2, 69, velocity);
lastB[6][2] = 0;
}
//B70
if ((keysB[6][3] == 0) and (lastB[6][3] == 0)) {
MidiSend(noteOn2, 70, velocity);
lastB[6][3] = 7;
}
//Write Midi Note Off
if ((keysB[6][3] == 1) and (lastB[6][3] == 7)) {
MidiSend(noteOff2, 70, velocity);
lastB[6][3] = 0;
}
//B71
if ((keysB[6][4] == 0) and (lastB[6][4] == 0)) {
MidiSend(noteOn2, 71, velocity);
lastB[6][4] = 7;
}
//Write Midi Note Off
if ((keysB[6][4] == 1) and (lastB[6][4] == 7)) {
MidiSend(noteOff2, 71, velocity);
lastB[6][4] = 0;
}
//B72
if ((keysB[6][5] == 0) and (lastB[6][5] == 0)) {
MidiSend(noteOn2, 72, velocity);
lastB[6][5] = 7;
}
//Write Midi Note Off
if ((keysB[6][5] == 1) and (lastB[6][5] == 7)) {
MidiSend(noteOff2, 72, velocity);
lastB[6][5] = 0;
}
//B73
if ((keysB[7][0] == 0) and (lastB[7][0] == 0)) {
MidiSend(noteOn2, 73, velocity);
lastB[7][0] = 7;
}
//Write Midi Note Off
if ((keysB[7][0] == 1) and (lastB[7][0] == 7)) {
MidiSend(noteOff2, 73, velocity);
lastB[7][0] = 0;
}
//B74
if ((keysB[7][1] == 0) and (lastB[7][1] == 0)) {
MidiSend(noteOn2, 74, velocity);
lastB[7][1] = 7;
}
//Write Midi Note Off
if ((keysB[7][1] == 1) and (lastB[7][1] == 7)) {
MidiSend(noteOff2, 74, velocity);
lastB[7][1] = 0;
}
//B75
if ((keysB[7][2] == 0) and (lastB[7][2] == 0)) {
MidiSend(noteOn2, 75, velocity);
lastB[7][2] = 7;
}
//Write Midi Note Off
if ((keysB[7][2] == 1) and (lastB[7][2] == 7)) {
MidiSend(noteOff2, 75, velocity);
lastB[7][2] = 0;
}
//B76
if ((keysB[7][3] == 0) and (lastB[7][3] == 0)) {
MidiSend(noteOn2, 76, velocity);
lastB[7][3] = 7;
}
//Write Midi Note Off
if ((keysB[7][3] == 1) and (lastB[7][3] == 7)) {
MidiSend(noteOff2, 76, velocity);
lastB[7][3] = 0;
}
//B77
if ((keysB[7][4] == 0) and (lastB[7][4] == 0)) {
MidiSend(noteOn2, 77, velocity);
lastB[7][4] = 7;
}
//Write Midi Note Off
if ((keysB[7][4] == 1) and (lastB[7][4] == 7)) {
MidiSend(noteOff2, 77, velocity);
lastB[7][4] = 0;
}
//B78
if ((keysB[7][5] == 0) and (lastB[7][5] == 0)) {
MidiSend(noteOn2, 78, velocity);
lastB[7][5] = 7;
}
//Write Midi Note Off
if ((keysB[7][5] == 1) and (lastB[7][5] == 7)) {
MidiSend(noteOff2, 78, velocity);
lastB[7][5] = 0;
}
//B79
if ((keysB[8][0] == 0) and (lastB[8][0] == 0)) {
MidiSend(noteOn2, 79, velocity);
lastB[8][0] = 7;
}
//Write Midi Note Off
if ((keysB[8][0] == 1) and (lastB[8][0] == 7)) {
MidiSend(noteOff2, 79, velocity);
lastB[8][0] = 0;
}
//B80
if ((keysB[8][1] == 0) and (lastB[8][1] == 0)) {
MidiSend(noteOn2, 80, velocity);
lastB[8][1] = 7;
}
//Write Midi Note Off
if ((keysB[8][1] == 1) and (lastB[8][1] == 7)) {
MidiSend(noteOff2, 80, velocity);
lastB[8][1] = 0;
}
//B81
if ((keysB[8][2] == 0) and (lastB[8][2] == 0)) {
MidiSend(noteOn2, 81, velocity);
lastB[8][2] = 7;
}
//Write Midi Note Off
if ((keysB[8][2] == 1) and (lastB[8][2] == 7)) {
MidiSend(noteOff2, 81, velocity);
lastB[8][2] = 0;
}
//B82
if ((keysB[8][3] == 0) and (lastB[8][3] == 0)) {
MidiSend(noteOn2, 82, velocity);
lastB[8][3] = 7;
}
//Write Midi Note Off
if ((keysB[8][3] == 1) and (lastB[8][3] == 7)) {
MidiSend(noteOff2, 82, velocity);
lastB[8][3] = 0;
}
//B83
if ((keysB[8][4] == 0) and (lastB[8][4] == 0)) {
MidiSend(noteOn2, 83, velocity);
lastB[8][4] = 7;
}
//Write Midi Note Off
if ((keysB[8][4] == 1) and (lastB[8][4] == 7)) {
MidiSend(noteOff2, 83, velocity);
lastB[8][4] = 0;
}
//B84
if ((keysB[8][5] == 0) and (lastB[8][5] == 0)) {
MidiSend(noteOn2, 84, velocity);
lastB[8][5] = 7;
}
//Write Midi Note Off
if ((keysB[8][5] == 1) and (lastB[8][5] == 7)) {
MidiSend(noteOff2, 84, velocity);
lastB[8][5] = 0;
}
//B85
if ((keysB[9][0] == 0) and (lastB[9][0] == 0)) {
MidiSend(noteOn2, 85, velocity);
lastB[9][0] = 7;
}
//Write Midi Note Off
if ((keysB[9][0] == 1) and (lastB[9][0] == 7)) {
MidiSend(noteOff2, 85, velocity);
lastB[9][0] = 0;
}
//B86
if ((keysB[9][1] == 0) and (lastB[9][1] == 0)) {
MidiSend(noteOn2, 86, velocity);
lastB[9][1] = 7;
}
//Write Midi Note Off
if ((keysB[9][1] == 1) and (lastB[9][1] == 7)) {
MidiSend(noteOff2, 86, velocity);
lastB[9][1] = 0;
}
//B87
if ((keysB[9][2] == 0) and (lastB[9][2] == 0)) {
MidiSend(noteOn2, 87, velocity);
lastB[9][2] = 7;
}
//Write Midi Note Off
if ((keysB[9][2] == 1) and (lastB[9][2] == 7)) {
MidiSend(noteOff2, 87, velocity);
lastB[9][2] = 0;
}
//B88
if ((keysB[9][3] == 0) and (lastB[9][3] == 0)) {
MidiSend(noteOn2, 88, velocity);
lastB[9][3] = 7;
}
//Write Midi Note Off
if ((keysB[9][3] == 1) and (lastB[9][3] == 7)) {
MidiSend(noteOff2, 88, velocity);
lastB[9][3] = 0;
}
//B89
if ((keysB[9][4] == 0) and (lastB[9][4] == 0)) {
MidiSend(noteOn2, 89, velocity);
lastB[9][4] = 7;
}
//Write Midi Note Off
if ((keysB[9][4] == 1) and (lastB[9][4] == 7)) {
MidiSend(noteOff2, 89, velocity);
lastB[9][4] = 0;
}
//B90
if ((keysB[9][5] == 0) and (lastB[9][5] == 0)) {
MidiSend(noteOn2, 90, velocity);
lastB[9][5] = 7;
}
//Write Midi Note Off
if ((keysB[9][5] == 1) and (lastB[9][5] == 7)) {
MidiSend(noteOff2, 90, velocity);
lastB[9][5] = 0;
}
//B91
if ((keysB[10][0] == 0) and (lastB[10][0] == 0)) {
MidiSend(noteOn2, 91, velocity);
lastB[10][0] = 7;
}
//Write Midi Note Off
if ((keysB[10][0] == 1) and (lastB[10][0] == 7)) {
MidiSend(noteOff2, 91, velocity);
lastB[10][0] = 0;
}
//B92
if ((keysB[10][1] == 0) and (lastB[10][1] == 0)) {
MidiSend(noteOn2, 92, velocity);
lastB[10][1] = 7;
}
//Write Midi Note Off
if ((keysB[10][1] == 1) and (lastB[10][1] == 7)) {
MidiSend(noteOff2, 92, velocity);
lastB[10][1] = 0;
}
//B93
if ((keysB[10][2] == 0) and (lastB[10][2] == 0)) {
MidiSend(noteOn2, 93, velocity);
lastB[10][2] = 7;
}
//Write Midi Note Off
if ((keysB[10][2] == 1) and (lastB[10][2] == 7)) {
MidiSend(noteOff2, 93, velocity);
lastB[10][2] = 0;
}
//B94
if ((keysB[10][3] == 0) and (lastB[10][3] == 0)) {
MidiSend(noteOn2, 94, velocity);
lastB[10][3] = 7;
}
//Write Midi Note Off
if ((keysB[10][3] == 1) and (lastB[10][3] == 7)) {
MidiSend(noteOff2, 94, velocity);
lastB[10][3] = 0;
}
//B95
if ((keysB[10][4] == 0) and (lastB[10][4] == 0)) {
MidiSend(noteOn2, 95, velocity);
lastB[10][4] = 7;
}
//Write Midi Note Off
if ((keysB[10][4] == 1) and (lastB[10][4] == 7)) {
MidiSend(noteOff2, 95, velocity);
lastB[10][4] = 0;
}
//B96
if ((keysB[10][5] == 0) and (lastB[10][5] == 0)) {
MidiSend(noteOn2, 96, velocity);
lastB[10][5] = 7;
}
//Write Midi Note Off
if ((keysB[10][5] == 1) and (lastB[10][5] == 7)) {
MidiSend(noteOff2, 96, velocity);
lastB[10][5] = 0;
}
//Write Keyboard C
//C36
if ((keysC[0][0] == 0) and (lastC[0][0] == 0)) {
MidiSend(noteOn3, 36, velocity);
lastC[0][0] = 7;
}
if ((keysC[0][0] == 1) and (lastC[0][0] == 7)) {
MidiSend(noteOff3, 36, velocity);
lastC[0][0] = 0;
}
//C37
if ((keysC[1][0] == 0) and (lastC[1][0] == 0)) {
MidiSend(noteOn3, 37, velocity);
lastC[1][0] = 7;
}
if ((keysC[1][0] == 1) and (lastC[1][0] == 7)) {
MidiSend(noteOff3, 37, velocity);
lastC[1][0] = 0;
}
//C38
if ((keysC[1][1] == 0) and (lastC[1][1] == 0)) {
MidiSend(noteOn3, 38, velocity);
lastC[1][1] = 7;
}
//Write Midi Note Off
if ((keysC[1][1] == 1) and (lastC[1][1] == 7)) {
MidiSend(noteOff3, 38, velocity);
lastC[1][1] = 0;
}
//C39
if ((keysC[1][2] == 0) and (lastC[1][2] == 0)) {
MidiSend(noteOn3, 39, velocity);
lastC[1][2] = 7;
}
//Write Midi Note Off
if ((keysC[1][2] == 1) and (lastC[1][2] == 7)) {
MidiSend(noteOff3, 39, velocity);
lastC[1][2] = 0;
}
//C40
if ((keysC[1][3] == 0) and (lastC[1][3] == 0)) {
MidiSend(noteOn3, 40, velocity);
lastC[1][3] = 7;
}
//Write Midi Note Off
if ((keysC[1][3] == 1) and (lastC[1][3] == 7)) {
MidiSend(noteOff3, 40, velocity);
lastC[1][3] = 0;
}
//C41
if ((keysC[1][4] == 0) and (lastC[1][4] == 0)) {
MidiSend(noteOn3, 41, velocity);
lastC[1][4] = 7;
}
//Write Midi Note Off
if ((keysC[1][4] == 1) and (lastC[1][4] == 7)) {
MidiSend(noteOff3, 41, velocity);
lastC[1][4] = 0;
}
//C42
if ((keysC[1][5] == 0) and (lastC[1][5] == 0)) {
MidiSend(noteOn3, 42, velocity);
lastC[1][5] = 7;
}
//Write Midi Note Off
if ((keysC[1][5] == 1) and (lastC[1][5] == 7)) {
MidiSend(noteOff3, 42, velocity);
lastC[1][5] = 0;
}
//C43
if ((keysC[2][0] == 0) and (lastC[2][0] == 0)) {
MidiSend(noteOn3, 43, velocity);
lastC[2][0] = 7;
}
//Write Midi Note Off
if ((keysC[2][0] == 1) and (lastC[2][0] == 7)) {
MidiSend(noteOff3, 43, velocity);
lastC[2][0] = 0;
}
//C44
if ((keysC[2][1] == 0) and (lastC[2][1] == 0)) {
MidiSend(noteOn3, 44, velocity);
lastC[2][1] = 7;
}
//Write Midi Note Off
if ((keysC[2][1] == 1) and (lastC[2][1] == 7)) {
MidiSend(noteOff3, 44, velocity);
lastC[2][1] = 0;
}
//B45
if ((keysC[2][2] == 0) and (lastC[2][2] == 0)) {
MidiSend(noteOn3, 45, velocity);
lastC[2][2] = 7;
}
//Write Midi Note Off
if ((keysC[2][2] == 1) and (lastC[2][2] == 7)) {
MidiSend(noteOff3, 45, velocity);
lastC[2][2] = 0;
}
//C46
if ((keysC[2][3] == 0) and (lastC[2][3] == 0)) {
MidiSend(noteOn3, 46, velocity);
lastC[2][3] = 7;
}
//Write Midi Note Off
if ((keysC[2][3] == 1) and (lastC[2][3] == 7)) {
MidiSend(noteOff3, 46, velocity);
lastC[2][3] = 0;
}
//C47
if ((keysC[2][4] == 0) and (lastC[2][4] == 0)) {
MidiSend(noteOn3, 47, velocity);
lastC[2][4] = 7;
}
//Write Midi Note Off
if ((keysC[2][4] == 1) and (lastC[2][4] == 7)) {
MidiSend(noteOff3, 47, velocity);
lastC[2][4] = 0;
}
//C48
if ((keysC[2][5] == 0) and (lastC[2][5] == 0)) {
MidiSend(noteOn3, 48, velocity);
lastC[2][5] = 7;
}
//Write Midi Note Off
if ((keysC[2][5] == 1) and (lastC[2][5] == 7)) {
MidiSend(noteOff3, 48, velocity);
lastC[2][5] = 0;
}
//C49
if ((keysC[3][0] == 0) and (lastC[3][0] == 0)) {
MidiSend(noteOn3, 49, velocity);
lastC[3][0] = 7;
}
//Write Midi Note Off
if ((keysC[3][0] == 1) and (lastC[3][0] == 7)) {
MidiSend(noteOff3, 49, velocity);
lastC[3][0] = 0;
}
//C50
if ((keysC[3][1] == 0) and (lastC[3][1] == 0)) {
MidiSend(noteOn3, 50, velocity);
lastC[3][1] = 7;
}
//Write Midi Note Off
if ((keysC[3][1] == 1) and (lastC[3][1] == 7)) {
MidiSend(noteOff3, 50, velocity);
lastC[3][1] = 0;
}
//C51
if ((keysC[3][2] == 0) and (lastC[3][2] == 0)) {
MidiSend(noteOn3, 51, velocity);
lastC[3][2] = 7;
}
//Write Midi Note Off
if ((keysC[3][2] == 1) and (lastC[3][2] == 7)) {
MidiSend(noteOff3, 51, velocity);
lastC[3][2] = 0;
}
//C52
if ((keysC[3][3] == 0) and (lastC[3][3] == 0)) {
MidiSend(noteOn3, 52, velocity);
lastC[3][3] = 7;
}
//Write Midi Note Off
if ((keysC[3][3] == 1) and (lastC[3][3] == 7)) {
MidiSend(noteOff3, 52, velocity);
lastC[3][3] = 0;
}
//C53
if ((keysC[3][4] == 0) and (lastC[3][4] == 0)) {
MidiSend(noteOn3, 53, velocity);
lastC[3][4] = 7;
}
//Write Midi Note Off
if ((keysC[3][4] == 1) and (lastC[3][4] == 7)) {
MidiSend(noteOff3, 53, velocity);
lastC[3][4] = 0;
}
//C54
if ((keysC[3][5] == 0) and (lastC[3][5] == 0)) {
MidiSend(noteOn3, 54, velocity);
lastC[3][5] = 7;
}
//Write Midi Note Off
if ((keysC[3][5] == 1) and (lastC[3][5] == 7)) {
MidiSend(noteOff3, 54, velocity);
lastC[3][5] = 0;
}
//C55
if ((keysC[4][0] == 0) and (lastC[4][0] == 0)) {
MidiSend(noteOn3, 55, velocity);
lastC[4][0] = 7;
}
//Write Midi Note Off
if ((keysC[4][0] == 1) and (lastC[4][0] == 7)) {
MidiSend(noteOff3, 55, velocity);
lastC[4][0] = 0;
}
//C56
if ((keysC[4][1] == 0) and (lastC[4][1] == 0)) {
MidiSend(noteOn3, 56, velocity);
lastC[4][1] = 7;
}
//Write Midi Note Off
if ((keysC[4][1] == 1) and (lastC[4][1] == 7)) {
MidiSend(noteOff3, 56, velocity);
lastC[4][1] = 0;
}
//C57
if ((keysC[4][2] == 0) and (lastC[4][2] == 0)) {
MidiSend(noteOn3, 57, velocity);
lastC[4][2] = 7;
}
//Write Midi Note Off
if ((keysC[4][2] == 1) and (lastC[4][2] == 7)) {
MidiSend(noteOff3, 57, velocity);
lastC[4][2] = 0;
}
//C58
if ((keysC[4][3] == 0) and (lastC[4][3] == 0)) {
MidiSend(noteOn3, 58, velocity);
lastC[4][3] = 7;
}
//Write Midi Note Off
if ((keysC[4][3] == 1) and (lastC[4][3] == 7)) {
MidiSend(noteOff3, 58, velocity);
lastC[4][3] = 0;
}
//C59
if ((keysC[4][4] == 0) and (lastC[4][4] == 0)) {
MidiSend(noteOn3, 59, velocity);
lastC[4][4] = 7;
}
//Write Midi Note Off
if ((keysC[4][4] == 1) and (lastC[4][4] == 7)) {
MidiSend(noteOff3, 59, velocity);
lastC[4][4] = 0;
}
//C60
if ((keysC[4][5] == 0) and (lastC[4][5] == 0)) {
MidiSend(noteOn3, 60, velocity);
lastC[4][5] = 7;
}
//Write Midi Note Off
if ((keysC[4][5] == 1) and (lastC[4][5] == 7)) {
MidiSend(noteOff3, 60, velocity);
lastC[4][5] = 0;
}
//C61
if ((keysC[5][0] == 0) and (lastC[5][0] == 0)) {
MidiSend(noteOn3, 61, velocity);
lastC[5][0] = 7;
}
//Write Midi Note Off
if ((keysC[5][0] == 1) and (lastC[5][0] == 7)) {
MidiSend(noteOff3, 61, velocity);
lastC[5][0] = 0;
}
//C62
if ((keysC[5][1] == 0) and (lastC[5][1] == 0)) {
MidiSend(noteOn3, 62, velocity);
lastC[5][1] = 7;
}
//Write Midi Note Off
if ((keysC[5][1] == 1) and (lastC[5][1] == 7)) {
MidiSend(noteOff3, 62, velocity);
lastC[5][1] = 0;
}
//C63
if ((keysC[5][2] == 0) and (lastC[5][2] == 0)) {
MidiSend(noteOn3, 63, velocity);
lastC[5][2] = 7;
}
//Write Midi Note Off
if ((keysC[5][2] == 1) and (lastC[5][2] == 7)) {
MidiSend(noteOff3, 63, velocity);
lastC[5][2] = 0;
}
//C64
if ((keysC[5][3] == 0) and (lastC[5][3] == 0)) {
MidiSend(noteOn3, 64, velocity);
lastC[5][3] = 7;
}
//Write Midi Note Off
if ((keysC[5][3] == 1) and (lastC[5][3] == 7)) {
MidiSend(noteOff3, 64, velocity);
lastC[5][3] = 0;
}
//C65
if ((keysC[5][4] == 0) and (lastC[5][4] == 0)) {
MidiSend(noteOn3, 65, velocity);
lastC[5][4] = 7;
}
//Write Midi Note Off
if ((keysC[5][4] == 1) and (lastC[5][4] == 7)) {
MidiSend(noteOff3, 65, velocity);
lastC[5][4] = 0;
}
//C66
if ((keysC[5][5] == 0) and (lastC[5][5] == 0)) {
MidiSend(noteOn3, 66, velocity);
lastC[5][5] = 7;
}
//Write Midi Note Off
if ((keysC[5][5] == 1) and (lastC[5][5] == 7)) {
MidiSend(noteOff3, 66, velocity);
lastC[5][5] = 0;
}
//C67
if ((keysC[6][0] == 0) and (lastC[6][0] == 0)) {
MidiSend(noteOn3, 67, velocity);
lastC[6][0] = 7;
}
//Write Midi Note Off
if ((keysC[6][0] == 1) and (lastC[6][0] == 7)) {
MidiSend(noteOff3, 67, velocity);
lastC[6][0] = 0;
}
//C68
if ((keysC[6][1] == 0) and (lastC[6][1] == 0)) {
MidiSend(noteOn3, 68, velocity);
lastC[6][1] = 7;
}
//Write Midi Note Off
if ((keysC[6][1] == 1) and (lastC[6][1] == 7)) {
MidiSend(noteOff3, 68, velocity);
lastC[6][1] = 0;
}
//C69
if ((keysC[6][2] == 0) and (lastC[6][2] == 0)) {
MidiSend(noteOn3, 69, velocity);
lastC[6][2] = 7;
}
//Write Midi Note Off
if ((keysC[6][2] == 1) and (lastC[6][2] == 7)) {
MidiSend(noteOff3, 69, velocity);
lastC[6][2] = 0;
}
//C70
if ((keysC[6][3] == 0) and (lastC[6][3] == 0)) {
MidiSend(noteOn3, 70, velocity);
lastC[6][3] = 7;
}
//Write Midi Note Off
if ((keysC[6][3] == 1) and (lastC[6][3] == 7)) {
MidiSend(noteOff3, 70, velocity);
lastC[6][3] = 0;
}
//C71
if ((keysC[6][4] == 0) and (lastC[6][4] == 0)) {
MidiSend(noteOn3, 71, velocity);
lastC[6][4] = 7;
}
//Write Midi Note Off
if ((keysC[6][4] == 1) and (lastC[6][4] == 7)) {
MidiSend(noteOff3, 71, velocity);
lastC[6][4] = 0;
}
//C72
if ((keysC[6][5] == 0) and (lastC[6][5] == 0)) {
MidiSend(noteOn3, 72, velocity);
lastC[6][5] = 7;
}
//Write Midi Note Off
if ((keysC[6][5] == 1) and (lastC[6][5] == 7)) {
MidiSend(noteOff3, 72, velocity);
lastC[6][5] = 0;
}
//C73
if ((keysC[7][0] == 0) and (lastC[7][0] == 0)) {
MidiSend(noteOn3, 73, velocity);
lastC[7][0] = 7;
}
//Write Midi Note Off
if ((keysC[7][0] == 1) and (lastC[7][0] == 7)) {
MidiSend(noteOff3, 73, velocity);
lastC[7][0] = 0;
}
//C74
if ((keysC[7][1] == 0) and (lastC[7][1] == 0)) {
MidiSend(noteOn3, 74, velocity);
lastC[7][1] = 7;
}
//Write Midi Note Off
if ((keysC[7][1] == 1) and (lastC[7][1] == 7)) {
MidiSend(noteOff3, 74, velocity);
lastC[7][1] = 0;
}
//C75
if ((keysC[7][2] == 0) and (lastC[7][2] == 0)) {
MidiSend(noteOn3, 75, velocity);
lastC[7][2] = 7;
}
//Write Midi Note Off
if ((keysC[7][2] == 1) and (lastC[7][2] == 7)) {
MidiSend(noteOff3, 75, velocity);
lastC[7][2] = 0;
}
//C76
if ((keysC[7][3] == 0) and (lastC[7][3] == 0)) {
MidiSend(noteOn3, 76, velocity);
lastC[7][3] = 7;
}
//Write Midi Note Off
if ((keysC[7][3] == 1) and (lastC[7][3] == 7)) {
MidiSend(noteOff3, 76, velocity);
lastC[7][3] = 0;
}
//C77
if ((keysC[7][4] == 0) and (lastC[7][4] == 0)) {
MidiSend(noteOn3, 77, velocity);
lastC[7][4] = 7;
}
//Write Midi Note Off
if ((keysC[7][4] == 1) and (lastC[7][4] == 7)) {
MidiSend(noteOff3, 77, velocity);
lastC[7][4] = 0;
}
//C78
if ((keysC[7][5] == 0) and (lastC[7][5] == 0)) {
MidiSend(noteOn3, 78, velocity);
lastC[7][5] = 7;
}
//Write Midi Note Off
if ((keysC[7][5] == 1) and (lastC[7][5] == 7)) {
MidiSend(noteOff3, 78, velocity);
lastC[7][5] = 0;
}
//C79
if ((keysC[8][0] == 0) and (lastC[8][0] == 0)) {
MidiSend(noteOn3, 79, velocity);
lastC[8][0] = 7;
}
//Write Midi Note Off
if ((keysC[8][0] == 1) and (lastC[8][0] == 7)) {
MidiSend(noteOff2, 79, velocity);
lastC[8][0] = 0;
}
//C80
if ((keysC[8][1] == 0) and (lastC[8][1] == 0)) {
MidiSend(noteOn3, 80, velocity);
lastC[8][1] = 7;
}
//Write Midi Note Off
if ((keysC[8][1] == 1) and (lastC[8][1] == 7)) {
MidiSend(noteOff3, 80, velocity);
lastC[8][1] = 0;
}
//C81
if ((keysC[8][2] == 0) and (lastC[8][2] == 0)) {
MidiSend(noteOn3, 81, velocity);
lastC[8][2] = 7;
}
//Write Midi Note Off
if ((keysC[8][2] == 1) and (lastC[8][2] == 7)) {
MidiSend(noteOff3, 81, velocity);
lastC[8][2] = 0;
}
//C82
if ((keysC[8][3] == 0) and (lastC[8][3] == 0)) {
MidiSend(noteOn3, 82, velocity);
lastC[8][3] = 7;
}
//Write Midi Note Off
if ((keysC[8][3] == 1) and (lastC[8][3] == 7)) {
MidiSend(noteOff3, 82, velocity);
lastC[8][3] = 0;
}
//C83
if ((keysC[8][4] == 0) and (lastC[8][4] == 0)) {
MidiSend(noteOn3, 83, velocity);
lastC[8][4] = 7;
}
//Write Midi Note Off
if ((keysC[8][4] == 1) and (lastC[8][4] == 7)) {
MidiSend(noteOff3, 83, velocity);
lastC[8][4] = 0;
}
//C84
if ((keysC[8][5] == 0) and (lastC[8][5] == 0)) {
MidiSend(noteOn3, 84, velocity);
lastC[8][5] = 7;
}
//Write Midi Note Off
if ((keysC[8][5] == 1) and (lastC[8][5] == 7)) {
MidiSend(noteOff3, 84, velocity);
lastC[8][5] = 0;
}
//C85
if ((keysC[9][0] == 0) and (lastC[9][0] == 0)) {
MidiSend(noteOn3, 85, velocity);
lastC[9][0] = 7;
}
//Write Midi Note Off
if ((keysC[9][0] == 1) and (lastC[9][0] == 7)) {
MidiSend(noteOff3, 85, velocity);
lastC[9][0] = 0;
}
//C86
if ((keysC[9][1] == 0) and (lastC[9][1] == 0)) {
MidiSend(noteOn2, 86, velocity);
lastC[9][1] = 7;
}
//Write Midi Note Off
if ((keysC[9][1] == 1) and (lastC[9][1] == 7)) {
MidiSend(noteOff3, 86, velocity);
lastC[9][1] = 0;
}
//C87
if ((keysC[9][2] == 0) and (lastC[9][2] == 0)) {
MidiSend(noteOn3, 87, velocity);
lastC[9][2] = 7;
}
//Write Midi Note Off
if ((keysC[9][2] == 1) and (lastC[9][2] == 7)) {
MidiSend(noteOff3, 87, velocity);
lastC[9][2] = 0;
}
//C88
if ((keysC[9][3] == 0) and (lastC[9][3] == 0)) {
MidiSend(noteOn3, 88, velocity);
lastC[9][3] = 7;
}
//Write Midi Note Off
if ((keysC[9][3] == 1) and (lastC[9][3] == 7)) {
MidiSend(noteOff3, 88, velocity);
lastC[9][3] = 0;
}
//C89
if ((keysC[9][4] == 0) and (lastC[9][4] == 0)) {
MidiSend(noteOn3, 89, velocity);
lastC[9][4] = 7;
}
//Write Midi Note Off
if ((keysC[9][4] == 1) and (lastC[9][4] == 7)) {
MidiSend(noteOff3, 89, velocity);
lastC[9][4] = 0;
}
//C90
if ((keysC[9][5] == 0) and (lastC[9][5] == 0)) {
MidiSend(noteOn3, 90, velocity);
lastC[9][5] = 7;
}
//Write Midi Note Off
if ((keysC[9][5] == 1) and (lastC[9][5] == 7)) {
MidiSend(noteOff3, 90, velocity);
lastC[9][5] = 0;
}
//C91
if ((keysC[10][0] == 0) and (lastC[10][0] == 0)) {
MidiSend(noteOn3, 91, velocity);
lastC[10][0] = 7;
}
//Write Midi Note Off
if ((keysC[10][0] == 1) and (lastC[10][0] == 7)) {
MidiSend(noteOff3, 91, velocity);
lastC[10][0] = 0;
}
//C92
if ((keysC[10][1] == 0) and (lastC[10][1] == 0)) {
MidiSend(noteOn3, 92, velocity);
lastC[10][1] = 7;
}
//Write Midi Note Off
if ((keysC[10][1] == 1) and (lastC[10][1] == 7)) {
MidiSend(noteOff3, 92, velocity);
lastC[10][1] = 0;
}
//C93
if ((keysC[10][2] == 0) and (lastC[10][2] == 0)) {
MidiSend(noteOn3, 93, velocity);
lastC[10][2] = 7;
}
//Write Midi Note Off
if ((keysC[10][2] == 1) and (lastC[10][2] == 7)) {
MidiSend(noteOff3, 93, velocity);
lastC[10][2] = 0;
}
//C94
if ((keysC[10][3] == 0) and (lastC[10][3] == 0)) {
MidiSend(noteOn3, 94, velocity);
lastC[10][3] = 7;
}
//Write Midi Note Off
if ((keysC[10][3] == 1) and (lastC[10][3] == 7)) {
MidiSend(noteOff3, 94, velocity);
lastC[10][3] = 0;
}
//C95
if ((keysC[10][4] == 0) and (lastC[10][4] == 0)) {
MidiSend(noteOn3, 95, velocity);
lastC[10][4] = 7;
}
//Write Midi Note Off
if ((keysC[10][4] == 1) and (lastC[10][4] == 7)) {
MidiSend(noteOff3, 95, velocity);
lastC[10][4] = 0;
}
//C96
if ((keysC[10][5] == 0) and (lastC[10][5] == 0)) {
MidiSend(noteOn3, 96, velocity);
lastC[10][5] = 7;
}
//Write Midi Note Off
if ((keysC[10][5] == 1) and (lastC[10][5] == 7)) {
MidiSend(noteOff3, 96, velocity);
lastC[10][5] = 0;
}
//Write Keyboard D
//D36
if ((keysD[0][0] == 0) and (lastD[0][0] == 0)) {
MidiSend(noteOn4, 36, velocity);
lastD[0][0] = 7;
}
if ((keysD[0][0] == 1) and (lastD[0][0] == 7)) {
MidiSend(noteOff4, 36, velocity);
lastD[0][0] = 0;
}
//D37
if ((keysD[1][0] == 0) and (lastD[1][0] == 0)) {
MidiSend(noteOn4, 37, velocity);
lastD[1][0] = 7;
}
if ((keysD[1][0] == 1) and (lastD[1][0] == 7)) {
MidiSend(noteOff4, 37, velocity);
lastD[1][0] = 0;
}
//D38
if ((keysD[1][1] == 0) and (lastD[1][1] == 0)) {
MidiSend(noteOn4, 38, velocity);
lastD[1][1] = 7;
}
//Write Midi Note Off
if ((keysD[1][1] == 1) and (lastD[1][1] == 7)) {
MidiSend(noteOff4, 38, velocity);
lastD[1][1] = 0;
}
//D39
if ((keysD[1][2] == 0) and (lastD[1][2] == 0)) {
MidiSend(noteOn4, 39, velocity);
lastD[1][2] = 7;
}
//Write Midi Note Off
if ((keysD[1][2] == 1) and (lastD[1][2] == 7)) {
MidiSend(noteOff4, 39, velocity);
lastD[1][2] = 0;
}
//D40
if ((keysD[1][3] == 0) and (lastD[1][3] == 0)) {
MidiSend(noteOn4, 40, velocity);
lastD[1][3] = 7;
}
//Write Midi Note Off
if ((keysD[1][3] == 1) and (lastD[1][3] == 7)) {
MidiSend(noteOff4, 40, velocity);
lastD[1][3] = 0;
}
//D41
if ((keysD[1][4] == 0) and (lastD[1][4] == 0)) {
MidiSend(noteOn4, 41, velocity);
lastD[1][4] = 7;
}
//Write Midi Note Off
if ((keysD[1][4] == 1) and (lastD[1][4] == 7)) {
MidiSend(noteOff4, 41, velocity);
lastD[1][4] = 0;
}
//D42
if ((keysD[1][5] == 0) and (lastD[1][5] == 0)) {
MidiSend(noteOn4, 42, velocity);
lastD[1][5] = 7;
}
//Write Midi Note Off
if ((keysD[1][5] == 1) and (lastD[1][5] == 7)) {
MidiSend(noteOff4, 42, velocity);
lastD[1][5] = 0;
}
//D43
if ((keysD[2][0] == 0) and (lastD[2][0] == 0)) {
MidiSend(noteOn4, 43, velocity);
lastD[2][0] = 7;
}
//Write Midi Note Off
if ((keysD[2][0] == 1) and (lastD[2][0] == 7)) {
MidiSend(noteOff4, 43, velocity);
lastD[2][0] = 0;
}
//B44
if ((keysD[2][1] == 0) and (lastD[2][1] == 0)) {
MidiSend(noteOn4, 44, velocity);
lastD[2][1] = 7;
}
//Write Midi Note Off
if ((keysD[2][1] == 1) and (lastD[2][1] == 7)) {
MidiSend(noteOff4, 44, velocity);
lastD[2][1] = 0;
}
//D45
if ((keysD[2][2] == 0) and (lastD[2][2] == 0)) {
MidiSend(noteOn4, 45, velocity);
lastD[2][2] = 7;
}
//Write Midi Note Off
if ((keysD[2][2] == 1) and (lastD[2][2] == 7)) {
MidiSend(noteOff4, 45, velocity);
lastD[2][2] = 0;
}
//D46
if ((keysD[2][3] == 0) and (lastD[2][3] == 0)) {
MidiSend(noteOn4, 46, velocity);
lastD[2][3] = 7;
}
//Write Midi Note Off
if ((keysD[2][3] == 1) and (lastD[2][3] == 7)) {
MidiSend(noteOff4, 46, velocity);
lastD[2][3] = 0;
}
//D47
if ((keysD[2][4] == 0) and (lastD[2][4] == 0)) {
MidiSend(noteOn4, 47, velocity);
lastD[2][4] = 7;
}
//Write Midi Note Off
if ((keysD[2][4] == 1) and (lastD[2][4] == 7)) {
MidiSend(noteOff4, 47, velocity);
lastD[2][4] = 0;
}
//D48
if ((keysD[2][5] == 0) and (lastD[2][5] == 0)) {
MidiSend(noteOn4, 48, velocity);
lastD[2][5] = 7;
}
//Write Midi Note Off
if ((keysD[2][5] == 1) and (lastD[2][5] == 7)) {
MidiSend(noteOff4, 48, velocity);
lastD[2][5] = 0;
}
//D49
if ((keysD[3][0] == 0) and (lastD[3][0] == 0)) {
MidiSend(noteOn4, 49, velocity);
lastD[3][0] = 7;
}
//Write Midi Note Off
if ((keysD[3][0] == 1) and (lastD[3][0] == 7)) {
MidiSend(noteOff4, 49, velocity);
lastD[3][0] = 0;
}
//D50
if ((keysD[3][1] == 0) and (lastD[3][1] == 0)) {
MidiSend(noteOn4, 50, velocity);
lastD[3][1] = 7;
}
//Write Midi Note Off
if ((keysD[3][1] == 1) and (lastD[3][1] == 7)) {
MidiSend(noteOff4, 50, velocity);
lastD[3][1] = 0;
}
//D51
if ((keysD[3][2] == 0) and (lastD[3][2] == 0)) {
MidiSend(noteOn4, 51, velocity);
lastD[3][2] = 7;
}
//Write Midi Note Off
if ((keysD[3][2] == 1) and (lastD[3][2] == 7)) {
MidiSend(noteOff4, 51, velocity);
lastD[3][2] = 0;
}
//D52
if ((keysD[3][3] == 0) and (lastD[3][3] == 0)) {
MidiSend(noteOn4, 52, velocity);
lastD[3][3] = 7;
}
//Write Midi Note Off
if ((keysD[3][3] == 1) and (lastD[3][3] == 7)) {
MidiSend(noteOff4, 52, velocity);
lastD[3][3] = 0;
}
//D53
if ((keysD[3][4] == 0) and (lastD[3][4] == 0)) {
MidiSend(noteOn4, 53, velocity);
lastD[3][4] = 7;
}
//Write Midi Note Off
if ((keysD[3][4] == 1) and (lastD[3][4] == 7)) {
MidiSend(noteOff4, 53, velocity);
lastD[3][4] = 0;
}
//D54
if ((keysD[3][5] == 0) and (lastD[3][5] == 0)) {
MidiSend(noteOn4, 54, velocity);
lastD[3][5] = 7;
}
//Write Midi Note Off
if ((keysD[3][5] == 1) and (lastD[3][5] == 7)) {
MidiSend(noteOff4, 54, velocity);
lastD[3][5] = 0;
}
//D55
if ((keysD[4][0] == 0) and (lastD[4][0] == 0)) {
MidiSend(noteOn4, 55, velocity);
lastD[4][0] = 7;
}
//Write Midi Note Off
if ((keysD[4][0] == 1) and (lastD[4][0] == 7)) {
MidiSend(noteOff4, 55, velocity);
lastD[4][0] = 0;
}
//D56
if ((keysD[4][1] == 0) and (lastD[4][1] == 0)) {
MidiSend(noteOn4, 56, velocity);
lastD[4][1] = 7;
}
//Write Midi Note Off
if ((keysD[4][1] == 1) and (lastD[4][1] == 7)) {
MidiSend(noteOff4, 56, velocity);
lastD[4][1] = 0;
}
//D57
if ((keysD[4][2] == 0) and (lastD[4][2] == 0)) {
MidiSend(noteOn4, 57, velocity);
lastD[4][2] = 7;
}
//Write Midi Note Off
if ((keysD[4][2] == 1) and (lastD[4][2] == 7)) {
MidiSend(noteOff4, 57, velocity);
lastD[4][2] = 0;
}
//D58
if ((keysD[4][3] == 0) and (lastD[4][3] == 0)) {
MidiSend(noteOn4, 58, velocity);
lastD[4][3] = 7;
}
//Write Midi Note Off
if ((keysD[4][3] == 1) and (lastD[4][3] == 7)) {
MidiSend(noteOff4, 58, velocity);
lastD[4][3] = 0;
}
//D59
if ((keysD[4][4] == 0) and (lastD[4][4] == 0)) {
MidiSend(noteOn4, 59, velocity);
lastD[4][4] = 7;
}
//Write Midi Note Off
if ((keysD[4][4] == 1) and (lastD[4][4] == 7)) {
MidiSend(noteOff4, 59, velocity);
lastD[4][4] = 0;
}
//D60
if ((keysD[4][5] == 0) and (lastD[4][5] == 0)) {
MidiSend(noteOn4, 60, velocity);
lastD[4][5] = 7;
}
//Write Midi Note Off
if ((keysD[4][5] == 1) and (lastD[4][5] == 7)) {
MidiSend(noteOff4, 60, velocity);
lastD[4][5] = 0;
}
//D61
if ((keysD[5][0] == 0) and (lastD[5][0] == 0)) {
MidiSend(noteOn4, 61, velocity);
lastD[5][0] = 7;
}
//Write Midi Note Off
if ((keysD[5][0] == 1) and (lastD[5][0] == 7)) {
MidiSend(noteOff4, 61, velocity);
lastD[5][0] = 0;
}
//D62
if ((keysD[5][1] == 0) and (lastD[5][1] == 0)) {
MidiSend(noteOn4, 62, velocity);
lastD[5][1] = 7;
}
//Write Midi Note Off
if ((keysD[5][1] == 1) and (lastD[5][1] == 7)) {
MidiSend(noteOff4, 62, velocity);
lastD[5][1] = 0;
}
//D63
if ((keysD[5][2] == 0) and (lastD[5][2] == 0)) {
MidiSend(noteOn4, 63, velocity);
lastD[5][2] = 7;
}
//Write Midi Note Off
if ((keysD[5][2] == 1) and (lastD[5][2] == 7)) {
MidiSend(noteOff4, 63, velocity);
lastD[5][2] = 0;
}
//D64
if ((keysD[5][3] == 0) and (lastD[5][3] == 0)) {
MidiSend(noteOn4, 64, velocity);
lastD[5][3] = 7;
}
//Write Midi Note Off
if ((keysD[5][3] == 1) and (lastD[5][3] == 7)) {
MidiSend(noteOff4, 64, velocity);
lastD[5][3] = 0;
}
//D65
if ((keysD[5][4] == 0) and (lastD[5][4] == 0)) {
MidiSend(noteOn4, 65, velocity);
lastD[5][4] = 7;
}
//Write Midi Note Off
if ((keysD[5][4] == 1) and (lastD[5][4] == 7)) {
MidiSend(noteOff4, 65, velocity);
lastD[5][4] = 0;
}
//D66
if ((keysD[5][5] == 0) and (lastD[5][5] == 0)) {
MidiSend(noteOn4, 66, velocity);
lastD[5][5] = 7;
}
//Write Midi Note Off
if ((keysD[5][5] == 1) and (lastD[5][5] == 7)) {
MidiSend(noteOff4, 66, velocity);
lastD[5][5] = 0;
}
//D67
if ((keysD[6][0] == 0) and (lastD[6][0] == 0)) {
MidiSend(noteOn4, 67, velocity);
lastD[6][0] = 7;
}
//Write Midi Note Off
if ((keysD[6][0] == 1) and (lastD[6][0] == 7)) {
MidiSend(noteOff4, 67, velocity);
lastD[6][0] = 0;
}
//D68
if ((keysD[6][1] == 0) and (lastD[6][1] == 0)) {
MidiSend(noteOn4, 68, velocity);
lastD[6][1] = 7;
}
//Write Midi Note Off
if ((keysD[6][1] == 1) and (lastD[6][1] == 7)) {
MidiSend(noteOff4, 68, velocity);
lastD[6][1] = 0;
}
//D69
if ((keysD[6][2] == 0) and (lastD[6][2] == 0)) {
MidiSend(noteOn4, 69, velocity);
lastD[6][2] = 7;
}
//Write Midi Note Off
if ((keysD[6][2] == 1) and (lastD[6][2] == 7)) {
MidiSend(noteOff4, 69, velocity);
lastD[6][2] = 0;
}
//D70
if ((keysD[6][3] == 0) and (lastD[6][3] == 0)) {
MidiSend(noteOn4, 70, velocity);
lastD[6][3] = 7;
}
//Write Midi Note Off
if ((keysD[6][3] == 1) and (lastD[6][3] == 7)) {
MidiSend(noteOff4, 70, velocity);
lastD[6][3] = 0;
}
//D71
if ((keysD[6][4] == 0) and (lastD[6][4] == 0)) {
MidiSend(noteOn4, 71, velocity);
lastD[6][4] = 7;
}
//Write Midi Note Off
if ((keysD[6][4] == 1) and (lastD[6][4] == 7)) {
MidiSend(noteOff4, 71, velocity);
lastD[6][4] = 0;
}
//D72
if ((keysD[6][5] == 0) and (lastD[6][5] == 0)) {
MidiSend(noteOn4, 72, velocity);
lastD[6][5] = 7;
}
//Write Midi Note Off
if ((keysD[6][5] == 1) and (lastD[6][5] == 7)) {
MidiSend(noteOff4, 72, velocity);
lastD[6][5] = 0;
}
//D73
if ((keysD[7][0] == 0) and (lastD[7][0] == 0)) {
MidiSend(noteOn4, 73, velocity);
lastD[7][0] = 7;
}
//Write Midi Note Off
if ((keysD[7][0] == 1) and (lastD[7][0] == 7)) {
MidiSend(noteOff4, 73, velocity);
lastD[7][0] = 0;
}
//D74
if ((keysD[7][1] == 0) and (lastD[7][1] == 0)) {
MidiSend(noteOn4, 74, velocity);
lastD[7][1] = 7;
}
//Write Midi Note Off
if ((keysD[7][1] == 1) and (lastD[7][1] == 7)) {
MidiSend(noteOff4, 74, velocity);
lastD[7][1] = 0;
}
//D75
if ((keysD[7][2] == 0) and (lastD[7][2] == 0)) {
MidiSend(noteOn4, 75, velocity);
lastD[7][2] = 7;
}
//Write Midi Note Off
if ((keysD[7][2] == 1) and (lastD[7][2] == 7)) {
MidiSend(noteOff4, 75, velocity);
lastD[7][2] = 0;
}
//D76
if ((keysD[7][3] == 0) and (lastD[7][3] == 0)) {
MidiSend(noteOn4, 76, velocity);
lastD[7][3] = 7;
}
//Write Midi Note Off
if ((keysD[7][3] == 1) and (lastD[7][3] == 7)) {
MidiSend(noteOff4, 76, velocity);
lastD[7][3] = 0;
}
//D77
if ((keysD[7][4] == 0) and (lastD[7][4] == 0)) {
MidiSend(noteOn4, 77, velocity);
lastD[7][4] = 7;
}
//Write Midi Note Off
if ((keysD[7][4] == 1) and (lastD[7][4] == 7)) {
MidiSend(noteOff4, 77, velocity);
lastD[7][4] = 0;
}
//D78
if ((keysD[7][5] == 0) and (lastD[7][5] == 0)) {
MidiSend(noteOn4, 78, velocity);
lastD[7][5] = 7;
}
//Write Midi Note Off
if ((keysD[7][5] == 1) and (lastD[7][5] == 7)) {
MidiSend(noteOff4, 78, velocity);
lastD[7][5] = 0;
}
//D79
if ((keysD[8][0] == 0) and (lastD[8][0] == 0)) {
MidiSend(noteOn4, 79, velocity);
lastD[8][0] = 7;
}
//Write Midi Note Off
if ((keysD[8][0] == 1) and (lastD[8][0] == 7)) {
MidiSend(noteOff4, 79, velocity);
lastD[8][0] = 0;
}
//D80
if ((keysD[8][1] == 0) and (lastD[8][1] == 0)) {
MidiSend(noteOn4, 80, velocity);
lastD[8][1] = 7;
}
//Write Midi Note Off
if ((keysD[8][1] == 1) and (lastD[8][1] == 7)) {
MidiSend(noteOff4, 80, velocity);
lastD[8][1] = 0;
}
//D81
if ((keysD[8][2] == 0) and (lastD[8][2] == 0)) {
MidiSend(noteOn4, 81, velocity);
lastD[8][2] = 7;
}
//Write Midi Note Off
if ((keysD[8][2] == 1) and (lastD[8][2] == 7)) {
MidiSend(noteOff4, 81, velocity);
lastD[8][2] = 0;
}
//D82
if ((keysD[8][3] == 0) and (lastD[8][3] == 0)) {
MidiSend(noteOn4, 82, velocity);
lastD[8][3] = 7;
}
//Write Midi Note Off
if ((keysD[8][3] == 1) and (lastD[8][3] == 7)) {
MidiSend(noteOff4, 82, velocity);
lastD[8][3] = 0;
}
//D83
if ((keysD[8][4] == 0) and (lastD[8][4] == 0)) {
MidiSend(noteOn4, 83, velocity);
lastD[8][4] = 7;
}
//Write Midi Note Off
if ((keysD[8][4] == 1) and (lastD[8][4] == 7)) {
MidiSend(noteOff4, 83, velocity);
lastD[8][4] = 0;
}
//D84
if ((keysD[8][5] == 0) and (lastD[8][5] == 0)) {
MidiSend(noteOn4, 84, velocity);
lastD[8][5] = 7;
}
//Write Midi Note Off
if ((keysD[8][5] == 1) and (lastD[8][5] == 7)) {
MidiSend(noteOff4, 84, velocity);
lastD[8][5] = 0;
}
//D85
if ((keysD[9][0] == 0) and (lastD[9][0] == 0)) {
MidiSend(noteOn4, 85, velocity);
lastD[9][0] = 7;
}
//Write Midi Note Off
if ((keysD[9][0] == 1) and (lastD[9][0] == 7)) {
MidiSend(noteOff4, 85, velocity);
lastD[9][0] = 0;
}
//D86
if ((keysD[9][1] == 0) and (lastD[9][1] == 0)) {
MidiSend(noteOn4, 86, velocity);
lastD[9][1] = 7;
}
//Write Midi Note Off
if ((keysD[9][1] == 1) and (lastD[9][1] == 7)) {
MidiSend(noteOff4, 86, velocity);
lastD[9][1] = 0;
}
//D87
if ((keysD[9][2] == 0) and (lastD[9][2] == 0)) {
MidiSend(noteOn4, 87, velocity);
lastD[9][2] = 7;
}
//Write Midi Note Off
if ((keysD[9][2] == 1) and (lastD[9][2] == 7)) {
MidiSend(noteOff4, 87, velocity);
lastD[9][2] = 0;
}
//D88
if ((keysD[9][3] == 0) and (lastD[9][3] == 0)) {
MidiSend(noteOn4, 88, velocity);
lastD[9][3] = 7;
}
//Write Midi Note Off
if ((keysD[9][3] == 1) and (lastD[9][3] == 7)) {
MidiSend(noteOff4, 88, velocity);
lastD[9][3] = 0;
}
//D89
if ((keysD[9][4] == 0) and (lastD[9][4] == 0)) {
MidiSend(noteOn4, 89, velocity);
lastD[9][4] = 7;
}
//Write Midi Note Off
if ((keysD[9][4] == 1) and (lastD[9][4] == 7)) {
MidiSend(noteOff4, 89, velocity);
lastD[9][4] = 0;
}
//D90
if ((keysD[9][5] == 0) and (lastD[9][5] == 0)) {
MidiSend(noteOn4, 90, velocity);
lastD[9][5] = 7;
}
//Write Midi Note Off
if ((keysD[9][5] == 1) and (lastD[9][5] == 7)) {
MidiSend(noteOff4, 90, velocity);
lastD[9][5] = 0;
}
//D91
if ((keysD[10][0] == 0) and (lastD[10][0] == 0)) {
MidiSend(noteOn4, 91, velocity);
lastD[10][0] = 7;
}
//Write Midi Note Off
if ((keysD[10][0] == 1) and (lastD[10][0] == 7)) {
MidiSend(noteOff4, 91, velocity);
lastD[10][0] = 0;
}
//D92
if ((keysD[10][1] == 0) and (lastD[10][1] == 0)) {
MidiSend(noteOn4, 92, velocity);
lastD[10][1] = 7;
}
//Write Midi Note Off
if ((keysD[10][1] == 1) and (lastD[10][1] == 7)) {
MidiSend(noteOff4, 92, velocity);
lastD[10][1] = 0;
}
//D93
if ((keysD[10][2] == 0) and (lastD[10][2] == 0)) {
MidiSend(noteOn4, 93, velocity);
lastD[10][2] = 7;
}
//Write Midi Note Off
if ((keysD[10][2] == 1) and (lastD[10][2] == 7)) {
MidiSend(noteOff4, 93, velocity);
lastD[10][2] = 0;
}
//D94
if ((keysD[10][3] == 0) and (lastD[10][3] == 0)) {
MidiSend(noteOn4, 94, velocity);
lastD[10][3] = 7;
}
//Write Midi Note Off
if ((keysD[10][3] == 1) and (lastD[10][3] == 7)) {
MidiSend(noteOff4, 94, velocity);
lastD[10][3] = 0;
}
//D95
if ((keysD[10][4] == 0) and (lastD[10][4] == 0)) {
MidiSend(noteOn4, 95, velocity);
lastD[10][4] = 7;
}
//Write Midi Note Off
if ((keysD[10][4] == 1) and (lastD[10][4] == 7)) {
MidiSend(noteOff4, 95, velocity);
lastD[10][4] = 0;
}
//D96
if ((keysD[10][5] == 0) and (lastD[10][5] == 0)) {
MidiSend(noteOn4, 96, velocity);
lastD[10][5] = 7;
}
//Write Midi Note Off
if ((keysD[10][5] == 1) and (lastD[10][5] == 7)) {
MidiSend(noteOff4, 96, velocity);
lastD[10][5] = 0;
}
//Write Keyboard C, only for inverted switches, first 32 notes only.
/*
//C36
if ((keysC[0][0] == 0) and (lastC[0][0] == 0)) {
MidiSend(noteOff3, 36, velocity);
lastC[0][0] = 7;
}
if ((keysC[0][0] == 1) and (lastC[0][0] == 7)) {
MidiSend(noteOn3, 36, velocity);
lastC[0][0] = 0;
}
//C37
if ((keysC[1][0] == 0) and (lastC[1][0] == 0)) {
MidiSend(noteOff3, 37, velocity);
lastC[1][0] = 7;
}
if ((keysC[1][0] == 1) and (lastC[1][0] == 7)) {
MidiSend(noteOn3, 37, velocity);
lastC[1][0] = 0;
}
//C38
if ((keysC[1][1] == 0) and (lastC[1][1] == 0)) {
MidiSend(noteOff3, 38, velocity);
lastC[1][1] = 7;
}
//Write Midi Note Off
if ((keysC[1][1] == 1) and (lastC[1][1] == 7)) {
MidiSend(noteOn3, 38, velocity);
lastC[1][1] = 0;
}
//C39
if ((keysC[1][2] == 0) and (lastC[1][2] == 0)) {
MidiSend(noteOff3, 39, velocity);
lastC[1][2] = 7;
}
//Write Midi Note Off
if ((keysC[1][2] == 1) and (lastC[1][2] == 7)) {
MidiSend(noteOn3, 39, velocity);
lastC[1][2] = 0;
}
//C40
if ((keysC[1][3] == 0) and (lastC[1][3] == 0)) {
MidiSend(noteOff3, 40, velocity);
lastC[1][3] = 7;
}
//Write Midi Note Off
if ((keysC[1][3] == 1) and (lastC[1][3] == 7)) {
MidiSend(noteOn3, 40, velocity);
lastC[1][3] = 0;
}
//C41
if ((keysC[1][4] == 0) and (lastC[1][4] == 0)) {
MidiSend(noteOff3, 41, velocity);
lastC[1][4] = 7;
}
//Write Midi Note Off
if ((keysC[1][4] == 1) and (lastC[1][4] == 7)) {
MidiSend(noteOn3, 41, velocity);
lastC[1][4] = 0;
}
//C42
if ((keysC[1][5] == 0) and (lastC[1][5] == 0)) {
MidiSend(noteOff3, 42, velocity);
lastC[1][5] = 7;
}
//Write Midi Note Off
if ((keysC[1][5] == 1) and (lastC[1][5] == 7)) {
MidiSend(noteOn3, 42, velocity);
lastC[1][5] = 0;
}
//C43
if ((keysC[2][0] == 0) and (lastC[2][0] == 0)) {
MidiSend(noteOff3, 43, velocity);
lastC[2][0] = 7;
}
//Write Midi Note Off
if ((keysC[2][0] == 1) and (lastC[2][0] == 7)) {
MidiSend(noteOn3, 43, velocity);
lastC[2][0] = 0;
}
//C44
if ((keysC[2][1] == 0) and (lastC[2][1] == 0)) {
MidiSend(noteOff3, 44, velocity);
lastC[2][1] = 7;
}
//Write Midi Note Off
if ((keysC[2][1] == 1) and (lastC[2][1] == 7)) {
MidiSend(noteOn3, 44, velocity);
lastC[2][1] = 0;
}
//C45
if ((keysC[2][2] == 0) and (lastC[2][2] == 0)) {
MidiSend(noteOff3, 45, velocity);
lastC[2][2] = 7;
}
//Write Midi Note Off
if ((keysC[2][2] == 1) and (lastC[2][2] == 7)) {
MidiSend(noteOn3, 45, velocity);
lastC[2][2] = 0;
}
//C46
if ((keysC[2][3] == 0) and (lastC[2][3] == 0)) {
MidiSend(noteOff3, 46, velocity);
lastC[2][3] = 7;
}
//Write Midi Note Off
if ((keysC[2][3] == 1) and (lastC[2][3] == 7)) {
MidiSend(noteOn3, 46, velocity);
lastC[2][3] = 0;
}
//C47
if ((keysC[2][4] == 0) and (lastC[2][4] == 0)) {
MidiSend(noteOff3, 47, velocity);
lastC[2][4] = 7;
}
//Write Midi Note Off
if ((keysC[2][4] == 1) and (lastC[2][4] == 7)) {
MidiSend(noteOn3, 47, velocity);
lastC[2][4] = 0;
}
//C48
if ((keysC[2][5] == 0) and (lastC[2][5] == 0)) {
MidiSend(noteOff3, 48, velocity);
lastC[2][5] = 7;
}
//Write Midi Note Off
if ((keysC[2][5] == 1) and (lastC[2][5] == 7)) {
MidiSend(noteOn3, 48, velocity);
lastC[2][5] = 0;
}
//C49
if ((keysC[3][0] == 0) and (lastC[3][0] == 0)) {
MidiSend(noteOff3, 49, velocity);
lastC[3][0] = 7;
}
//Write Midi Note Off
if ((keysC[3][0] == 1) and (lastC[3][0] == 7)) {
MidiSend(noteOn3, 49, velocity);
lastC[3][0] = 0;
}
//C50
if ((keysC[3][1] == 0) and (lastC[3][1] == 0)) {
MidiSend(noteOff3, 50, velocity);
lastC[3][1] = 7;
}
//Write Midi Note Off
if ((keysC[3][1] == 1) and (lastC[3][1] == 7)) {
MidiSend(noteOn3, 50, velocity);
lastC[3][1] = 0;
}
//C51
if ((keysC[3][2] == 0) and (lastC[3][2] == 0)) {
MidiSend(noteOff3, 51, velocity);
lastC[3][2] = 7;
}
//Write Midi Note Off
if ((keysC[3][2] == 1) and (lastC[3][2] == 7)) {
MidiSend(noteOn3, 51, velocity);
lastC[3][2] = 0;
}
//C52
if ((keysC[3][3] == 0) and (lastC[3][3] == 0)) {
MidiSend(noteOff3, 52, velocity);
lastC[3][3] = 7;
}
//Write Midi Note Off
if ((keysC[3][3] == 1) and (lastC[3][3] == 7)) {
MidiSend(noteOn3, 52, velocity);
lastC[3][3] = 0;
}
//C53
if ((keysC[3][4] == 0) and (lastC[3][4] == 0)) {
MidiSend(noteOff3, 53, velocity);
lastC[3][4] = 7;
}
//Write Midi Note Off
if ((keysC[3][4] == 1) and (lastC[3][4] == 7)) {
MidiSend(noteOn3, 53, velocity);
lastC[3][4] = 0;
}
//C54
if ((keysC[3][5] == 0) and (lastC[3][5] == 0)) {
MidiSend(noteOff3, 54, velocity);
lastC[3][5] = 7;
}
//Write Midi Note Off
if ((keysC[3][5] == 1) and (lastC[3][5] == 7)) {
MidiSend(noteOn3, 54, velocity);
lastC[3][5] = 0;
}
//C55
if ((keysC[4][0] == 0) and (lastC[4][0] == 0)) {
MidiSend(noteOff3, 55, velocity);
lastC[4][0] = 7;
}
//Write Midi Note Off
if ((keysC[4][0] == 1) and (lastC[4][0] == 7)) {
MidiSend(noteOn3, 55, velocity);
lastC[4][0] = 0;
}
//C56
if ((keysC[4][1] == 0) and (lastC[4][1] == 0)) {
MidiSend(noteOff3, 56, velocity);
lastC[4][1] = 7;
}
//Write Midi Note Off
if ((keysC[4][1] == 1) and (lastC[4][1] == 7)) {
MidiSend(noteOn3, 56, velocity);
lastC[4][1] = 0;
}
//C57
if ((keysC[4][2] == 0) and (lastC[4][2] == 0)) {
MidiSend(noteOff3, 57, velocity);
lastC[4][2] = 7;
}
//Write Midi Note Off
if ((keysC[4][2] == 1) and (lastC[4][2] == 7)) {
MidiSend(noteOn3, 57, velocity);
lastC[4][2] = 0;
}
//C58
if ((keysC[4][3] == 0) and (lastC[4][3] == 0)) {
MidiSend(noteOff3, 58, velocity);
lastC[4][3] = 7;
}
//Write Midi Note Off
if ((keysC[4][3] == 1) and (lastC[4][3] == 7)) {
MidiSend(noteOn3, 58, velocity);
lastC[4][3] = 0;
}
//C59
if ((keysC[4][4] == 0) and (lastC[4][4] == 0)) {
MidiSend(noteOff3, 59, velocity);
lastC[4][4] = 7;
}
//Write Midi Note Off
if ((keysC[4][4] == 1) and (lastC[4][4] == 7)) {
MidiSend(noteOn3, 59, velocity);
lastC[4][4] = 0;
}
//C60
if ((keysC[4][5] == 0) and (lastC[4][5] == 0)) {
MidiSend(noteOff3, 60, velocity);
lastC[4][5] = 7;
}
//Write Midi Note Off
if ((keysC[4][5] == 1) and (lastC[4][5] == 7)) {
MidiSend(noteOn3, 60, velocity);
lastC[4][5] = 0;
}
//C61
if ((keysC[5][0] == 0) and (lastC[5][0] == 0)) {
MidiSend(noteOff3, 61, velocity);
lastC[5][0] = 7;
}
//Write Midi Note Off
if ((keysC[5][0] == 1) and (lastC[5][0] == 7)) {
MidiSend(noteOn3, 61, velocity);
lastC[5][0] = 0;
}
//C62
if ((keysC[5][1] == 0) and (lastC[5][1] == 0)) {
MidiSend(noteOff3, 62, velocity);
lastC[5][1] = 7;
}
//Write Midi Note Off
if ((keysC[5][1] == 1) and (lastC[5][1] == 7)) {
MidiSend(noteOn3, 62, velocity);
lastC[5][1] = 0;
}
//C63
if ((keysC[5][2] == 0) and (lastC[5][2] == 0)) {
MidiSend(noteOff3, 63, velocity);
lastC[5][2] = 7;
}
//Write Midi Note Off
if ((keysC[5][2] == 1) and (lastC[5][2] == 7)) {
MidiSend(noteOn3, 63, velocity);
lastC[5][2] = 0;
}
//C64
if ((keysC[5][3] == 0) and (lastC[5][3] == 0)) {
MidiSend(noteOff3, 64, velocity);
lastC[5][3] = 7;
}
//Write Midi Note Off
if ((keysC[5][3] == 1) and (lastC[5][3] == 7)) {
MidiSend(noteOn3, 64, velocity);
lastC[5][3] = 0;
}
//C65
if ((keysC[5][4] == 0) and (lastC[5][4] == 0)) {
MidiSend(noteOff3, 65, velocity);
lastC[5][4] = 7;
}
//Write Midi Note Off
if ((keysC[5][4] == 1) and (lastC[5][4] == 7)) {
MidiSend(noteOn3, 65, velocity);
lastC[5][4] = 0;
}
//C66
if ((keysC[5][5] == 0) and (lastC[5][5] == 0)) {
MidiSend(noteOff3, 66, velocity);
lastC[5][5] = 7;
}
//Write Midi Note Off
if ((keysC[5][5] == 1) and (lastC[5][5] == 7)) {
MidiSend(noteOn3, 66, velocity);
lastC[5][5] = 0;
}
//C67
if ((keysC[6][0] == 0) and (lastC[6][0] == 0)) {
MidiSend(noteOff3, 67, velocity);
lastC[6][0] = 7;
}
//Write Midi Note Off
if ((keysC[6][0] == 1) and (lastC[6][0] == 7)) {
MidiSend(noteOn3, 67, velocity);
lastC[6][0] = 0;
}
*/
//Expression Pedal controls
//Expression pedal on analog pin A13 to Channel 6
int Cur6 = analogRead(13);
int Map6 = map(Cur6, 0, 1023, 0, 127);
if (abs(Cur6 - LastPot6) >= 8) {
MidiSend(chan6,Exp,Map6);
LastPot6 = Cur6;
}
//Expression pedal on analog pin A14 to Channel 7
int Cur7 = analogRead(14);
int Map7 = map(Cur7, 0, 1023, 0, 127);
if (abs(Cur7 - LastPot7) >= 8) {
MidiSend(chan7,Exp,Map7);
LastPot7 = Cur7;
}
//Expression pedal on analog pin A15 to Channel 8
int Cur8 = analogRead(15);
int Map8 = map(Cur8, 0, 1023, 0, 127);
if (abs(Cur8 - LastPot8) >= 8) {
MidiSend(chan8,Exp,Map8);
LastPot8 = Cur8;
}
}
void MidiSend(int one, int two, int three) {
Serial.write(one);
Serial.write(two);
Serial.write(three);
}
Revised Matrixed Code
Arduino// Name: Arduino Mega Midi Controller Mega side.
// Created: May 10, 2021
// Last Edited: Mar 26, 2022
// Author: Larason2
// Acknowledgements: Bald Engineer, Amanda Ghassaei, jeffb42, GrumpyMike, John Main, Ghost, RIP Tutorial, Arduino tutorials.
// Includes Midi Through, wiring for pistons, improved debounce.
//Setup Key Data Arrays
byte keysA[11][6];
byte keysB[11][6];
byte keysC[7][6];
byte keysE[6][6];
//Setup Key Press Arrays
byte lastA[11][6];
byte lastB[11][6];
byte lastC[7][6];
byte lastE[6][6];
//Setup midi channel values
int noteOn1 = 144;
int noteOff1 = 128;
int noteOn2 = 145;
int noteOff2 = 129;
int noteOn3 = 146;
int noteOff3 = 130;
int noteOn4 = 147;
int noteOff4 = 131;
//Setup volume control channels
int CCchan6 = 181;
int CCchan7 = 182;
//Setup midi variables
int velocity = 100;
int Exp = 11;
//Setup Pot Monitoring variables
int LastPot6 = 1;
int LastPot7 = 1;
//Setup variable to debounce pots. increase to decrease bounce on the pots (units of analog signal variation)
int PotT = 10;
//Setup variables for Midi Thru
boolean byteReady;
unsigned char midiByte;
//Setup variables for key debounce on
unsigned long BounceAOn[11][6];
unsigned long BounceBOn[11][6];
unsigned long BounceCOn[7][6];
unsigned long BounceEOn[6][6];
//Setup variables for key debounce on
unsigned long BounceAOff[11][6];
unsigned long BounceBOff[11][6];
unsigned long BounceCOff[7][6];
unsigned long BounceEOff[6][6];
//Setup variable for adjusting key debounce
//Increase to decrease bounce on the keys (units of milliseconds)
unsigned long Delay = 50;
void setup() {
// Start Serial
Serial.begin(31250);
//Initialize Row Pins Keyboard A
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
//Initialize Column Pins Keyboard A
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(10, INPUT);
pinMode(11, INPUT);
pinMode(12, INPUT);
pinMode(14, INPUT);
pinMode(15, INPUT);
pinMode(16, INPUT);
pinMode(17, INPUT);
pinMode(18, INPUT);
pinMode(19, INPUT);
//Initialize Row Pins Keyboard B
pinMode(22, INPUT);
pinMode(23, INPUT);
pinMode(24, INPUT);
pinMode(25, INPUT);
pinMode(26, INPUT);
pinMode(27, INPUT);
//Initialize Column Pins Keyboard B
pinMode(28, INPUT);
pinMode(29, INPUT);
pinMode(30, INPUT);
pinMode(31, INPUT);
pinMode(32, INPUT);
pinMode(33, INPUT);
pinMode(34, INPUT);
pinMode(35, INPUT);
pinMode(36, INPUT);
pinMode(37, INPUT);
pinMode(38, INPUT);
//Initialize Row Pins Keyboard C (Pedals)
pinMode(39, INPUT);
pinMode(40, INPUT);
pinMode(41, INPUT);
pinMode(42, INPUT);
pinMode(43, INPUT);
pinMode(44, INPUT);
//Initialize Column Pins Keyboard C (Pedals)
pinMode(45, INPUT);
pinMode(46, INPUT);
pinMode(47, INPUT);
pinMode(48, INPUT);
pinMode(49, INPUT);
pinMode(50, INPUT);
pinMode(51, INPUT);
//Keyboard E, Pistons Rows
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
//Keyboard E, Piston Columns
pinMode(A6, INPUT);
pinMode(A7, INPUT);
pinMode(A8, INPUT);
pinMode(A9, INPUT);
pinMode(A10, INPUT);
pinMode(A11, INPUT);
//Pot Pins
pinMode(A13, INPUT);
pinMode(A14, INPUT);
//Initialize Midi Thru
byteReady = false;
midiByte = 0;
}
void loop() {
// Read Keyboard A
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, OUTPUT);
digitalWrite(8, LOW);
keysA[0][0] = digitalRead(2);
pinMode(8, INPUT);
pinMode(9, OUTPUT);
digitalWrite(9, LOW);
keysA[1][0] = digitalRead(3);
keysA[1][1] = digitalRead(4);
keysA[1][2] = digitalRead(5);
keysA[1][3] = digitalRead(6);
keysA[1][4] = digitalRead(7);
keysA[1][5] = digitalRead(2);
pinMode(9, INPUT);
pinMode(10, OUTPUT);
digitalWrite(10, LOW);
keysA[2][0] = digitalRead(3);
keysA[2][1] = digitalRead(4);
keysA[2][2] = digitalRead(5);
keysA[2][3] = digitalRead(6);
keysA[2][4] = digitalRead(7);
keysA[2][5] = digitalRead(2);
pinMode(10, INPUT);
pinMode(11, OUTPUT);
digitalWrite(11, LOW);
keysA[3][0] = digitalRead(3);
keysA[3][1] = digitalRead(4);
keysA[3][2] = digitalRead(5);
keysA[3][3] = digitalRead(6);
keysA[3][4] = digitalRead(7);
keysA[3][5] = digitalRead(2);
pinMode(11, INPUT);
pinMode(12, OUTPUT);
digitalWrite(12, LOW);
keysA[4][0] = digitalRead(3);
keysA[4][1] = digitalRead(4);
keysA[4][2] = digitalRead(5);
keysA[4][3] = digitalRead(6);
keysA[4][4] = digitalRead(7);
keysA[4][5] = digitalRead(2);
pinMode(12, INPUT);
pinMode(14, OUTPUT);
digitalWrite(14, LOW);
keysA[5][0] = digitalRead(3);
keysA[5][1] = digitalRead(4);
keysA[5][2] = digitalRead(5);
keysA[5][3] = digitalRead(6);
keysA[5][4] = digitalRead(7);
keysA[5][5] = digitalRead(2);
pinMode(14, INPUT);
pinMode(15, OUTPUT);
digitalWrite(15, LOW);
keysA[6][0] = digitalRead(3);
keysA[6][1] = digitalRead(4);
keysA[6][2] = digitalRead(5);
keysA[6][3] = digitalRead(6);
keysA[6][4] = digitalRead(7);
keysA[6][5] = digitalRead(2);
pinMode(15, INPUT);
pinMode(16, OUTPUT);
digitalWrite(16, LOW);
keysA[7][0] = digitalRead(3);
keysA[7][1] = digitalRead(4);
keysA[7][2] = digitalRead(5);
keysA[7][3] = digitalRead(6);
keysA[7][4] = digitalRead(7);
keysA[7][5] = digitalRead(2);
pinMode(16, INPUT);
pinMode(17, OUTPUT);
digitalWrite(17, LOW);
keysA[8][0] = digitalRead(3);
keysA[8][1] = digitalRead(4);
keysA[8][2] = digitalRead(5);
keysA[8][3] = digitalRead(6);
keysA[8][4] = digitalRead(7);
keysA[8][5] = digitalRead(2);
pinMode(17, INPUT);
pinMode(18, OUTPUT);
digitalWrite(18, LOW);
keysA[9][0] = digitalRead(3);
keysA[9][1] = digitalRead(4);
keysA[9][2] = digitalRead(5);
keysA[9][3] = digitalRead(6);
keysA[9][4] = digitalRead(7);
keysA[9][5] = digitalRead(2);
pinMode(18, INPUT);
pinMode(19, OUTPUT);
digitalWrite(19, LOW);
keysA[10][0] = digitalRead(3);
keysA[10][1] = digitalRead(4);
keysA[10][2] = digitalRead(5);
keysA[10][3] = digitalRead(6);
keysA[10][4] = digitalRead(7);
keysA[10][5] = digitalRead(2);
pinMode(19, INPUT);
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
// Read Keyboard B
pinMode(22, INPUT_PULLUP);
pinMode(23, INPUT_PULLUP);
pinMode(24, INPUT_PULLUP);
pinMode(25, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
pinMode(27, INPUT_PULLUP);
pinMode(28, OUTPUT);
digitalWrite(28, LOW);
keysB[0][0] = digitalRead(22);
pinMode(28, INPUT);
pinMode(29, OUTPUT);
digitalWrite(29, LOW);
keysB[1][0] = digitalRead(23);
keysB[1][1] = digitalRead(24);
keysB[1][2] = digitalRead(25);
keysB[1][3] = digitalRead(26);
keysB[1][4] = digitalRead(27);
keysB[1][5] = digitalRead(22);
pinMode(29, INPUT);
pinMode(30, OUTPUT);
digitalWrite(30, LOW);
keysB[2][0] = digitalRead(23);
keysB[2][1] = digitalRead(24);
keysB[2][2] = digitalRead(25);
keysB[2][3] = digitalRead(26);
keysB[2][4] = digitalRead(27);
keysB[2][5] = digitalRead(22);
pinMode(30, INPUT);
pinMode(31, OUTPUT);
digitalWrite(31, LOW);
keysB[3][0] = digitalRead(23);
keysB[3][1] = digitalRead(24);
keysB[3][2] = digitalRead(25);
keysB[3][3] = digitalRead(26);
keysB[3][4] = digitalRead(27);
keysB[3][5] = digitalRead(22);
pinMode(31, INPUT);
pinMode(32, OUTPUT);
digitalWrite(32, LOW);
keysB[4][0] = digitalRead(23);
keysB[4][1] = digitalRead(24);
keysB[4][2] = digitalRead(25);
keysB[4][3] = digitalRead(26);
keysB[4][4] = digitalRead(27);
keysB[4][5] = digitalRead(22);
pinMode(32, INPUT);
pinMode(33, OUTPUT);
digitalWrite(33, LOW);
keysB[5][0] = digitalRead(23);
keysB[5][1] = digitalRead(24);
keysB[5][2] = digitalRead(25);
keysB[5][3] = digitalRead(26);
keysB[5][4] = digitalRead(27);
keysB[5][5] = digitalRead(22);
pinMode(33, INPUT);
pinMode(34, OUTPUT);
digitalWrite(34, LOW);
keysB[6][0] = digitalRead(23);
keysB[6][1] = digitalRead(24);
keysB[6][2] = digitalRead(25);
keysB[6][3] = digitalRead(26);
keysB[6][4] = digitalRead(27);
keysB[6][5] = digitalRead(22);
pinMode(34, INPUT);
pinMode(35, OUTPUT);
digitalWrite(35, LOW);
keysB[7][0] = digitalRead(23);
keysB[7][1] = digitalRead(24);
keysB[7][2] = digitalRead(25);
keysB[7][3] = digitalRead(26);
keysB[7][4] = digitalRead(27);
keysB[7][5] = digitalRead(22);
pinMode(35, INPUT);
pinMode(36, OUTPUT);
digitalWrite(36, LOW);
keysB[8][0] = digitalRead(23);
keysB[8][1] = digitalRead(24);
keysB[8][2] = digitalRead(25);
keysB[8][3] = digitalRead(26);
keysB[8][4] = digitalRead(27);
keysB[8][5] = digitalRead(22);
pinMode(36, INPUT);
pinMode(37, OUTPUT);
digitalWrite(37, LOW);
keysB[9][0] = digitalRead(23);
keysB[9][1] = digitalRead(24);
keysB[9][2] = digitalRead(25);
keysB[9][3] = digitalRead(26);
keysB[9][4] = digitalRead(27);
keysB[9][5] = digitalRead(22);
pinMode(37, INPUT);
pinMode(38, OUTPUT);
digitalWrite(38, LOW);
keysB[10][0] = digitalRead(23);
keysB[10][1] = digitalRead(24);
keysB[10][2] = digitalRead(25);
keysB[10][3] = digitalRead(26);
keysB[10][4] = digitalRead(27);
keysB[10][5] = digitalRead(22);
pinMode(38, INPUT);
pinMode(23, INPUT);
pinMode(24, INPUT);
pinMode(25, INPUT);
pinMode(26, INPUT);
pinMode(27, INPUT);
pinMode(22, INPUT);
// Read Keyboard C
//Set Row pins to read
pinMode(39, INPUT_PULLUP);
pinMode(40, INPUT_PULLUP);
pinMode(41, INPUT_PULLUP);
pinMode(42, INPUT_PULLUP);
pinMode(43, INPUT_PULLUP);
pinMode(44, INPUT_PULLUP);
pinMode(45, OUTPUT);
digitalWrite(45, LOW);
keysC[0][0] = digitalRead(39);
pinMode(45, INPUT);
pinMode(46, OUTPUT);
digitalWrite(46, LOW);
keysC[1][0] = digitalRead(40);
keysC[1][1] = digitalRead(41);
keysC[1][2] = digitalRead(42);
keysC[1][3] = digitalRead(43);
keysC[1][4] = digitalRead(44);
keysC[1][5] = digitalRead(39);
pinMode(46, INPUT);
pinMode(47, OUTPUT);
digitalWrite(47, LOW);
keysC[2][0] = digitalRead(40);
keysC[2][1] = digitalRead(41);
keysC[2][2] = digitalRead(42);
keysC[2][3] = digitalRead(43);
keysC[2][4] = digitalRead(44);
keysC[2][5] = digitalRead(39);
pinMode(47, INPUT);
pinMode(48, OUTPUT);
digitalWrite(48, LOW);
keysC[3][0] = digitalRead(40);
keysC[3][1] = digitalRead(41);
keysC[3][2] = digitalRead(42);
keysC[3][3] = digitalRead(43);
keysC[3][4] = digitalRead(44);
keysC[3][5] = digitalRead(39);
pinMode(48, INPUT);
pinMode(49, OUTPUT);
digitalWrite(49, LOW);
keysC[4][0] = digitalRead(40);
keysC[4][1] = digitalRead(41);
keysC[4][2] = digitalRead(42);
keysC[4][3] = digitalRead(43);
keysC[4][4] = digitalRead(44);
keysC[4][5] = digitalRead(39);
pinMode(49, INPUT);
pinMode(50, OUTPUT);
digitalWrite(50, LOW);
keysC[5][0] = digitalRead(40);
keysC[5][1] = digitalRead(41);
keysC[5][2] = digitalRead(42);
keysC[5][3] = digitalRead(43);
keysC[5][4] = digitalRead(44);
keysC[5][5] = digitalRead(39);
pinMode(50, INPUT);
pinMode(51, OUTPUT);
digitalWrite(51, LOW);
keysC[6][0] = digitalRead(40);
pinMode(51, INPUT);
pinMode(39, INPUT);
pinMode(40, INPUT);
pinMode(41, INPUT);
pinMode(42, INPUT);
pinMode(43, INPUT);
pinMode(44, INPUT);
//Read Piston data (Keyboard E)
pinMode(A0, INPUT_PULLUP);
pinMode(A1, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);
pinMode(A3, INPUT_PULLUP);
pinMode(A4, INPUT_PULLUP);
pinMode(A5, INPUT_PULLUP);
pinMode(20, INPUT_PULLUP);
pinMode(21, INPUT_PULLUP);
pinMode(52, INPUT_PULLUP);
pinMode(53, INPUT_PULLUP);
pinMode(A12, INPUT_PULLUP);
pinMode(A13, INPUT_PULLUP);
pinMode(A6, OUTPUT);
digitalWrite(A6, LOW);
keysE[0][0] = digitalRead(A0);
keysE[0][1] = digitalRead(A1);
keysE[0][2] = digitalRead(A2);
keysE[0][3] = digitalRead(A3);
keysE[0][4] = digitalRead(A4);
keysE[0][5] = digitalRead(A5);
pinMode(A6, INPUT);
pinMode(A7, OUTPUT);
digitalWrite(A7, LOW);
keysE[1][0] = digitalRead(A0);
keysE[1][1] = digitalRead(A1);
keysE[1][2] = digitalRead(A2);
keysE[1][3] = digitalRead(A3);
keysE[1][4] = digitalRead(A4);
keysE[1][5] = digitalRead(A5);
pinMode(A7, INPUT);
pinMode(A8, OUTPUT);
digitalWrite(A8, LOW);
keysE[2][0] = digitalRead(A0);
pinMode(A8, INPUT);
pinMode(A9, OUTPUT);
digitalWrite(A9, LOW);
keysE[3][0] = digitalRead(20);
keysE[3][1] = digitalRead(21);
keysE[3][2] = digitalRead(52);
keysE[3][3] = digitalRead(53);
keysE[3][4] = digitalRead(A12);
keysE[3][5] = digitalRead(A13);
pinMode(A9, INPUT);
pinMode(A10, OUTPUT);
digitalWrite(A10, LOW);
keysE[4][0] = digitalRead(20);
keysE[4][1] = digitalRead(21);
keysE[4][2] = digitalRead(52);
keysE[4][3] = digitalRead(53);
keysE[4][4] = digitalRead(A12);
keysE[4][5] = digitalRead(A13);
pinMode(A10, INPUT);
pinMode(A11, OUTPUT);
digitalWrite(A11, LOW);
keysE[5][0] = digitalRead(20);
keysE[5][1] = digitalRead(21);
keysE[5][2] = digitalRead(52);
keysE[5][3] = digitalRead(53);
keysE[5][4] = digitalRead(A12);
pinMode(A11, INPUT);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
pinMode(20, INPUT);
pinMode(21, INPUT);
pinMode(52, INPUT);
pinMode(53, INPUT);
pinMode(A12, INPUT);
pinMode(A13, INPUT);
//Invert Keyboard C data (For switches that are Normally Closed)
//Column 1
if (keysC[0][0] == 0) {
keysC[0][0] = 1;
}
else
if (keysC[0][0] == 1) {
keysC[0][0] = 0;
}
//Column 2
if (keysC[1][0] == 0) {
keysC[1][0] = 1;
}
else
if (keysC[1][0] == 1) {
keysC[1][0] = 0;
}
if (keysC[1][1] == 0) {
keysC[1][1] = 1;
}
else
if (keysC[1][1] == 1) {
keysC[1][1] = 0;
}
if (keysC[1][2] == 0) {
keysC[1][2] = 1;
}
else
if (keysC[1][2] == 1) {
keysC[1][2] = 0;
}
if (keysC[1][3] == 0) {
keysC[1][3] = 1;
}
else
if (keysC[1][3] == 1) {
keysC[1][3] = 0;
}
if (keysC[1][4] == 0) {
keysC[1][4] = 1;
}
else
if (keysC[1][4] == 1) {
keysC[1][4] = 0;
}
if (keysC[1][5] == 0) {
keysC[1][5] = 1;
}
else
if (keysC[1][5] == 1) {
keysC[1][5] = 0;
}
//Column 3
if (keysC[2][0] == 0) {
keysC[2][0] = 1;
}
else
if (keysC[2][0] == 1) {
keysC[2][0] = 0;
}
if (keysC[2][1] == 0) {
keysC[2][1] = 1;
}
else
if (keysC[2][1] == 1) {
keysC[2][1] = 0;
}
if (keysC[2][2] == 0) {
keysC[2][2] = 1;
}
else
if (keysC[2][2] == 1) {
keysC[2][2] = 0;
}
if (keysC[2][3] == 0) {
keysC[2][3] = 1;
}
else
if (keysC[2][3] == 1) {
keysC[2][3] = 0;
}
if (keysC[2][4] == 0) {
keysC[2][4] = 1;
}
else
if (keysC[2][4] == 1) {
keysC[2][4] = 0;
}
if (keysC[2][5] == 0) {
keysC[2][5] = 1;
}
else
if (keysC[2][5] == 1) {
keysC[2][5] = 0;
}
//Column 4
if (keysC[3][0] == 0) {
keysC[3][0] = 1;
}
else
if (keysC[3][0] == 1) {
keysC[3][0] = 0;
}
if (keysC[3][1] == 0) {
keysC[3][1] = 1;
}
else
if (keysC[3][1] == 1) {
keysC[3][1] = 0;
}
if (keysC[3][2] == 0) {
keysC[3][2] = 1;
}
else
if (keysC[3][2] == 1) {
keysC[3][2] = 0;
}
if (keysC[3][3] == 0) {
keysC[3][3] = 1;
}
else
if (keysC[3][3] == 1) {
keysC[3][3] = 0;
}
if (keysC[3][4] == 0) {
keysC[3][4] = 1;
}
else
if (keysC[3][4] == 1) {
keysC[3][4] = 0;
}
if (keysC[3][5] == 0) {
keysC[3][5] = 1;
}
else
if (keysC[3][5] == 1) {
keysC[3][5] = 0;
}
//Column 5
if (keysC[4][0] == 0) {
keysC[4][0] = 1;
}
else
if (keysC[4][0] == 1) {
keysC[4][0] = 0;
}
if (keysC[4][1] == 0) {
keysC[4][1] = 1;
}
else
if (keysC[4][1] == 1) {
keysC[4][1] = 0;
}
if (keysC[4][2] == 0) {
keysC[4][2] = 1;
}
else
if (keysC[4][2] == 1) {
keysC[4][2] = 0;
}
if (keysC[4][3] == 0) {
keysC[4][3] = 1;
}
else
if (keysC[4][3] == 1) {
keysC[4][3] = 0;
}
if (keysC[4][4] == 0) {
keysC[4][4] = 1;
}
else
if (keysC[4][4] == 1) {
keysC[4][4] = 0;
}
if (keysC[4][5] == 0) {
keysC[4][5] = 1;
}
else
if (keysC[4][5] == 1) {
keysC[4][5] = 0;
}
//Column 6
if (keysC[5][0] == 0) {
keysC[5][0] = 1;
}
else
if (keysC[5][0] == 1) {
keysC[5][0] = 0;
}
if (keysC[5][1] == 0) {
keysC[5][1] = 1;
}
else
if (keysC[5][1] == 1) {
keysC[5][1] = 0;
}
if (keysC[5][2] == 0) {
keysC[5][2] = 1;
}
else
if (keysC[5][2] == 1) {
keysC[5][2] = 0;
}
if (keysC[5][3] == 0) {
keysC[5][3] = 1;
}
else
if (keysC[5][3] == 1) {
keysC[5][3] = 0;
}
if (keysC[5][4] == 0) {
keysC[5][4] = 1;
}
else
if (keysC[5][4] == 1) {
keysC[5][4] = 0;
}
if (keysC[5][5] == 0) {
keysC[5][5] = 1;
}
else
if (keysC[5][5] == 1) {
keysC[5][5] = 0;
}
//Column 7
if (keysC[6][0] == 0) {keysC[6][0] = 1;}
else
if (keysC[6][0] == 1) {keysC[6][0] = 0;}
//Write Keyboard A
//A36
if (lastA[0][0] == 7) {
BounceAOn[0][0] = millis();
}
if ((keysA[0][0] == 0) and (lastA[0][0] == 0) and ((millis() - BounceAOn[0][0]) > Delay)) {
MidiSend(noteOn1, 36, velocity);
lastA[0][0] = 7;
}
if (lastA[0][0] == 0) {
BounceAOff[0][0] = millis();
}
if ((keysA[0][0] == 1) and (lastA[0][0] == 7) and ((millis() - BounceAOff[0][0]) > Delay)) {
MidiSend(noteOff1, 36, velocity);
lastA[0][0] = 0;
}
//A37
if (lastA[1][0] == 7) {
BounceAOn[1][0] = millis();
}
if ((keysA[1][0] == 0) and (lastA[1][0] == 0) and ((millis() - BounceAOn[1][0]) > Delay)) {
MidiSend(noteOn1, 37, velocity);
lastA[1][0] = 7;
}
if (lastA[1][0] == 0) {
BounceAOff[1][0] = millis();
}
if ((keysA[1][0] == 1) and (lastA[1][0] == 7) and ((millis() - BounceAOff[1][0]) > Delay)) {
MidiSend(noteOff1, 37, velocity);
lastA[1][0] = 0;
}
//A38
if (lastA[1][1] == 7) {
BounceAOn[1][1] = millis();
}
if ((keysA[1][1] == 0) and (lastA[1][1] == 0) and ((millis() - BounceAOn[1][1]) > Delay)) {
MidiSend(noteOn1, 38, velocity);
lastA[1][1] = 7;
}
if (lastA[1][1] == 0) {
BounceAOff[1][1] = millis();
}
if ((keysA[1][1] == 1) and (lastA[1][1] == 7) and ((millis() - BounceAOff[1][1]) > Delay)) {
MidiSend(noteOff1, 38, velocity);
lastA[1][1] = 0;
}
//A39
if (lastA[1][2] == 7) {
BounceAOn[1][2] = millis();
}
if ((keysA[1][2] == 0) and (lastA[1][2] == 0) and ((millis() - BounceAOn[1][2]) > Delay)) {
MidiSend(noteOn1, 39, velocity);
lastA[1][2] = 7;
}
if (lastA[1][2] == 0) {
BounceAOff[1][2] = millis();
}
if ((keysA[1][2] == 1) and (lastA[1][2] == 7) and ((millis() - BounceAOff[1][2]) > Delay)) {
MidiSend(noteOff1, 39, velocity);
lastA[1][2] = 0;
}
//A40
if (lastA[1][3] == 7) {
BounceAOn[1][3] = millis();
}
if ((keysA[1][3] == 0) and (lastA[1][3] == 0) and ((millis() - BounceAOn[1][3]) > Delay)) {
MidiSend(noteOn1, 40, velocity);
lastA[1][3] = 7;
}
if (lastA[1][3] == 0) {
BounceAOff[1][3] = millis();
}
if ((keysA[1][3] == 1) and (lastA[1][3] == 7) and ((millis() - BounceAOff[1][3]) > Delay)) {
MidiSend(noteOff1, 40, velocity);
lastA[1][3] = 0;
}
//A41
if (lastA[1][4] == 7) {
BounceAOn[1][4] = millis();
}
if ((keysA[1][4] == 0) and (lastA[1][4] == 0) and ((millis() - BounceAOn[1][4]) > Delay)) {
MidiSend(noteOn1, 41, velocity);
lastA[1][4] = 7;
}
if (lastA[1][4] == 0) {
BounceAOff[1][4] = millis();
}
if ((keysA[1][4] == 1) and (lastA[1][4] == 7) and ((millis() - BounceAOff[1][4]) > Delay)) {
MidiSend(noteOff1, 41, velocity);
lastA[1][4] = 0;
}
//A42
if (lastA[1][5] == 7) {
BounceAOn[1][5] = millis();
}
if ((keysA[1][5] == 0) and (lastA[1][5] == 0) and ((millis() - BounceAOn[1][5]) > Delay)) {
MidiSend(noteOn1, 42, velocity);
lastA[1][5] = 7;
}
if (lastA[1][5] == 0) {
BounceAOff[1][5] = millis();
}
if ((keysA[1][5] == 1) and (lastA[1][5] == 7) and ((millis() - BounceAOff[1][5]) > Delay)) {
MidiSend(noteOff1, 42, velocity);
lastA[1][5] = 0;
}
//A43
if (lastA[2][0] == 7) {
BounceAOn[2][0] = millis();
}
if ((keysA[2][0] == 0) and (lastA[2][0] == 0) and ((millis() - BounceAOn[2][0]) > Delay)) {
MidiSend(noteOn1, 43, velocity);
lastA[2][0] = 7;
}
if (lastA[2][0] == 0) {
BounceAOff[2][0] = millis();
}
if ((keysA[2][0] == 1) and (lastA[2][0] == 7) and ((millis() - BounceAOff[2][0]) > Delay)) {
MidiSend(noteOff1, 43, velocity);
lastA[2][0] = 0;
}
//A44
if (lastA[2][1] == 7) {
BounceAOn[2][1] = millis();
}
if ((keysA[2][1] == 0) and (lastA[2][1] == 0) and ((millis() - BounceAOn[2][1]) > Delay)) {
MidiSend(noteOn1, 44, velocity);
lastA[2][1] = 7;
}
if (lastA[2][1] == 0) {
BounceAOff[2][1] = millis();
}
if ((keysA[2][1] == 1) and (lastA[2][1] == 7) and ((millis() - BounceAOff[2][1]) > Delay)) {
MidiSend(noteOff1, 44, velocity);
lastA[2][1] = 0;
}
//A45
if (lastA[2][2] == 7) {
BounceAOn[2][2] = millis();
}
if ((keysA[2][2] == 0) and (lastA[2][2] == 0) and ((millis() - BounceAOn[2][2]) > Delay)) {
MidiSend(noteOn1, 45, velocity);
lastA[2][2] = 7;
}
if (lastA[2][2] == 0) {
BounceAOff[2][2] = millis();
}
if ((keysA[2][2] == 1) and (lastA[2][2] == 7) and ((millis() - BounceAOff[2][2]) > Delay)) {
MidiSend(noteOff1, 45, velocity);
lastA[2][2] = 0;
}
//A46
if (lastA[2][3] == 7) {
BounceAOn[2][3] = millis();
}
if ((keysA[2][3] == 0) and (lastA[2][3] == 0) and ((millis() - BounceAOn[2][3]) > Delay)) {
MidiSend(noteOn1, 46, velocity);
lastA[2][3] = 7;
}
if (lastA[2][3] == 0) {
BounceAOff[2][3] = millis();
}
if ((keysA[2][3] == 1) and (lastA[2][3] == 7) and ((millis() - BounceAOff[2][3]) > Delay)) {
MidiSend(noteOff1, 46, velocity);
lastA[2][3] = 0;
}
//A47
if (lastA[2][4] == 7) {
BounceAOn[2][4] = millis();
}
if ((keysA[2][4] == 0) and (lastA[2][4] == 0) and ((millis() - BounceAOn[2][4]) > Delay)) {
MidiSend(noteOn1, 47, velocity);
lastA[2][4] = 7;
}
if (lastA[2][4] == 0) {
BounceAOff[2][4] = millis();
}
if ((keysA[2][4] == 1) and (lastA[2][4] == 7) and ((millis() - BounceAOff[2][4]) > Delay)) {
MidiSend(noteOff1, 47, velocity);
lastA[2][4] = 0;
}
//A48
if (lastA[2][5] == 7) {
BounceAOn[2][5] = millis();
}
if ((keysA[2][5] == 0) and (lastA[2][5] == 0) and ((millis() - BounceAOn[2][5]) > Delay)) {
MidiSend(noteOn1, 48, velocity);
lastA[2][5] = 7;
}
if (lastA[2][5] == 0) {
BounceAOff[2][5] = millis();
}
if ((keysA[2][5] == 1) and (lastA[2][5] == 7) and ((millis() - BounceAOff[2][5]) > Delay)) {
MidiSend(noteOff1, 48, velocity);
lastA[2][5] = 0;
}
//A49
if (lastA[3][0] == 7) {
BounceAOn[3][0] = millis();
}
if ((keysA[3][0] == 0) and (lastA[3][0] == 0) and ((millis() - BounceAOn[3][0]) > Delay)) {
MidiSend(noteOn1, 49, velocity);
lastA[3][0] = 7;
}
if (lastA[3][0] == 0) {
BounceAOff[3][0] = millis();
}
if ((keysA[3][0] == 1) and (lastA[3][0] == 7) and ((millis() - BounceAOff[3][0]) > Delay)) {
MidiSend(noteOff1, 49, velocity);
lastA[3][0] = 0;
}
//A50
if (lastA[3][1] == 7) {
BounceAOn[3][1] = millis();
}
if ((keysA[3][1] == 0) and (lastA[3][1] == 0) and ((millis() - BounceAOn[3][1]) > Delay)) {
MidiSend(noteOn1, 50, velocity);
lastA[3][1] = 7;
}
if (lastA[3][1] == 0) {
BounceAOff[3][1] = millis();
}
if ((keysA[3][1] == 1) and (lastA[3][1] == 7) and ((millis() - BounceAOff[3][1]) > Delay)) {
MidiSend(noteOff1, 50, velocity);
lastA[3][1] = 0;
}
//A51
if (lastA[3][2] == 7) {
BounceAOn[3][2] = millis();
}
if ((keysA[3][2] == 0) and (lastA[3][2] == 0) and ((millis() - BounceAOn[3][2]) > Delay)) {
MidiSend(noteOn1, 51, velocity);
lastA[3][2] = 7;
}
if (lastA[3][2] == 0) {
BounceAOff[3][2] = millis();
}
if ((keysA[3][2] == 1) and (lastA[3][2] == 7) and ((millis() - BounceAOff[3][2]) > Delay)) {
MidiSend(noteOff1, 51, velocity);
lastA[3][2] = 0;
}
//A52
if (lastA[3][3] == 7) {
BounceAOn[3][3] = millis();
}
if ((keysA[3][3] == 0) and (lastA[3][3] == 0) and ((millis() - BounceAOn[3][3]) > Delay)) {
MidiSend(noteOn1, 52, velocity);
lastA[3][3] = 7;
}
if (lastA[3][3] == 0) {
BounceAOff[3][3] = millis();
}
if ((keysA[3][3] == 1) and (lastA[3][3] == 7) and ((millis() - BounceAOff[3][3]) > Delay)) {
MidiSend(noteOff1, 52, velocity);
lastA[3][3] = 0;
}
//A53
if (lastA[3][4] == 7) {
BounceAOn[3][4] = millis();
}
if ((keysA[3][4] == 0) and (lastA[3][4] == 0) and ((millis() - BounceAOn[3][4]) > Delay)) {
MidiSend(noteOn1, 53, velocity);
lastA[3][4] = 7;
}
if (lastA[3][4] == 0) {
BounceAOff[3][4] = millis();
}
if ((keysA[3][4] == 1) and (lastA[3][4] == 7) and ((millis() - BounceAOff[3][4]) > Delay)) {
MidiSend(noteOff1, 53, velocity);
lastA[3][4] = 0;
}
//A54
if (lastA[3][5] == 7) {
BounceAOn[3][5] = millis();
}
if ((keysA[3][5] == 0) and (lastA[3][5] == 0) and ((millis() - BounceAOn[3][5]) > Delay)) {
MidiSend(noteOn1, 54, velocity);
lastA[3][5] = 7;
}
if (lastA[3][5] == 0) {
BounceAOff[3][5] = millis();
}
if ((keysA[3][5] == 1) and (lastA[3][5] == 7) and ((millis() - BounceAOff[3][5]) > Delay)) {
MidiSend(noteOff1, 54, velocity);
lastA[3][5] = 0;
}
//A55
if (lastA[4][0] == 7) {
BounceAOn[4][0] = millis();
}
if ((keysA[4][0] == 0) and (lastA[4][0] == 0) and ((millis() - BounceAOn[4][0]) > Delay)) {
MidiSend(noteOn1, 55, velocity);
lastA[4][0] = 7;
}
if (lastA[4][0] == 0) {
BounceAOff[4][0] = millis();
}
if ((keysA[4][0] == 1) and (lastA[4][0] == 7) and ((millis() - BounceAOff[4][0]) > Delay)) {
MidiSend(noteOff1, 55, velocity);
lastA[4][0] = 0;
}
//A56
if (lastA[4][1] == 7) {
BounceAOn[4][1] = millis();
}
if ((keysA[4][1] == 0) and (lastA[4][1] == 0) and ((millis() - BounceAOn[4][1]) > Delay)) {
MidiSend(noteOn1, 56, velocity);
lastA[4][1] = 7;
}
if (lastA[4][1] == 0) {
BounceAOff[4][1] = millis();
}
if ((keysA[4][1] == 1) and (lastA[4][1] == 7) and ((millis() - BounceAOff[4][1]) > Delay)) {
MidiSend(noteOff1, 56, velocity);
lastA[4][1] = 0;
}
//A57
if (lastA[4][2] == 7) {
BounceAOn[4][2] = millis();
}
if ((keysA[4][2] == 0) and (lastA[4][2] == 0) and ((millis() - BounceAOn[4][2]) > Delay)) {
MidiSend(noteOn1, 57, velocity);
lastA[4][2] = 7;
}
if (lastA[4][2] == 0) {
BounceAOff[4][2] = millis();
}
if ((keysA[4][2] == 1) and (lastA[4][2] == 7) and ((millis() - BounceAOff[4][2]) > Delay)) {
MidiSend(noteOff1, 57, velocity);
lastA[4][2] = 0;
}
//A58
if (lastA[4][3] == 7) {
BounceAOn[4][3] = millis();
}
if ((keysA[4][3] == 0) and (lastA[4][3] == 0) and ((millis() - BounceAOn[4][3]) > Delay)) {
MidiSend(noteOn1, 58, velocity);
lastA[4][3] = 7;
}
if (lastA[4][3] == 0) {
BounceAOff[4][3] = millis();
}
if ((keysA[4][3] == 1) and (lastA[4][3] == 7) and ((millis() - BounceAOff[4][3]) > Delay)) {
MidiSend(noteOff1, 58, velocity);
lastA[4][3] = 0;
}
//59
if (lastA[4][4] == 7) {
BounceAOn[4][4] = millis();
}
if ((keysA[4][4] == 0) and (lastA[4][4] == 0) and ((millis() - BounceAOn[4][4]) > Delay)) {
MidiSend(noteOn1, 59, velocity);
lastA[4][4] = 7;
}
if (lastA[4][4] == 0) {
BounceAOff[4][4] = millis();
}
if ((keysA[4][4] == 1) and (lastA[4][4] == 7) and ((millis() - BounceAOff[4][4]) > Delay)) {
MidiSend(noteOff1, 59, velocity);
lastA[4][4] = 0;
}
//A60
if (lastA[4][5] == 7) {
BounceAOn[4][5] = millis();
}
if ((keysA[4][5] == 0) and (lastA[4][5] == 0) and ((millis() - BounceAOn[4][5]) > Delay)) {
MidiSend(noteOn1, 60, velocity);
lastA[4][5] = 7;
}
if (lastA[4][5] == 0) {
BounceAOff[4][5] = millis();
}
if ((keysA[4][5] == 1) and (lastA[4][5] == 7) and ((millis() - BounceAOff[4][5]) > Delay)) {
MidiSend(noteOff1, 60, velocity);
lastA[4][5] = 0;
}
//A61
if (lastA[5][0] == 7) {
BounceAOn[5][0] = millis();
}
if ((keysA[5][0] == 0) and (lastA[5][0] == 0) and ((millis() - BounceAOn[5][0]) > Delay)) {
MidiSend(noteOn1, 61, velocity);
lastA[5][0] = 7;
}
if (lastA[5][0] == 0) {
BounceAOff[5][0] = millis();
}
if ((keysA[5][0] == 1) and (lastA[5][0] == 7) and ((millis() - BounceAOff[5][0]) > Delay)) {
MidiSend(noteOff1, 61, velocity);
lastA[5][0] = 0;
}
//A62
if (lastA[5][1] == 7) {
BounceAOn[5][1] = millis();
}
if ((keysA[5][1] == 0) and (lastA[5][1] == 0) and ((millis() - BounceAOn[5][1]) > Delay)) {
MidiSend(noteOn1, 62, velocity);
lastA[5][1] = 7;
}
if (lastA[5][1] == 0) {
BounceAOff[5][1] = millis();
}
if ((keysA[5][1] == 1) and (lastA[5][1] == 7) and ((millis() - BounceAOff[5][1]) > Delay)) {
MidiSend(noteOff1, 62, velocity);
lastA[5][1] = 0;
}
//A63
if (lastA[5][2] == 7) {
BounceAOn[5][2] = millis();
}
if ((keysA[5][2] == 0) and (lastA[5][2] == 0) and ((millis() - BounceAOn[5][2]) > Delay)) {
MidiSend(noteOn1, 63, velocity);
lastA[5][2] = 7;
}
if (lastA[5][2] == 0) {
BounceAOff[5][2] = millis();
}
if ((keysA[5][2] == 1) and (lastA[5][2] == 7) and ((millis() - BounceAOff[5][2]) > Delay)) {
MidiSend(noteOff1, 63, velocity);
lastA[5][2] = 0;
}
//A64
if (lastA[5][3] == 7) {
BounceAOn[5][3] = millis();
}
if ((keysA[5][3] == 0) and (lastA[5][3] == 0) and ((millis() - BounceAOn[5][3]) > Delay)) {
MidiSend(noteOn1, 64, velocity);
lastA[5][3] = 7;
}
if (lastA[5][3] == 0) {
BounceAOff[5][3] = millis();
}
if ((keysA[5][3] == 1) and (lastA[5][3] == 7) and ((millis() - BounceAOff[5][3]) > Delay)) {
MidiSend(noteOff1, 64, velocity);
lastA[5][3] = 0;
}
//A65
if (lastA[5][4] == 7) {
BounceAOn[5][4] = millis();
}
if ((keysA[5][4] == 0) and (lastA[5][4] == 0) and ((millis() - BounceAOn[5][4]) > Delay)) {
MidiSend(noteOn1, 65, velocity);
lastA[5][4] = 7;
}
if (lastA[5][4] == 0) {
BounceAOff[5][4] = millis();
}
if ((keysA[5][4] == 1) and (lastA[5][4] == 7) and ((millis() - BounceAOff[5][4]) > Delay)) {
MidiSend(noteOff1, 65, velocity);
lastA[5][4] = 0;
}
//A66
if (lastA[5][5] == 7) {
BounceAOn[5][5] = millis();
}
if ((keysA[5][5] == 0) and (lastA[5][5] == 0) and ((millis() - BounceAOn[5][5]) > Delay)) {
MidiSend(noteOn1, 66, velocity);
lastA[5][5] = 7;
}
if (lastA[5][5] == 0) {
BounceAOff[5][5] = millis();
}
if ((keysA[5][5] == 1) and (lastA[5][5] == 7) and ((millis() - BounceAOff[5][5]) > Delay)) {
MidiSend(noteOff1, 66, velocity);
lastA[5][5] = 0;
}
//A67
if (lastA[6][0] == 7) {
BounceAOn[6][0] = millis();
}
if ((keysA[6][0] == 0) and (lastA[6][0] == 0) and ((millis() - BounceAOn[6][0]) > Delay)) {
MidiSend(noteOn1, 67, velocity);
lastA[6][0] = 7;
}
if (lastA[6][0] == 0) {
BounceAOff[6][0] = millis();
}
if ((keysA[6][0] == 1) and (lastA[6][0] == 7) and ((millis() - BounceAOff[6][0]) > Delay)) {
MidiSend(noteOff1, 67, velocity);
lastA[6][0] = 0;
}
//A68
if (lastA[6][1] == 7) {
BounceAOn[6][1] = millis();
}
if ((keysA[6][1] == 0) and (lastA[6][1] == 0) and ((millis() - BounceAOn[6][1]) > Delay)) {
MidiSend(noteOn1, 68, velocity);
lastA[6][1] = 7;
}
if (lastA[6][1] == 0) {
BounceAOff[6][1] = millis();
}
if ((keysA[6][1] == 1) and (lastA[6][1] == 7) and ((millis() - BounceAOff[6][1]) > Delay)) {
MidiSend(noteOff1, 68, velocity);
lastA[6][1] = 0;
}
//A69
if (lastA[6][2] == 7) {
BounceAOn[6][2] = millis();
}
if ((keysA[6][2] == 0) and (lastA[6][2] == 0) and ((millis() - BounceAOn[6][2]) > Delay)) {
MidiSend(noteOn1, 69, velocity);
lastA[6][2] = 7;
}
if (lastA[6][2] == 0) {
BounceAOff[6][2] = millis();
}
if ((keysA[6][2] == 1) and (lastA[6][2] == 7) and ((millis() - BounceAOff[6][2]) > Delay)) {
MidiSend(noteOff1, 69, velocity);
lastA[6][2] = 0;
}
//A70
if (lastA[6][3] == 7) {
BounceAOn[6][3] = millis();
}
if ((keysA[6][3] == 0) and (lastA[6][3] == 0) and ((millis() - BounceAOn[6][3]) > Delay)) {
MidiSend(noteOn1, 70, velocity);
lastA[6][3] = 7;
}
if (lastA[6][3] == 0) {
BounceAOff[6][3] = millis();
}
if ((keysA[6][3] == 1) and (lastA[6][3] == 7) and ((millis() - BounceAOff[6][3]) > Delay)) {
MidiSend(noteOff1, 70, velocity);
lastA[6][3] = 0;
}
//A71
if (lastA[6][4] == 7) {
BounceAOn[6][4] = millis();
}
if ((keysA[6][4] == 0) and (lastA[6][4] == 0) and ((millis() - BounceAOn[6][4]) > Delay)) {
MidiSend(noteOn1, 71, velocity);
lastA[6][4] = 7;
}
if (lastA[6][4] == 0) {
BounceAOff[6][4] = millis();
}
if ((keysA[6][4] == 1) and (lastA[6][4] == 7) and ((millis() - BounceAOff[6][4]) > Delay)) {
MidiSend(noteOff1, 71, velocity);
lastA[6][4] = 0;
}
//A72
if (lastA[6][5] == 7) {
BounceAOn[6][5] = millis();
}
if ((keysA[6][5] == 0) and (lastA[6][5] == 0) and ((millis() - BounceAOn[6][5]) > Delay)) {
MidiSend(noteOn1, 72, velocity);
lastA[6][5] = 7;
}
if (lastA[6][5] == 0) {
BounceAOff[6][5] = millis();
}
if ((keysA[6][5] == 1) and (lastA[6][5] == 7) and ((millis() - BounceAOff[6][5]) > Delay)) {
MidiSend(noteOff1, 72, velocity);
lastA[6][5] = 0;
}
//A73
if (lastA[7][0] == 7) {
BounceAOn[7][0] = millis();
}
if ((keysA[7][0] == 0) and (lastA[7][0] == 0) and ((millis() - BounceAOn[7][0]) > Delay)) {
MidiSend(noteOn1, 73, velocity);
lastA[7][0] = 7;
}
if (lastA[7][0] == 0) {
BounceAOff[7][0] = millis();
}
if ((keysA[7][0] == 1) and (lastA[7][0] == 7) and ((millis() - BounceAOff[7][0]) > Delay)) {
MidiSend(noteOff1, 73, velocity);
lastA[7][0] = 0;
}
//A74
if (lastA[7][1] == 7) {
BounceAOn[7][1] = millis();
}
if ((keysA[7][1] == 0) and (lastA[7][1] == 0) and ((millis() - BounceAOn[7][1]) > Delay)) {
MidiSend(noteOn1, 74, velocity);
lastA[7][1] = 7;
}
if (lastA[7][1] == 0) {
BounceAOff[7][1] = millis();
}
if ((keysA[7][1] == 1) and (lastA[7][1] == 7) and ((millis() - BounceAOff[7][1]) > Delay)) {
MidiSend(noteOff1, 74, velocity);
lastA[7][1] = 0;
}
//A75
if (lastA[7][2] == 7) {
BounceAOn[7][2] = millis();
}
if ((keysA[7][2] == 0) and (lastA[7][2] == 0) and ((millis() - BounceAOn[7][2]) > Delay)) {
MidiSend(noteOn1, 75, velocity);
lastA[7][2] = 7;
}
if (lastA[7][2] == 0) {
BounceAOff[7][2] = millis();
}
if ((keysA[7][2] == 1) and (lastA[7][2] == 7) and ((millis() - BounceAOff[7][2]) > Delay)) {
MidiSend(noteOff1, 75, velocity);
lastA[7][2] = 0;
}
//A76
if (lastA[7][3] == 7) {
BounceAOn[7][3] = millis();
}
if ((keysA[7][3] == 0) and (lastA[7][3] == 0) and ((millis() - BounceAOn[7][3]) > Delay)) {
MidiSend(noteOn1, 76, velocity);
lastA[7][3] = 7;
}
if (lastA[7][3] == 0) {
BounceAOff[7][3] = millis();
}
if ((keysA[7][3] == 1) and (lastA[7][3] == 7) and ((millis() - BounceAOff[7][3]) > Delay)) {
MidiSend(noteOff1, 76, velocity);
lastA[7][3] = 0;
}
//A77
if (lastA[7][4] == 7) {
BounceAOn[7][4] = millis();
}
if ((keysA[7][4] == 0) and (lastA[7][4] == 0) and ((millis() - BounceAOn[7][4]) > Delay)) {
MidiSend(noteOn1, 77, velocity);
lastA[7][4] = 7;
}
if (lastA[7][4] == 0) {
BounceAOff[7][4] = millis();
}
if ((keysA[7][4] == 1) and (lastA[7][4] == 7) and ((millis() - BounceAOff[7][4]) > Delay)) {
MidiSend(noteOff1, 77, velocity);
lastA[7][4] = 0;
}
//A78
if (lastA[7][5] == 7) {
BounceAOn[7][5] = millis();
}
if ((keysA[7][5] == 0) and (lastA[7][5] == 0) and ((millis() - BounceAOn[7][5]) > Delay)) {
MidiSend(noteOn1, 78, velocity);
lastA[7][5] = 7;
}
if (lastA[7][5] == 0) {
BounceAOff[7][5] = millis();
}
if ((keysA[7][5] == 1) and (lastA[7][5] == 7) and ((millis() - BounceAOff[7][5]) > Delay)) {
MidiSend(noteOff1, 78, velocity);
lastA[7][5] = 0;
}
//A79
if (lastA[8][0] == 7) {
BounceAOn[8][0] = millis();
}
if ((keysA[8][0] == 0) and (lastA[8][0] == 0) and ((millis() - BounceAOn[8][0]) > Delay)) {
MidiSend(noteOn1, 79, velocity);
lastA[8][0] = 7;
}
if (lastA[8][0] == 0) {
BounceAOff[8][0] = millis();
}
if ((keysA[8][0] == 1) and (lastA[8][0] == 7) and ((millis() - BounceAOff[8][0]) > Delay)) {
MidiSend(noteOff1, 79, velocity);
lastA[8][0] = 0;
}
//A80
if (lastA[8][1] == 7) {
BounceAOn[8][1] = millis();
}
if ((keysA[8][1] == 0) and (lastA[8][1] == 0) and ((millis() - BounceAOn[8][1]) > Delay)) {
MidiSend(noteOn1, 80, velocity);
lastA[8][1] = 7;
}
if (lastA[8][1] == 0) {
BounceAOff[8][1] = millis();
}
if ((keysA[8][1] == 1) and (lastA[8][1] == 7) and ((millis() - BounceAOff[8][1]) > Delay)) {
MidiSend(noteOff1, 80, velocity);
lastA[8][1] = 0;
}
//A81
if (lastA[8][2] == 7) {
BounceAOn[8][2] = millis();
}
if ((keysA[8][2] == 0) and (lastA[8][2] == 0) and ((millis() - BounceAOn[8][2]) > Delay)) {
MidiSend(noteOn1, 81, velocity);
lastA[8][2] = 7;
}
if (lastA[8][2] == 0) {
BounceAOff[8][2] = millis();
}
if ((keysA[8][2] == 1) and (lastA[8][2] == 7) and ((millis() - BounceAOff[8][2]) > Delay)) {
MidiSend(noteOff1, 81, velocity);
lastA[8][2] = 0;
}
//A82
if (lastA[8][3] == 7) {
BounceAOn[8][3] = millis();
}
if ((keysA[8][3] == 0) and (lastA[8][3] == 0) and ((millis() - BounceAOn[8][3]) > Delay)) {
MidiSend(noteOn1, 82, velocity);
lastA[8][3] = 7;
}
if (lastA[8][3] == 0) {
BounceAOff[8][3] = millis();
}
if ((keysA[8][3] == 1) and (lastA[8][3] == 7) and ((millis() - BounceAOff[8][3]) > Delay)) {
MidiSend(noteOff1, 82, velocity);
lastA[8][3] = 0;
}
//A83
if (lastA[8][4] == 7) {
BounceAOn[8][4] = millis();
}
if ((keysA[8][4] == 0) and (lastA[8][4] == 0) and ((millis() - BounceAOn[8][4]) > Delay)) {
MidiSend(noteOn1, 83, velocity);
lastA[8][4] = 7;
}
if (lastA[8][4] == 0) {
BounceAOff[8][4] = millis();
}
if ((keysA[8][4] == 1) and (lastA[8][4] == 7) and ((millis() - BounceAOff[8][4]) > Delay)) {
MidiSend(noteOff1, 83, velocity);
lastA[8][4] = 0;
}
//A84
if (lastA[8][5] == 7) {
BounceAOn[8][5] = millis();
}
if ((keysA[8][5] == 0) and (lastA[8][5] == 0) and ((millis() - BounceAOn[8][5]) > Delay)) {
MidiSend(noteOn1, 84, velocity);
lastA[8][5] = 7;
}
if (lastA[8][5] == 0) {
BounceAOff[8][5] = millis();
}
if ((keysA[8][5] == 1) and (lastA[8][5] == 7) and ((millis() - BounceAOff[8][5]) > Delay)) {
MidiSend(noteOff1, 84, velocity);
lastA[8][5] = 0;
}
//A85
if (lastA[9][0] == 7) {
BounceAOn[9][0] = millis();
}
if ((keysA[9][0] == 0) and (lastA[9][0] == 0) and ((millis() - BounceAOn[9][0]) > Delay)) {
MidiSend(noteOn1, 85, velocity);
lastA[9][0] = 7;
}
if (lastA[9][0] == 0) {
BounceAOff[9][0] = millis();
}
if ((keysA[9][0] == 1) and (lastA[9][0] == 7) and ((millis() - BounceAOff[9][0]) > Delay)) {
MidiSend(noteOff1, 85, velocity);
lastA[9][0] = 0;
}
//A86
if (lastA[9][1] == 7) {
BounceAOn[9][1] = millis();
}
if ((keysA[9][1] == 0) and (lastA[9][1] == 0) and ((millis() - BounceAOn[9][1]) > Delay)) {
MidiSend(noteOn1, 86, velocity);
lastA[9][1] = 7;
}
if (lastA[9][1] == 0) {
BounceAOff[9][1] = millis();
}
if ((keysA[9][1] == 1) and (lastA[9][1] == 7) and ((millis() - BounceAOff[9][1]) > Delay)) {
MidiSend(noteOff1, 86, velocity);
lastA[9][1] = 0;
}
//A87
if (lastA[9][2] == 7) {
BounceAOn[9][2] = millis();
}
if ((keysA[9][2] == 0) and (lastA[9][2] == 0) and ((millis() - BounceAOn[9][2]) > Delay)) {
MidiSend(noteOn1, 87, velocity);
lastA[9][2] = 7;
}
if (lastA[9][2] == 0) {
BounceAOff[9][2] = millis();
}
if ((keysA[9][2] == 1) and (lastA[9][2] == 7) and ((millis() - BounceAOff[9][2]) > Delay)) {
MidiSend(noteOff1, 87, velocity);
lastA[9][2] = 0;
}
//A88
if (lastA[9][3] == 7) {
BounceAOn[9][3] = millis();
}
if ((keysA[9][3] == 0) and (lastA[9][3] == 0) and ((millis() - BounceAOn[9][3]) > Delay)) {
MidiSend(noteOn1, 88, velocity);
lastA[9][3] = 7;
}
if (lastA[9][3] == 0) {
BounceAOff[9][3] = millis();
}
if ((keysA[9][3] == 1) and (lastA[9][3] == 7) and ((millis() - BounceAOff[9][3]) > Delay)) {
MidiSend(noteOff1, 88, velocity);
lastA[9][3] = 0;
}
//A89
if (lastA[9][4] == 7) {
BounceAOn[9][4] = millis();
}
if ((keysA[9][4] == 0) and (lastA[9][4] == 0) and ((millis() - BounceAOn[9][4]) > Delay)) {
MidiSend(noteOn1, 89, velocity);
lastA[9][4] = 7;
}
if (lastA[9][4] == 0) {
BounceAOff[9][4] = millis();
}
if ((keysA[9][4] == 1) and (lastA[9][4] == 7) and ((millis() - BounceAOff[9][4]) > Delay)) {
MidiSend(noteOff1, 89, velocity);
lastA[9][4] = 0;
}
//A90
if (lastA[9][5] == 7) {
BounceAOn[9][5] = millis();
}
if ((keysA[9][5] == 0) and (lastA[9][5] == 0) and ((millis() - BounceAOn[9][5]) > Delay)) {
MidiSend(noteOn1, 90, velocity);
lastA[9][5] = 7;
}
if (lastA[9][5] == 0) {
BounceAOff[9][5] = millis();
}
if ((keysA[9][5] == 1) and (lastA[9][5] == 7) and ((millis() - BounceAOff[9][5]) > Delay)) {
MidiSend(noteOff1, 90, velocity);
lastA[9][5] = 0;
}
//A91
if (lastA[10][0] == 7) {
BounceAOn[10][0] = millis();
}
if ((keysA[10][0] == 0) and (lastA[10][0] == 0) and ((millis() - BounceAOn[10][0]) > Delay)) {
MidiSend(noteOn1, 91, velocity);
lastA[10][0] = 7;
}
if (lastA[10][0] == 0) {
BounceAOff[10][0] = millis();
}
if ((keysA[10][0] == 1) and (lastA[10][0] == 7) and ((millis() - BounceAOff[10][0]) > Delay)) {
MidiSend(noteOff1, 91, velocity);
lastA[10][0] = 0;
}
//A92
if (lastA[10][1] == 7) {
BounceAOn[10][1] = millis();
}
if ((keysA[10][1] == 0) and (lastA[10][1] == 0) and ((millis() - BounceAOn[10][1]) > Delay)) {
MidiSend(noteOn1, 92, velocity);
lastA[10][1] = 7;
}
if (lastA[10][1] == 0) {
BounceAOff[10][1] = millis();
}
if ((keysA[10][1] == 1) and (lastA[10][1] == 7) and ((millis() - BounceAOff[10][1]) > Delay)) {
MidiSend(noteOff1, 92, velocity);
lastA[10][1] = 0;
}
//A93
if (lastA[10][2] == 7) {
BounceAOn[10][2] = millis();
}
if ((keysA[10][2] == 0) and (lastA[10][2] == 0) and ((millis() - BounceAOn[10][2]) > Delay)) {
MidiSend(noteOn1, 93, velocity);
lastA[10][2] = 7;
}
if (lastA[10][2] == 0) {
BounceAOff[10][2] = millis();
}
if ((keysA[10][2] == 1) and (lastA[10][2] == 7) and ((millis() - BounceAOff[10][2]) > Delay)) {
MidiSend(noteOff1, 93, velocity);
lastA[10][2] = 0;
}
//A94
if (lastA[10][3] == 7) {
BounceAOn[10][3] = millis();
}
if ((keysA[10][3] == 0) and (lastA[10][3] == 0) and ((millis() - BounceAOn[10][3]) > Delay)) {
MidiSend(noteOn1, 94, velocity);
lastA[10][3] = 7;
}
if (lastA[10][3] == 0) {
BounceAOff[10][3] = millis();
}
if ((keysA[10][3] == 1) and (lastA[10][3] == 7) and ((millis() - BounceAOff[10][3]) > Delay)) {
MidiSend(noteOff1, 94, velocity);
lastA[10][3] = 0;
}
//A95
if (lastA[10][4] == 7) {
BounceAOn[10][4] = millis();
}
if ((keysA[10][4] == 0) and (lastA[10][4] == 0) and ((millis() - BounceAOn[10][4]) > Delay)) {
MidiSend(noteOn1, 95, velocity);
lastA[10][4] = 7;
}
if (lastA[10][4] == 0) {
BounceAOff[10][4] = millis();
}
if ((keysA[10][4] == 1) and (lastA[10][4] == 7) and ((millis() - BounceAOff[10][4]) > Delay)) {
MidiSend(noteOff1, 95, velocity);
lastA[10][4] = 0;
}
//A96
if (lastA[10][5] == 7) {
BounceAOn[10][5] = millis();
}
if ((keysA[10][5] == 0) and (lastA[10][5] == 0) and ((millis() - BounceAOn[10][5]) > Delay)) {
MidiSend(noteOn1, 96, velocity);
lastA[10][5] = 7;
}
if (lastA[10][5] == 0) {
BounceAOff[10][5] = millis();
}
if ((keysA[10][5] == 1) and (lastA[10][5] == 7) and ((millis() - BounceAOff[10][5]) > Delay)) {
MidiSend(noteOff1, 96, velocity);
lastA[10][5] = 0;
}
//Write Keyboard B
//B36
if (lastB[0][0] == 7) {
BounceBOn[0][0] = millis();
}
if ((keysB[0][0] == 0) and (lastB[0][0] == 0) and ((millis() - BounceBOn[0][0]) > Delay)) {
MidiSend(noteOn2, 36, velocity);
lastB[0][0] = 7;
}
if (lastB[0][0] == 0) {
BounceBOff[0][0] = millis();
}
if ((keysB[0][0] == 1) and (lastB[0][0] == 7) and ((millis() - BounceBOff[0][0]) > Delay)) {
MidiSend(noteOff2, 36, velocity);
lastB[0][0] = 0;
}
//B37
if (lastB[1][0] == 7) {
BounceBOn[1][0] = millis();
}
if ((keysB[1][0] == 0) and (lastB[1][0] == 0) and ((millis() - BounceBOn[1][0]) > Delay)) {
MidiSend(noteOn2, 37, velocity);
lastB[1][0] = 7;
}
if (lastB[1][0] == 0) {
BounceBOff[1][0] = millis();
}
if ((keysB[1][0] == 1) and (lastB[1][0] == 7) and ((millis() - BounceBOff[1][0]) > Delay)) {
MidiSend(noteOff2, 37, velocity);
lastB[1][0] = 0;
}
//B38
if (lastB[1][1] == 7) {
BounceBOn[1][1] = millis();
}
if ((keysB[1][1] == 0) and (lastB[1][1] == 0) and ((millis() - BounceBOn[1][1]) > Delay)) {
MidiSend(noteOn2, 38, velocity);
lastB[1][1] = 7;
}
if (lastB[1][1] == 0) {
BounceBOff[1][1] = millis();
}
if ((keysB[1][1] == 1) and (lastB[1][1] == 7) and ((millis() - BounceBOff[1][1]) > Delay)) {
MidiSend(noteOff2, 38, velocity);
lastB[1][1] = 0;
}
//B39
if (lastB[1][2] == 7) {
BounceBOn[1][2] = millis();
}
if ((keysB[1][2] == 0) and (lastB[1][2] == 0) and ((millis() - BounceBOn[1][2]) > Delay)) {
MidiSend(noteOn2, 39, velocity);
lastB[1][2] = 7;
}
if (lastB[1][2] == 0) {
BounceBOff[1][2] = millis();
}
if ((keysB[1][2] == 1) and (lastB[1][2] == 7) and ((millis() - BounceBOff[1][2]) > Delay)) {
MidiSend(noteOff2, 39, velocity);
lastB[1][2] = 0;
}
//B40
if (lastB[1][3] == 7) {
BounceBOn[1][3] = millis();
}
if ((keysB[1][3] == 0) and (lastB[1][3] == 0) and ((millis() - BounceBOn[1][3]) > Delay)) {
MidiSend(noteOn2, 40, velocity);
lastB[1][3] = 7;
}
if (lastB[1][3] == 0) {
BounceBOff[1][3] = millis();
}
if ((keysB[1][3] == 1) and (lastB[1][3] == 7) and ((millis() - BounceBOff[1][3]) > Delay)) {
MidiSend(noteOff2, 40, velocity);
lastB[1][3] = 0;
}
//B41
if (lastB[1][4] == 7) {
BounceBOn[1][4] = millis();
}
if ((keysB[1][4] == 0) and (lastB[1][4] == 0) and ((millis() - BounceBOn[1][4]) > Delay)) {
MidiSend(noteOn2, 41, velocity);
lastB[1][4] = 7;
}
if (lastB[1][4] == 0) {
BounceBOff[1][4] = millis();
}
if ((keysB[1][4] == 1) and (lastB[1][4] == 7) and ((millis() - BounceBOff[1][4]) > Delay)) {
MidiSend(noteOff2, 41, velocity);
lastB[1][4] = 0;
}
//B42
if (lastB[1][5] == 7) {
BounceBOn[1][5] = millis();
}
if ((keysB[1][5] == 0) and (lastB[1][5] == 0) and ((millis() - BounceBOn[1][5]) > Delay)) {
MidiSend(noteOn2, 42, velocity);
lastB[1][5] = 7;
}
if (lastB[1][5] == 0) {
BounceBOff[1][5] = millis();
}
if ((keysB[1][5] == 1) and (lastB[1][5] == 7) and ((millis() - BounceBOff[1][5]) > Delay)) {
MidiSend(noteOff2, 42, velocity);
lastB[1][5] = 0;
}
//B43
if (lastB[2][0] == 7) {
BounceBOn[2][0] = millis();
}
if ((keysB[2][0] == 0) and (lastB[2][0] == 0) and ((millis() - BounceBOn[2][0]) > Delay)) {
MidiSend(noteOn2, 43, velocity);
lastB[2][0] = 7;
}
if (lastB[2][0] == 0) {
BounceBOff[2][0] = millis();
}
if ((keysB[2][0] == 1) and (lastB[2][0] == 7) and ((millis() - BounceBOff[2][0]) > Delay)) {
MidiSend(noteOff2, 43, velocity);
lastB[2][0] = 0;
}
//B44
if (lastB[2][1] == 7) {
BounceBOn[2][1] = millis();
}
if ((keysB[2][1] == 0) and (lastB[2][1] == 0) and ((millis() - BounceBOn[2][1]) > Delay)) {
MidiSend(noteOn2, 44, velocity);
lastB[2][1] = 7;
}
if (lastB[2][1] == 0) {
BounceBOff[2][1] = millis();
}
if ((keysB[2][1] == 1) and (lastB[2][1] == 7) and ((millis() - BounceBOff[2][1]) > Delay)) {
MidiSend(noteOff2, 44, velocity);
lastB[2][1] = 0;
}
//B45
if (lastB[2][2] == 7) {
BounceBOn[2][2] = millis();
}
if ((keysB[2][2] == 0) and (lastB[2][2] == 0) and ((millis() - BounceBOn[2][2]) > Delay)) {
MidiSend(noteOn2, 45, velocity);
lastB[2][2] = 7;
}
if (lastB[2][2] == 0) {
BounceBOff[2][2] = millis();
}
if ((keysB[2][2] == 1) and (lastB[2][2] == 7) and ((millis() - BounceBOff[2][2]) > Delay)) {
MidiSend(noteOff2, 45, velocity);
lastB[2][2] = 0;
}
//B46
if (lastB[2][3] == 7) {
BounceBOn[2][3] = millis();
}
if ((keysB[2][3] == 0) and (lastB[2][3] == 0) and ((millis() - BounceBOn[2][3]) > Delay)) {
MidiSend(noteOn2, 46, velocity);
lastB[2][3] = 7;
}
if (lastB[2][3] == 0) {
BounceBOff[2][3] = millis();
}
if ((keysB[2][3] == 1) and (lastB[2][3] == 7) and ((millis() - BounceBOff[2][3]) > Delay)) {
MidiSend(noteOff2, 46, velocity);
lastB[2][3] = 0;
}
//B47
if (lastB[2][4] == 7) {
BounceBOn[2][4] = millis();
}
if ((keysB[2][4] == 0) and (lastB[2][4] == 0) and ((millis() - BounceBOn[2][4]) > Delay)) {
MidiSend(noteOn2, 47, velocity);
lastB[2][4] = 7;
}
if (lastB[2][4] == 0) {
BounceBOff[2][4] = millis();
}
if ((keysB[2][4] == 1) and (lastB[2][4] == 7) and ((millis() - BounceBOff[2][4]) > Delay)) {
MidiSend(noteOff2, 47, velocity);
lastB[2][4] = 0;
}
//B48
if (lastB[2][5] == 7) {
BounceBOn[2][5] = millis();
}
if ((keysB[2][5] == 0) and (lastB[2][5] == 0) and ((millis() - BounceBOn[2][5]) > Delay)) {
MidiSend(noteOn2, 48, velocity);
lastB[2][5] = 7;
}
if (lastB[2][5] == 0) {
BounceBOff[2][5] = millis();
}
if ((keysB[2][5] == 1) and (lastB[2][5] == 7) and ((millis() - BounceBOff[2][5]) > Delay)) {
MidiSend(noteOff2, 48, velocity);
lastB[2][5] = 0;
}
//B49
if (lastB[3][0] == 7) {
BounceBOn[3][0] = millis();
}
if ((keysB[3][0] == 0) and (lastB[3][0] == 0) and ((millis() - BounceBOn[3][0]) > Delay)) {
MidiSend(noteOn2, 49, velocity);
lastB[3][0] = 7;
}
if (lastB[3][0] == 0) {
BounceBOff[3][0] = millis();
}
if ((keysB[3][0] == 1) and (lastB[3][0] == 7) and ((millis() - BounceBOff[3][0]) > Delay)) {
MidiSend(noteOff2, 49, velocity);
lastB[3][0] = 0;
}
//B50
if (lastB[3][1] == 7) {
BounceBOn[3][1] = millis();
}
if ((keysB[3][1] == 0) and (lastB[3][1] == 0) and ((millis() - BounceBOn[3][1]) > Delay)) {
MidiSend(noteOn2, 50, velocity);
lastB[3][1] = 7;
}
if (lastB[3][1] == 0) {
BounceBOff[3][1] = millis();
}
if ((keysB[3][1] == 1) and (lastB[3][1] == 7) and ((millis() - BounceBOff[3][1]) > Delay)) {
MidiSend(noteOff2, 50, velocity);
lastB[3][1] = 0;
}
//B51
if (lastB[3][2] == 7) {
BounceBOn[3][2] = millis();
}
if ((keysB[3][2] == 0) and (lastB[3][2] == 0) and ((millis() - BounceBOn[3][2]) > Delay)) {
MidiSend(noteOn2, 51, velocity);
lastB[3][2] = 7;
}
if (lastB[3][2] == 0) {
BounceBOff[3][2] = millis();
}
if ((keysB[3][2] == 1) and (lastB[3][2] == 7) and ((millis() - BounceBOff[3][2]) > Delay)) {
MidiSend(noteOff2, 51, velocity);
lastB[3][2] = 0;
}
//B52
if (lastB[3][3] == 7) {
BounceBOn[3][3] = millis();
}
if ((keysB[3][3] == 0) and (lastB[3][3] == 0) and ((millis() - BounceBOn[3][3]) > Delay)) {
MidiSend(noteOn2, 52, velocity);
lastB[3][3] = 7;
}
if (lastB[3][3] == 0) {
BounceBOff[3][3] = millis();
}
if ((keysB[3][3] == 1) and (lastB[3][3] == 7) and ((millis() - BounceBOff[3][3]) > Delay)) {
MidiSend(noteOff2, 52, velocity);
lastB[3][3] = 0;
}
//B53
if (lastB[3][4] == 7) {
BounceBOn[3][4] = millis();
}
if ((keysB[3][4] == 0) and (lastB[3][4] == 0) and ((millis() - BounceBOn[3][4]) > Delay)) {
MidiSend(noteOn2, 53, velocity);
lastB[3][4] = 7;
}
if (lastB[3][4] == 0) {
BounceBOff[3][4] = millis();
}
if ((keysB[3][4] == 1) and (lastB[3][4] == 7) and ((millis() - BounceBOff[3][4]) > Delay)) {
MidiSend(noteOff2, 53, velocity);
lastB[3][4] = 0;
}
//B54
if (lastB[3][5] == 7) {
BounceBOn[3][5] = millis();
}
if ((keysB[3][5] == 0) and (lastB[3][5] == 0) and ((millis() - BounceBOn[3][5]) > Delay)) {
MidiSend(noteOn2, 54, velocity);
lastB[3][5] = 7;
}
if (lastB[3][5] == 0) {
BounceBOff[3][5] = millis();
}
if ((keysB[3][5] == 1) and (lastB[3][5] == 7) and ((millis() - BounceBOff[3][5]) > Delay)) {
MidiSend(noteOff2, 54, velocity);
lastB[3][5] = 0;
}
//B55
if (lastB[4][0] == 7) {
BounceBOn[4][0] = millis();
}
if ((keysB[4][0] == 0) and (lastB[4][0] == 0) and ((millis() - BounceBOn[4][0]) > Delay)) {
MidiSend(noteOn2, 55, velocity);
lastB[4][0] = 7;
}
if (lastB[4][0] == 0) {
BounceBOff[4][0] = millis();
}
if ((keysB[4][0] == 1) and (lastB[4][0] == 7) and ((millis() - BounceBOff[4][0]) > Delay)) {
MidiSend(noteOff2, 55, velocity);
lastB[4][0] = 0;
}
//B56
if (lastB[4][1] == 7) {
BounceBOn[4][1] = millis();
}
if ((keysB[4][1] == 0) and (lastB[4][1] == 0) and ((millis() - BounceBOn[4][1]) > Delay)) {
MidiSend(noteOn2, 56, velocity);
lastB[4][1] = 7;
}
if (lastB[4][1] == 0) {
BounceBOff[4][1] = millis();
}
if ((keysB[4][1] == 1) and (lastB[4][1] == 7) and ((millis() - BounceBOff[4][1]) > Delay)) {
MidiSend(noteOff2, 56, velocity);
lastB[4][1] = 0;
}
//B57
if (lastB[4][2] == 7) {
BounceBOn[4][2] = millis();
}
if ((keysB[4][2] == 0) and (lastB[4][2] == 0) and ((millis() - BounceBOn[4][2]) > Delay)) {
MidiSend(noteOn2, 57, velocity);
lastB[4][2] = 7;
}
if (lastB[4][2] == 0) {
BounceBOff[4][2] = millis();
}
if ((keysB[4][2] == 1) and (lastB[4][2] == 7) and ((millis() - BounceBOff[4][2]) > Delay)) {
MidiSend(noteOff2, 57, velocity);
lastB[4][2] = 0;
}
//B58
if (lastB[4][3] == 7) {
BounceBOn[4][3] = millis();
}
if ((keysB[4][3] == 0) and (lastB[4][3] == 0) and ((millis() - BounceBOn[4][3]) > Delay)) {
MidiSend(noteOn2, 58, velocity);
lastB[4][3] = 7;
}
if (lastB[4][3] == 0) {
BounceBOff[4][3] = millis();
}
if ((keysB[4][3] == 1) and (lastB[4][3] == 7) and ((millis() - BounceBOff[4][3]) > Delay)) {
MidiSend(noteOff2, 58, velocity);
lastB[4][3] = 0;
}
//B59
if (lastB[4][4] == 7) {
BounceBOn[4][4] = millis();
}
if ((keysB[4][4] == 0) and (lastB[4][4] == 0) and ((millis() - BounceBOn[4][4]) > Delay)) {
MidiSend(noteOn2, 59, velocity);
lastB[4][4] = 7;
}
if (lastB[4][4] == 0) {
BounceBOff[4][4] = millis();
}
if ((keysB[4][4] == 1) and (lastB[4][4] == 7) and ((millis() - BounceBOff[4][4]) > Delay)) {
MidiSend(noteOff2, 59, velocity);
lastB[4][4] = 0;
}
//B60
if (lastB[4][5] == 7) {
BounceBOn[4][5] = millis();
}
if ((keysB[4][5] == 0) and (lastB[4][5] == 0) and ((millis() - BounceBOn[4][5]) > Delay)) {
MidiSend(noteOn2, 60, velocity);
lastB[4][5] = 7;
}
if (lastB[4][5] == 0) {
BounceBOff[4][5] = millis();
}
if ((keysB[4][5] == 1) and (lastB[4][5] == 7) and ((millis() - BounceBOff[4][5]) > Delay)) {
MidiSend(noteOff2, 60, velocity);
lastB[4][5] = 0;
}
//B61
if (lastB[5][0] == 7) {
BounceBOn[5][0] = millis();
}
if ((keysB[5][0] == 0) and (lastB[5][0] == 0) and ((millis() - BounceBOn[5][0]) > Delay)) {
MidiSend(noteOn2, 61, velocity);
lastB[5][0] = 7;
}
if (lastB[5][0] == 0) {
BounceBOff[5][0] = millis();
}
if ((keysB[5][0] == 1) and (lastB[5][0] == 7) and ((millis() - BounceBOff[5][0]) > Delay)) {
MidiSend(noteOff2, 61, velocity);
lastB[5][0] = 0;
}
//B62
if (lastB[5][1] == 7) {
BounceBOn[5][1] = millis();
}
if ((keysB[5][1] == 0) and (lastB[5][1] == 0) and ((millis() - BounceBOn[5][1]) > Delay)) {
MidiSend(noteOn2, 62, velocity);
lastB[5][1] = 7;
}
if (lastB[5][1] == 0) {
BounceBOff[5][1] = millis();
}
if ((keysB[5][1] == 1) and (lastB[5][1] == 7) and ((millis() - BounceBOff[5][1]) > Delay)) {
MidiSend(noteOff2, 62, velocity);
lastB[5][1] = 0;
}
//B63
if (lastB[5][2] == 7) {
BounceBOn[5][2] = millis();
}
if ((keysB[5][2] == 0) and (lastB[5][2] == 0) and ((millis() - BounceBOn[5][2]) > Delay)) {
MidiSend(noteOn2, 63, velocity);
lastB[5][2] = 7;
}
if (lastB[5][2] == 0) {
BounceBOff[5][2] = millis();
}
if ((keysB[5][2] == 1) and (lastB[5][2] == 7) and ((millis() - BounceBOff[5][2]) > Delay)) {
MidiSend(noteOff2, 63, velocity);
lastB[5][2] = 0;
}
//B64
if (lastB[5][3] == 7) {
BounceBOn[5][3] = millis();
}
if ((keysB[5][3] == 0) and (lastB[5][3] == 0) and ((millis() - BounceBOn[5][3]) > Delay)) {
MidiSend(noteOn2, 64, velocity);
lastB[5][3] = 7;
}
if (lastB[5][3] == 0) {
BounceBOff[5][3] = millis();
}
if ((keysB[5][3] == 1) and (lastB[5][3] == 7) and ((millis() - BounceBOff[5][3]) > Delay)) {
MidiSend(noteOff2, 64, velocity);
lastB[5][3] = 0;
}
//B65
if (lastB[5][4] == 7) {
BounceBOn[5][4] = millis();
}
if ((keysB[5][4] == 0) and (lastB[5][4] == 0) and ((millis() - BounceBOn[5][4]) > Delay)) {
MidiSend(noteOn2, 65, velocity);
lastB[5][4] = 7;
}
if (lastB[5][4] == 0) {
BounceBOff[5][4] = millis();
}
if ((keysB[5][4] == 1) and (lastB[5][4] == 7) and ((millis() - BounceBOff[5][4]) > Delay)) {
MidiSend(noteOff2, 65, velocity);
lastB[5][4] = 0;
}
//B66
if (lastB[5][5] == 7) {
BounceBOn[5][5] = millis();
}
if ((keysB[5][5] == 0) and (lastB[5][5] == 0) and ((millis() - BounceBOn[5][5]) > Delay)) {
MidiSend(noteOn2, 66, velocity);
lastB[5][5] = 7;
}
if (lastB[5][5] == 0) {
BounceBOff[5][5] = millis();
}
if ((keysB[5][5] == 1) and (lastB[5][5] == 7) and ((millis() - BounceBOff[5][5]) > Delay)) {
MidiSend(noteOff2, 66, velocity);
lastB[5][5] = 0;
}
//B67
if (lastB[6][0] == 7) {
BounceBOn[6][0] = millis();
}
if ((keysB[6][0] == 0) and (lastB[6][0] == 0) and ((millis() - BounceBOn[6][0]) > Delay)) {
MidiSend(noteOn2, 67, velocity);
lastB[6][0] = 7;
}
if (lastB[6][0] == 0) {
BounceBOff[6][0] = millis();
}
if ((keysB[6][0] == 1) and (lastB[6][0] == 7) and ((millis() - BounceBOff[6][0]) > Delay)) {
MidiSend(noteOff2, 67, velocity);
lastB[6][0] = 0;
}
//B68
if (lastB[6][1] == 7) {
BounceBOn[6][1] = millis();
}
if ((keysB[6][1] == 0) and (lastB[6][1] == 0) and ((millis() - BounceBOn[6][1]) > Delay)) {
MidiSend(noteOn2, 68, velocity);
lastB[6][1] = 7;
}
if (lastB[6][1] == 0) {
BounceBOff[6][1] = millis();
}
if ((keysB[6][1] == 1) and (lastB[6][1] == 7) and ((millis() - BounceBOff[6][1]) > Delay)) {
MidiSend(noteOff2, 68, velocity);
lastB[6][1] = 0;
}
//B69
if (lastB[6][2] == 7) {
BounceBOn[6][2] = millis();
}
if ((keysB[6][2] == 0) and (lastB[6][2] == 0) and ((millis() - BounceBOn[6][2]) > Delay)) {
MidiSend(noteOn2, 69, velocity);
lastB[6][2] = 7;
}
if (lastB[6][2] == 0) {
BounceBOff[6][2] = millis();
}
if ((keysB[6][2] == 1) and (lastB[6][2] == 7) and ((millis() - BounceBOff[6][2]) > Delay)) {
MidiSend(noteOff2, 69, velocity);
lastB[6][2] = 0;
}
//B70
if (lastB[6][3] == 7) {
BounceBOn[6][3] = millis();
}
if ((keysB[6][3] == 0) and (lastB[6][3] == 0) and ((millis() - BounceBOn[6][3]) > Delay)) {
MidiSend(noteOn2, 70, velocity);
lastB[6][3] = 7;
}
if (lastB[6][3] == 0) {
BounceBOff[6][3] = millis();
}
if ((keysB[6][3] == 1) and (lastB[6][3] == 7) and ((millis() - BounceBOff[6][3]) > Delay)) {
MidiSend(noteOff2, 70, velocity);
lastB[6][3] = 0;
}
//B71
if (lastB[6][4] == 7) {
BounceBOn[6][4] = millis();
}
if ((keysB[6][4] == 0) and (lastB[6][4] == 0) and ((millis() - BounceBOn[6][4]) > Delay)) {
MidiSend(noteOn2, 71, velocity);
lastB[6][4] = 7;
}
if (lastB[6][4] == 0) {
BounceBOff[6][4] = millis();
}
if ((keysB[6][4] == 1) and (lastB[6][4] == 7) and ((millis() - BounceBOff[6][4]) > Delay)) {
MidiSend(noteOff2, 71, velocity);
lastB[6][4] = 0;
}
//B72
if (lastB[6][5] == 7) {
BounceBOn[6][5] = millis();
}
if ((keysB[6][5] == 0) and (lastB[6][5] == 0) and ((millis() - BounceBOn[6][5]) > Delay)) {
MidiSend(noteOn2, 72, velocity);
lastB[6][5] = 7;
}
if (lastB[6][5] == 0) {
BounceBOff[6][5] = millis();
}
if ((keysB[6][5] == 1) and (lastB[6][5] == 7) and ((millis() - BounceBOff[6][5]) > Delay)) {
MidiSend(noteOff2, 72, velocity);
lastB[6][5] = 0;
}
//B73
if (lastB[7][0] == 7) {
BounceBOn[7][0] = millis();
}
if ((keysB[7][0] == 0) and (lastB[7][0] == 0) and ((millis() - BounceBOn[7][0]) > Delay)) {
MidiSend(noteOn2, 73, velocity);
lastB[7][0] = 7;
}
if (lastB[7][0] == 0) {
BounceBOff[7][0] = millis();
}
if ((keysB[7][0] == 1) and (lastB[7][0] == 7) and ((millis() - BounceBOff[7][0]) > Delay)) {
MidiSend(noteOff2, 73, velocity);
lastB[7][0] = 0;
}
//B74
if (lastB[7][1] == 7) {
BounceBOn[7][1] = millis();
}
if ((keysB[7][1] == 0) and (lastB[7][1] == 0) and ((millis() - BounceBOn[7][1]) > Delay)) {
MidiSend(noteOn2, 74, velocity);
lastB[7][1] = 7;
}
if (lastB[7][1] == 0) {
BounceBOff[7][1] = millis();
}
if ((keysB[7][1] == 1) and (lastB[7][1] == 7) and ((millis() - BounceBOff[7][1]) > Delay)) {
MidiSend(noteOff2, 74, velocity);
lastB[7][1] = 0;
}
//B75
if (lastB[7][2] == 7) {
BounceBOn[7][2] = millis();
}
if ((keysB[7][2] == 0) and (lastB[7][2] == 0) and ((millis() - BounceBOn[7][2]) > Delay)) {
MidiSend(noteOn2, 75, velocity);
lastB[7][2] = 7;
}
if (lastB[7][2] == 0) {
BounceBOff[7][2] = millis();
}
if ((keysB[7][2] == 1) and (lastB[7][2] == 7) and ((millis() - BounceBOff[7][2]) > Delay)) {
MidiSend(noteOff2, 75, velocity);
lastB[7][2] = 0;
}
//B76
if (lastB[7][3] == 7) {
BounceBOn[7][3] = millis();
}
if ((keysB[7][3] == 0) and (lastB[7][3] == 0) and ((millis() - BounceBOn[7][3]) > Delay)) {
MidiSend(noteOn2, 76, velocity);
lastB[7][3] = 7;
}
if (lastB[7][3] == 0) {
BounceBOff[7][3] = millis();
}
if ((keysB[7][3] == 1) and (lastB[7][3] == 7) and ((millis() - BounceBOff[7][3]) > Delay)) {
MidiSend(noteOff2, 76, velocity);
lastB[7][3] = 0;
}
//B77
if (lastB[7][4] == 7) {
BounceBOn[7][4] = millis();
}
if ((keysB[7][4] == 0) and (lastB[7][4] == 0) and ((millis() - BounceBOn[7][4]) > Delay)) {
MidiSend(noteOn2, 77, velocity);
lastB[7][4] = 7;
}
if (lastB[7][4] == 0) {
BounceBOff[7][4] = millis();
}
if ((keysB[7][4] == 1) and (lastB[7][4] == 7) and ((millis() - BounceBOff[7][4]) > Delay)) {
MidiSend(noteOff2, 77, velocity);
lastB[7][4] = 0;
}
//B78
if (lastB[7][5] == 7) {
BounceBOn[7][5] = millis();
}
if ((keysB[7][5] == 0) and (lastB[7][5] == 0) and ((millis() - BounceBOn[7][5]) > Delay)) {
MidiSend(noteOn2, 78, velocity);
lastB[7][5] = 7;
}
if (lastB[7][5] == 0) {
BounceBOff[7][5] = millis();
}
if ((keysB[7][5] == 1) and (lastB[7][5] == 7) and ((millis() - BounceBOff[7][5]) > Delay)) {
MidiSend(noteOff2, 78, velocity);
lastB[7][5] = 0;
}
//B79
if (lastB[8][0] == 7) {
BounceBOn[8][0] = millis();
}
if ((keysB[8][0] == 0) and (lastB[8][0] == 0) and ((millis() - BounceBOn[8][0]) > Delay)) {
MidiSend(noteOn2, 79, velocity);
lastB[8][0] = 7;
}
if (lastB[8][0] == 0) {
BounceBOff[8][0] = millis();
}
if ((keysB[8][0] == 1) and (lastB[8][0] == 7) and ((millis() - BounceBOff[8][0]) > Delay)) {
MidiSend(noteOff2, 79, velocity);
lastB[8][0] = 0;
}
//B80
if (lastB[8][1] == 7) {
BounceBOn[8][1] = millis();
}
if ((keysB[8][1] == 0) and (lastB[8][1] == 0) and ((millis() - BounceBOn[8][1]) > Delay)) {
MidiSend(noteOn2, 80, velocity);
lastB[8][1] = 7;
}
if (lastB[8][1] == 0) {
BounceBOff[8][1] = millis();
}
if ((keysB[8][1] == 1) and (lastB[8][1] == 7) and ((millis() - BounceBOff[8][1]) > Delay)) {
MidiSend(noteOff2, 80, velocity);
lastB[8][1] = 0;
}
//B81
if (lastB[8][2] == 7) {
BounceBOn[8][2] = millis();
}
if ((keysB[8][2] == 0) and (lastB[8][2] == 0) and ((millis() - BounceBOn[8][2]) > Delay)) {
MidiSend(noteOn2, 81, velocity);
lastB[8][2] = 7;
}
if (lastB[8][2] == 0) {
BounceBOff[8][2] = millis();
}
if ((keysB[8][2] == 1) and (lastB[8][2] == 7) and ((millis() - BounceBOff[8][2]) > Delay)) {
MidiSend(noteOff2, 81, velocity);
lastB[8][2] = 0;
}
//B82
if (lastB[8][3] == 7) {
BounceBOn[8][3] = millis();
}
if ((keysB[8][3] == 0) and (lastB[8][3] == 0) and ((millis() - BounceBOn[8][3]) > Delay)) {
MidiSend(noteOn2, 82, velocity);
lastB[8][3] = 7;
}
if (lastB[8][3] == 0) {
BounceBOff[8][3] = millis();
}
if ((keysB[8][3] == 1) and (lastB[8][3] == 7) and ((millis() - BounceBOff[8][3]) > Delay)) {
MidiSend(noteOff2, 82, velocity);
lastB[8][3] = 0;
}
//B83
if (lastB[8][4] == 7) {
BounceBOn[8][4] = millis();
}
if ((keysB[8][4] == 0) and (lastB[8][4] == 0) and ((millis() - BounceBOn[8][4]) > Delay)) {
MidiSend(noteOn2, 83, velocity);
lastB[8][4] = 7;
}
if (lastB[8][4] == 0) {
BounceBOff[8][4] = millis();
}
if ((keysB[8][4] == 1) and (lastB[8][4] == 7) and ((millis() - BounceBOff[8][4]) > Delay)) {
MidiSend(noteOff2, 83, velocity);
lastB[8][4] = 0;
}
//B84
if (lastB[8][5] == 7) {
BounceBOn[8][5] = millis();
}
if ((keysB[8][5] == 0) and (lastB[8][5] == 0) and ((millis() - BounceBOn[8][5]) > Delay)) {
MidiSend(noteOn2, 84, velocity);
lastB[8][5] = 7;
}
if (lastB[8][5] == 0) {
BounceBOff[8][5] = millis();
}
if ((keysB[8][5] == 1) and (lastB[8][5] == 7) and ((millis() - BounceBOff[8][5]) > Delay)) {
MidiSend(noteOff2, 84, velocity);
lastB[8][5] = 0;
}
//B85
if (lastB[9][0] == 7) {
BounceBOn[9][0] = millis();
}
if ((keysB[9][0] == 0) and (lastB[9][0] == 0) and ((millis() - BounceBOn[9][0]) > Delay)) {
MidiSend(noteOn2, 85, velocity);
lastB[9][0] = 7;
}
if (lastB[9][0] == 0) {
BounceBOff[9][0] = millis();
}
if ((keysB[9][0] == 1) and (lastB[9][0] == 7) and ((millis() - BounceBOff[9][0]) > Delay)) {
MidiSend(noteOff2, 85, velocity);
lastB[9][0] = 0;
}
//B86
if (lastB[9][1] == 7) {
BounceBOn[9][1] = millis();
}
if ((keysB[9][1] == 0) and (lastB[9][1] == 0) and ((millis() - BounceBOn[9][1]) > Delay)) {
MidiSend(noteOn2, 86, velocity);
lastB[9][1] = 7;
}
if (lastB[9][1] == 0) {
BounceBOff[9][1] = millis();
}
if ((keysB[9][1] == 1) and (lastB[9][1] == 7) and ((millis() - BounceBOff[9][1]) > Delay)) {
MidiSend(noteOff2, 86, velocity);
lastB[9][1] = 0;
}
//B87
if (lastB[9][2] == 7) {
BounceBOn[9][2] = millis();
}
if ((keysB[9][2] == 0) and (lastB[9][2] == 0) and ((millis() - BounceBOn[9][2]) > Delay)) {
MidiSend(noteOn2, 87, velocity);
lastB[9][2] = 7;
}
if (lastB[9][2] == 0) {
BounceBOff[9][2] = millis();
}
if ((keysB[9][2] == 1) and (lastB[9][2] == 7) and ((millis() - BounceBOff[9][2]) > Delay)) {
MidiSend(noteOff2, 87, velocity);
lastB[9][2] = 0;
}
//B88
if (lastB[9][3] == 7) {
BounceBOn[9][3] = millis();
}
if ((keysB[9][3] == 0) and (lastB[9][3] == 0) and ((millis() - BounceBOn[9][3]) > Delay)) {
MidiSend(noteOn2, 88, velocity);
lastB[9][3] = 7;
}
if (lastB[9][3] == 0) {
BounceBOff[9][3] = millis();
}
if ((keysB[9][3] == 1) and (lastB[9][3] == 7) and ((millis() - BounceBOff[9][3]) > Delay)) {
MidiSend(noteOff2, 88, velocity);
lastB[9][3] = 0;
}
//B89
if (lastB[9][4] == 7) {
BounceBOn[9][4] = millis();
}
if ((keysB[9][4] == 0) and (lastB[9][4] == 0) and ((millis() - BounceBOn[9][4]) > Delay)) {
MidiSend(noteOn2, 89, velocity);
lastB[9][4] = 7;
}
if (lastB[9][4] == 0) {
BounceBOff[9][4] = millis();
}
if ((keysB[9][4] == 1) and (lastB[9][4] == 7) and ((millis() - BounceBOff[9][4]) > Delay)) {
MidiSend(noteOff2, 89, velocity);
lastB[9][4] = 0;
}
//B90
if (lastB[9][5] == 7) {
BounceBOn[9][5] = millis();
}
if ((keysB[9][5] == 0) and (lastB[9][5] == 0) and ((millis() - BounceBOn[9][5]) > Delay)) {
MidiSend(noteOn2, 90, velocity);
lastB[9][5] = 7;
}
if (lastB[9][5] == 0) {
BounceBOff[9][5] = millis();
}
if ((keysB[9][5] == 1) and (lastB[9][5] == 7) and ((millis() - BounceBOff[9][5]) > Delay)) {
MidiSend(noteOff2, 90, velocity);
lastB[9][5] = 0;
}
//B91
if (lastB[10][0] == 7) {
BounceBOn[10][0] = millis();
}
if ((keysB[10][0] == 0) and (lastB[10][0] == 0) and ((millis() - BounceBOn[10][0]) > Delay)) {
MidiSend(noteOn2, 91, velocity);
lastB[10][0] = 7;
}
if (lastB[10][0] == 0) {
BounceBOff[10][0] = millis();
}
if ((keysB[10][0] == 1) and (lastB[10][0] == 7) and ((millis() - BounceBOff[10][0]) > Delay)) {
MidiSend(noteOff2, 91, velocity);
lastB[10][0] = 0;
}
//B92
if (lastB[10][1] == 7) {
BounceBOn[10][1] = millis();
}
if ((keysB[10][1] == 0) and (lastB[10][1] == 0) and ((millis() - BounceBOn[10][1]) > Delay)) {
MidiSend(noteOn2, 92, velocity);
lastB[10][1] = 7;
}
if (lastB[10][1] == 0) {
BounceBOff[10][1] = millis();
}
if ((keysB[10][1] == 1) and (lastB[10][1] == 7) and ((millis() - BounceBOff[10][1]) > Delay)) {
MidiSend(noteOff2, 92, velocity);
lastB[10][1] = 0;
}
//B93
if (lastB[10][2] == 7) {
BounceBOn[10][2] = millis();
}
if ((keysB[10][2] == 0) and (lastB[10][2] == 0) and ((millis() - BounceBOn[10][2]) > Delay)) {
MidiSend(noteOn2, 93, velocity);
lastB[10][2] = 7;
}
if (lastB[10][2] == 0) {
BounceBOff[10][2] = millis();
}
if ((keysB[10][2] == 1) and (lastB[10][2] == 7) and ((millis() - BounceBOff[10][2]) > Delay)) {
MidiSend(noteOff2, 93, velocity);
lastB[10][2] = 0;
}
//B94
if (lastB[10][3] == 7) {
BounceBOn[10][3] = millis();
}
if ((keysB[10][3] == 0) and (lastB[10][3] == 0) and ((millis() - BounceBOn[10][3]) > Delay)) {
MidiSend(noteOn2, 94, velocity);
lastB[10][3] = 7;
}
if (lastB[10][3] == 0) {
BounceBOff[10][3] = millis();
}
if ((keysB[10][3] == 1) and (lastB[10][3] == 7) and ((millis() - BounceBOff[10][3]) > Delay)) {
MidiSend(noteOff2, 94, velocity);
lastB[10][3] = 0;
}
//B95
if (lastB[10][4] == 7) {
BounceBOn[10][4] = millis();
}
if ((keysB[10][4] == 0) and (lastB[10][4] == 0) and ((millis() - BounceBOn[10][4]) > Delay)) {
MidiSend(noteOn2, 95, velocity);
lastB[10][4] = 7;
}
if (lastB[10][4] == 0) {
BounceBOff[10][4] = millis();
}
if ((keysB[10][4] == 1) and (lastB[10][4] == 7) and ((millis() - BounceBOff[10][4]) > Delay)) {
MidiSend(noteOff2, 95, velocity);
lastB[10][4] = 0;
}
//B96
if (lastB[10][5] == 7) {
BounceBOn[10][5] = millis();
}
if ((keysB[10][5] == 0) and (lastB[10][5] == 0) and ((millis() - BounceBOn[10][5]) > Delay)) {
MidiSend(noteOn2, 96, velocity);
lastB[10][5] = 7;
}
if (lastB[10][5] == 0) {
BounceBOff[10][5] = millis();
}
if ((keysB[10][5] == 1) and (lastB[10][5] == 7) and ((millis() - BounceBOff[10][5]) > Delay)) {
MidiSend(noteOff2, 96, velocity);
lastB[10][5] = 0;
}
//Write Keyboard C, only for inverted switches, first 32 notes only.
//C36
if (lastC[0][0] == 7) {
BounceCOn[0][0] = millis();
}
if ((keysC[0][0] == 0) and (lastC[0][0] == 0) and ((millis() - BounceCOn[0][0]) > Delay)) {
MidiSend(noteOff3, 36, velocity);
lastC[0][0] = 7;
}
if (lastC[0][0] == 0) {
BounceCOff[0][0] = millis();
}
if ((keysC[0][0] == 1) and (lastC[0][0] == 7) and ((millis() - BounceCOff[0][0]) > Delay)) {
MidiSend(noteOn3, 36, velocity);
lastC[0][0] = 0;
}
//C37
if (lastC[1][0] == 7) {
BounceCOn[1][0] = millis();
}
if ((keysC[1][0] == 0) and (lastC[1][0] == 0) and ((millis() - BounceCOn[1][0]) > Delay)) {
MidiSend(noteOff3, 37, velocity);
lastC[1][0] = 7;
}
if (lastC[1][0] == 0) {
BounceCOff[1][0] = millis();
}
if ((keysC[1][0] == 1) and (lastC[1][0] == 7) and ((millis() - BounceCOff[1][0]) > Delay)) {
MidiSend(noteOn3, 37, velocity);
lastC[1][0] = 0;
}
//C38
if (lastC[1][1] == 7) {
BounceCOn[1][1] = millis();
}
if ((keysC[1][1] == 0) and (lastC[1][1] == 0) and ((millis() - BounceCOn[1][1]) > Delay)) {
MidiSend(noteOff3, 38, velocity);
lastC[1][1] = 7;
}
if (lastC[1][1] == 0) {
BounceCOff[1][1] = millis();
}
if ((keysC[1][1] == 1) and (lastC[1][1] == 7) and ((millis() - BounceCOff[1][1]) > Delay)) {
MidiSend(noteOn3, 38, velocity);
lastC[1][1] = 0;
}
//C39
if (lastC[1][2] == 7) {
BounceCOn[1][2] = millis();
}
if ((keysC[1][2] == 0) and (lastC[1][2] == 0) and ((millis() - BounceCOn[1][2]) > Delay)) {
MidiSend(noteOff3, 39, velocity);
lastC[1][2] = 7;
}
if (lastC[1][2] == 0) {
BounceCOff[1][2] = millis();
}
if ((keysC[1][2] == 1) and (lastC[1][2] == 7) and ((millis() - BounceCOff[1][2]) > Delay)) {
MidiSend(noteOn3, 39, velocity);
lastC[1][2] = 0;
}
//C40
if (lastC[1][3] == 7) {
BounceCOn[1][3] = millis();
}
if ((keysC[1][3] == 0) and (lastC[1][3] == 0) and ((millis() - BounceCOn[1][3]) > Delay)) {
MidiSend(noteOff3, 40, velocity);
lastC[1][3] = 7;
}
if (lastC[1][3] == 0) {
BounceCOff[1][3] = millis();
}
if ((keysC[1][3] == 1) and (lastC[1][3] == 7) and ((millis() - BounceCOff[1][3]) > Delay)) {
MidiSend(noteOn3, 40, velocity);
lastC[1][3] = 0;
}
//C41
if (lastC[1][4] == 7) {
BounceCOn[1][4] = millis();
}
if ((keysC[1][4] == 0) and (lastC[1][4] == 0) and ((millis() - BounceCOn[1][4]) > Delay)) {
MidiSend(noteOff3, 41, velocity);
lastC[1][4] = 7;
}
if (lastC[1][4] == 0) {
BounceCOff[1][4] = millis();
}
if ((keysC[1][4] == 1) and (lastC[1][4] == 7) and ((millis() - BounceCOff[1][4]) > Delay)) {
MidiSend(noteOn3, 41, velocity);
lastC[1][4] = 0;
}
//C42
if (lastC[1][5] == 7) {
BounceCOn[1][5] = millis();
}
if ((keysC[1][5] == 0) and (lastC[1][5] == 0) and ((millis() - BounceCOn[1][5]) > Delay)) {
MidiSend(noteOff3, 42, velocity);
lastC[1][5] = 7;
}
if (lastC[1][5] == 0) {
BounceCOff[1][5] = millis();
}
if ((keysC[1][5] == 1) and (lastC[1][5] == 7) and ((millis() - BounceCOff[1][5]) > Delay)) {
MidiSend(noteOn3, 42, velocity);
lastC[1][5] = 0;
}
//C43
if (lastC[2][0] == 7) {
BounceCOn[2][0] = millis();
}
if ((keysC[2][0] == 0) and (lastC[2][0] == 0) and ((millis() - BounceCOn[2][0]) > Delay)) {
MidiSend(noteOff3, 43, velocity);
lastC[2][0] = 7;
}
if (lastC[2][0] == 0) {
BounceCOff[2][0] = millis();
}
if ((keysC[2][0] == 1) and (lastC[2][0] == 7) and ((millis() - BounceCOff[2][0]) > Delay)) {
MidiSend(noteOn3, 43, velocity);
lastC[2][0] = 0;
}
//C44
if (lastC[2][1] == 7) {
BounceCOn[2][1] = millis();
}
if ((keysC[2][1] == 0) and (lastC[2][1] == 0) and ((millis() - BounceCOn[2][1]) > Delay)) {
MidiSend(noteOff3, 44, velocity);
lastC[2][1] = 7;
}
if (lastC[2][1] == 0) {
BounceCOff[2][1] = millis();
}
if ((keysC[2][1] == 1) and (lastC[2][1] == 7) and ((millis() - BounceCOff[2][1]) > Delay)) {
MidiSend(noteOn3, 44, velocity);
lastC[2][1] = 0;
}
//C45
if (lastC[2][2] == 7) {
BounceCOn[2][2] = millis();
}
if ((keysC[2][2] == 0) and (lastC[2][2] == 0) and ((millis() - BounceCOn[2][2]) > Delay)) {
MidiSend(noteOff3, 45, velocity);
lastC[2][2] = 7;
}
if (lastC[2][2] == 0) {
BounceCOff[2][2] = millis();
}
if ((keysC[2][2] == 1) and (lastC[2][2] == 7) and ((millis() - BounceCOff[2][2]) > Delay)) {
MidiSend(noteOn3, 45, velocity);
lastC[2][2] = 0;
}
//C46
if (lastC[2][3] == 7) {
BounceCOn[2][3] = millis();
}
if ((keysC[2][3] == 0) and (lastC[2][3] == 0) and ((millis() - BounceCOn[2][3]) > Delay)) {
MidiSend(noteOff3, 46, velocity);
lastC[2][3] = 7;
}
if (lastC[2][3] == 0) {
BounceCOff[2][3] = millis();
}
if ((keysC[2][3] == 1) and (lastC[2][3] == 7) and ((millis() - BounceCOff[2][3]) > Delay)) {
MidiSend(noteOn3, 46, velocity);
lastC[2][3] = 0;
}
//C47
if (lastC[2][4] == 7) {
BounceCOn[2][4] = millis();
}
if ((keysC[2][4] == 0) and (lastC[2][4] == 0) and ((millis() - BounceCOn[2][4]) > Delay)) {
MidiSend(noteOff3, 47, velocity);
lastC[2][4] = 7;
}
if (lastC[2][4] == 0) {
BounceCOff[2][4] = millis();
}
if ((keysC[2][4] == 1) and (lastC[2][4] == 7) and ((millis() - BounceCOff[2][4]) > Delay)) {
MidiSend(noteOn3, 47, velocity);
lastC[2][4] = 0;
}
//B48
if (lastC[2][5] == 7) {
BounceCOn[2][5] = millis();
}
if ((keysC[2][5] == 0) and (lastC[2][5] == 0) and ((millis() - BounceCOn[2][5]) > Delay)) {
MidiSend(noteOff3, 48, velocity);
lastC[2][5] = 7;
}
if (lastC[2][5] == 0) {
BounceCOff[2][5] = millis();
}
if ((keysC[2][5] == 1) and (lastC[2][5] == 7) and ((millis() - BounceCOff[2][5]) > Delay)) {
MidiSend(noteOn3, 48, velocity);
lastC[2][5] = 0;
}
//C49
if (lastC[3][0] == 7) {
BounceCOn[3][0] = millis();
}
if ((keysC[3][0] == 0) and (lastC[3][0] == 0) and ((millis() - BounceCOn[3][0]) > Delay)) {
MidiSend(noteOff3, 49, velocity);
lastC[3][0] = 7;
}
if (lastC[3][0] == 0) {
BounceCOff[3][0] = millis();
}
if ((keysC[3][0] == 1) and (lastC[3][0] == 7) and ((millis() - BounceCOff[3][0]) > Delay)) {
MidiSend(noteOn3, 49, velocity);
lastC[3][0] = 0;
}
//C50
if (lastC[3][1] == 7) {
BounceCOn[3][1] = millis();
}
if ((keysC[3][1] == 0) and (lastC[3][1] == 0) and ((millis() - BounceCOn[3][1]) > Delay)) {
MidiSend(noteOff3, 50, velocity);
lastC[3][1] = 7;
}
if (lastC[3][1] == 0) {
BounceCOff[3][1] = millis();
}
if ((keysC[3][1] == 1) and (lastC[3][1] == 7) and ((millis() - BounceCOff[3][1]) > Delay)) {
MidiSend(noteOn3, 50, velocity);
lastC[3][1] = 0;
}
//C51
if (lastC[3][2] == 7) {
BounceCOn[3][2] = millis();
}
if ((keysC[3][2] == 0) and (lastC[3][2] == 0) and ((millis() - BounceCOn[3][2]) > Delay)) {
MidiSend(noteOff3, 51, velocity);
lastC[3][2] = 7;
}
if (lastC[3][2] == 0) {
BounceCOff[3][2] = millis();
}
if ((keysC[3][2] == 1) and (lastC[3][2] == 7) and ((millis() - BounceCOff[3][2]) > Delay)) {
MidiSend(noteOn3, 51, velocity);
lastC[3][2] = 0;
}
//C52
if (lastC[3][3] == 7) {
BounceCOn[3][3] = millis();
}
if ((keysC[3][3] == 0) and (lastC[3][3] == 0) and ((millis() - BounceCOn[3][3]) > Delay)) {
MidiSend(noteOff3, 52, velocity);
lastC[3][3] = 7;
}
if (lastC[3][3] == 0) {
BounceCOff[3][3] = millis();
}
if ((keysC[3][3] == 1) and (lastC[3][3] == 7) and ((millis() - BounceCOff[3][3]) > Delay)) {
MidiSend(noteOn3, 52, velocity);
lastC[3][3] = 0;
}
//C53
if (lastC[3][4] == 7) {
BounceCOn[3][4] = millis();
}
if ((keysC[3][4] == 0) and (lastC[3][4] == 0) and ((millis() - BounceCOn[3][4]) > Delay)) {
MidiSend(noteOff3, 53, velocity);
lastC[3][4] = 7;
}
if (lastC[3][4] == 0) {
BounceCOff[3][4] = millis();
}
if ((keysC[3][4] == 1) and (lastC[3][4] == 7) and ((millis() - BounceCOff[3][4]) > Delay)) {
MidiSend(noteOn3, 53, velocity);
lastC[3][4] = 0;
}
//C54
if (lastC[3][5] == 7) {
BounceCOn[3][5] = millis();
}
if ((keysC[3][5] == 0) and (lastC[3][5] == 0) and ((millis() - BounceCOn[3][5]) > Delay)) {
MidiSend(noteOff3, 54, velocity);
lastC[3][5] = 7;
}
if (lastC[3][5] == 0) {
BounceCOff[3][5] = millis();
}
if ((keysC[3][5] == 1) and (lastC[3][5] == 7) and ((millis() - BounceCOff[3][5]) > Delay)) {
MidiSend(noteOn3, 54, velocity);
lastC[3][5] = 0;
}
//C55
if (lastC[4][0] == 7) {
BounceCOn[4][0] = millis();
}
if ((keysC[4][0] == 0) and (lastC[4][0] == 0) and ((millis() - BounceCOn[4][0]) > Delay)) {
MidiSend(noteOff3, 55, velocity);
lastC[4][0] = 7;
}
if (lastC[4][0] == 0) {
BounceCOff[4][0] = millis();
}
if ((keysC[4][0] == 1) and (lastC[4][0] == 7) and ((millis() - BounceCOff[4][0]) > Delay)) {
MidiSend(noteOn3, 55, velocity);
lastC[4][0] = 0;
}
//C56
if (lastC[4][1] == 7) {
BounceCOn[4][1] = millis();
}
if ((keysC[4][1] == 0) and (lastC[4][1] == 0) and ((millis() - BounceCOn[4][1]) > Delay)) {
MidiSend(noteOff3, 56, velocity);
lastC[4][1] = 7;
}
if (lastC[4][1] == 0) {
BounceCOff[4][1] = millis();
}
if ((keysC[4][1] == 1) and (lastC[4][1] == 7) and ((millis() - BounceCOff[4][1]) > Delay)) {
MidiSend(noteOn3, 56, velocity);
lastC[4][1] = 0;
}
//C57
if (lastC[4][2] == 7) {
BounceCOn[4][2] = millis();
}
if ((keysC[4][2] == 0) and (lastC[4][2] == 0) and ((millis() - BounceCOn[4][2]) > Delay)) {
MidiSend(noteOff3, 57, velocity);
lastC[4][2] = 7;
}
if (lastC[4][2] == 0) {
BounceCOff[4][2] = millis();
}
if ((keysC[4][2] == 1) and (lastC[4][2] == 7) and ((millis() - BounceCOff[4][2]) > Delay)) {
MidiSend(noteOn3, 57, velocity);
lastC[4][2] = 0;
}
//C58
if (lastC[4][3] == 7) {
BounceCOn[4][3] = millis();
}
if ((keysC[4][3] == 0) and (lastC[4][3] == 0) and ((millis() - BounceCOn[4][3]) > Delay)) {
MidiSend(noteOff3, 58, velocity);
lastC[4][3] = 7;
}
if (lastC[4][3] == 0) {
BounceCOff[4][3] = millis();
}
if ((keysC[4][3] == 1) and (lastC[4][3] == 7) and ((millis() - BounceCOff[4][3]) > Delay)) {
MidiSend(noteOn3, 58, velocity);
lastC[4][3] = 0;
}
//C59
if (lastC[4][4] == 7) {
BounceCOn[4][4] = millis();
}
if ((keysC[4][4] == 0) and (lastC[4][4] == 0) and ((millis() - BounceCOn[4][4]) > Delay)) {
MidiSend(noteOff3, 59, velocity);
lastC[4][4] = 7;
}
if (lastC[4][4] == 0) {
BounceCOff[4][4] = millis();
}
if ((keysC[4][4] == 1) and (lastC[4][4] == 7) and ((millis() - BounceCOff[4][4]) > Delay)) {
MidiSend(noteOn3, 59, velocity);
lastC[4][4] = 0;
}
//C60
if (lastC[4][5] == 7) {
BounceCOn[4][5] = millis();
}
if ((keysC[4][5] == 0) and (lastC[4][5] == 0) and ((millis() - BounceCOn[4][5]) > Delay)) {
MidiSend(noteOff3, 60, velocity);
lastC[4][5] = 7;
}
if (lastC[4][5] == 0) {
BounceCOff[4][5] = millis();
}
if ((keysC[4][5] == 1) and (lastC[4][5] == 7) and ((millis() - BounceCOff[4][5]) > Delay)) {
MidiSend(noteOn3, 60, velocity);
lastC[4][5] = 0;
}
//C61
if (lastC[5][0] == 7) {
BounceCOn[5][0] = millis();
}
if ((keysC[5][0] == 0) and (lastC[5][0] == 0) and ((millis() - BounceCOn[5][0]) > Delay)) {
MidiSend(noteOff3, 61, velocity);
lastC[5][0] = 7;
}
if (lastC[5][0] == 0) {
BounceCOff[5][0] = millis();
}
if ((keysC[5][0] == 1) and (lastC[5][0] == 7) and ((millis() - BounceCOff[5][0]) > Delay)) {
MidiSend(noteOn3, 61, velocity);
lastC[5][0] = 0;
}
//C62
if (lastC[5][1] == 7) {
BounceCOn[5][1] = millis();
}
if ((keysC[5][1] == 0) and (lastC[5][1] == 0) and ((millis() - BounceCOn[5][1]) > Delay)) {
MidiSend(noteOff3, 62, velocity);
lastC[5][1] = 7;
}
if (lastC[5][1] == 0) {
BounceCOff[5][1] = millis();
}
if ((keysC[5][1] == 1) and (lastC[5][1] == 7) and ((millis() - BounceCOff[5][1]) > Delay)) {
MidiSend(noteOn3, 62, velocity);
lastC[5][1] = 0;
}
//C63
if (lastC[5][2] == 7) {
BounceCOn[5][2] = millis();
}
if ((keysC[5][2] == 0) and (lastC[5][2] == 0) and ((millis() - BounceCOn[5][2]) > Delay)) {
MidiSend(noteOff3, 63, velocity);
lastC[5][2] = 7;
}
if (lastC[5][2] == 0) {
BounceCOff[5][2] = millis();
}
if ((keysC[5][2] == 1) and (lastC[5][2] == 7) and ((millis() - BounceCOff[5][2]) > Delay)) {
MidiSend(noteOn3, 63, velocity);
lastC[5][2] = 0;
}
//C64
if (lastC[5][3] == 7) {
BounceCOn[5][3] = millis();
}
if ((keysC[5][3] == 0) and (lastC[5][3] == 0) and ((millis() - BounceCOn[5][3]) > Delay)) {
MidiSend(noteOff3, 64, velocity);
lastC[5][3] = 7;
}
if (lastC[5][3] == 0) {
BounceCOff[5][3] = millis();
}
if ((keysC[5][3] == 1) and (lastC[5][3] == 7) and ((millis() - BounceCOff[5][3]) > Delay)) {
MidiSend(noteOn3, 64, velocity);
lastC[5][3] = 0;
}
//C65
if (lastC[5][4] == 7) {
BounceCOn[5][4] = millis();
}
if ((keysC[5][4] == 0) and (lastC[5][4] == 0) and ((millis() - BounceCOn[5][4]) > Delay)) {
MidiSend(noteOff3, 65, velocity);
lastC[5][4] = 7;
}
if (lastC[5][4] == 0) {
BounceCOff[5][4] = millis();
}
if ((keysC[5][4] == 1) and (lastC[5][4] == 7) and ((millis() - BounceCOff[5][4]) > Delay)) {
MidiSend(noteOn3, 65, velocity);
lastC[5][4] = 0;
}
//C66
if (lastC[5][5] == 7) {
BounceCOn[5][5] = millis();
}
if ((keysC[5][5] == 0) and (lastC[5][5] == 0) and ((millis() - BounceCOn[5][5]) > Delay)) {
MidiSend(noteOff3, 66, velocity);
lastC[5][5] = 7;
}
if (lastC[5][5] == 0) {
BounceCOff[5][5] = millis();
}
if ((keysC[5][5] == 1) and (lastC[5][5] == 7) and ((millis() - BounceCOff[5][5]) > Delay)) {
MidiSend(noteOn3, 66, velocity);
lastC[5][5] = 0;
}
//C67
if (lastC[6][0] == 7) {
BounceCOn[6][0] = millis();
}
if ((keysC[6][0] == 0) and (lastC[6][0] == 0) and ((millis() - BounceCOn[6][0]) > Delay)) {
MidiSend(noteOff3, 67, velocity);
lastC[6][0] = 7;
}
if (lastC[6][0] == 0) {
BounceCOff[6][0] = millis();
}
if ((keysC[6][0] == 1) and (lastC[6][0] == 7) and ((millis() - BounceCOff[6][0]) > Delay)) {
MidiSend(noteOn3, 67, velocity);
lastC[6][0] = 0;
}
//Write Keyboard E (Pistons)
//E55
if (lastE[4][0] == 7) {
BounceEOn[4][0] = millis();
}
if ((keysE[4][0] == 0) and (lastE[4][0] == 0) and ((millis() - BounceEOn[4][0]) > Delay)) {
MidiSend(noteOn4, 55, velocity);
lastE[4][0] = 7;
}
if (lastE[4][0] == 0) {
BounceEOff[4][0] = millis();
}
if ((keysE[4][0] == 1) and (lastE[4][0] == 7) and ((millis() - BounceEOff[4][0]) > Delay)) {
MidiSend(noteOff4, 55, velocity);
lastE[4][0] = 0;
}
//E56
if (lastE[4][1] == 7) {
BounceEOn[4][1] = millis();
}
if ((keysE[4][1] == 0) and (lastE[4][1] == 0) and ((millis() - BounceEOn[4][1]) > Delay)) {
MidiSend(noteOn4, 56, velocity);
lastE[4][1] = 7;
}
if (lastE[4][1] == 0) {
BounceEOff[4][1] = millis();
}
if ((keysE[4][1] == 1) and (lastE[4][1] == 7) and ((millis() - BounceEOff[4][1]) > Delay)) {
MidiSend(noteOff4, 56, velocity);
lastE[4][1] = 0;
}
//E57
if (lastE[4][2] == 7) {
BounceEOn[4][2] = millis();
}
if ((keysE[4][2] == 0) and (lastE[4][2] == 0) and ((millis() - BounceEOn[4][2]) > Delay)) {
MidiSend(noteOn4, 57, velocity);
lastE[4][2] = 7;
}
if (lastE[4][2] == 0) {
BounceEOff[4][2] = millis();
}
if ((keysE[4][2] == 1) and (lastE[4][2] == 7) and ((millis() - BounceEOff[4][2]) > Delay)) {
MidiSend(noteOff4, 57, velocity);
lastE[4][2] = 0;
}
//E58
if (lastE[4][3] == 7) {
BounceEOn[4][3] = millis();
}
if ((keysE[4][3] == 0) and (lastE[4][3] == 0) and ((millis() - BounceEOn[4][3]) > Delay)) {
MidiSend(noteOn4, 58, velocity);
lastE[4][3] = 7;
}
if (lastE[4][3] == 0) {
BounceEOff[4][3] = millis();
}
if ((keysE[4][3] == 1) and (lastE[4][3] == 7) and ((millis() - BounceEOff[4][3]) > Delay)) {
MidiSend(noteOff4, 58, velocity);
lastE[4][3] = 0;
}
//E59
if (lastE[4][4] == 7) {
BounceEOn[4][4] = millis();
}
if ((keysE[4][4] == 0) and (lastE[4][4] == 0) and ((millis() - BounceEOn[4][4]) > Delay)) {
MidiSend(noteOn4, 59, velocity);
lastE[4][4] = 7;
}
if (lastE[4][4] == 0) {
BounceEOff[4][4] = millis();
}
if ((keysE[4][4] == 1) and (lastE[4][4] == 7) and ((millis() - BounceEOff[4][4]) > Delay)) {
MidiSend(noteOff4, 59, velocity);
lastE[4][4] = 0;
}
//E60
if (lastE[4][5] == 7) {
BounceEOn[4][5] = millis();
}
if ((keysE[4][5] == 0) and (lastE[4][5] == 0) and ((millis() - BounceEOn[4][5]) > Delay)) {
MidiSend(noteOn4, 60, velocity);
lastE[4][5] = 7;
}
if (lastE[4][5] == 0) {
BounceEOff[4][5] = millis();
}
if ((keysE[4][5] == 1) and (lastE[4][5] == 7) and ((millis() - BounceEOff[4][5]) > Delay)) {
MidiSend(noteOff4, 60, velocity);
lastE[4][5] = 0;
}
//E61
if (lastE[5][0] == 7) {
BounceEOn[5][0] = millis();
}
if ((keysE[5][0] == 0) and (lastE[5][0] == 0) and ((millis() - BounceEOn[5][0]) > Delay)) {
MidiSend(noteOn4, 61, velocity);
lastE[5][0] = 7;
}
if (lastE[5][0] == 0) {
BounceEOff[5][0] = millis();
}
if ((keysE[5][0] == 1) and (lastE[5][0] == 7) and ((millis() - BounceEOff[5][0]) > Delay)) {
MidiSend(noteOff4, 61, velocity);
lastE[5][0] = 0;
}
//E62
if (lastE[5][1] == 7) {
BounceEOn[5][1] = millis();
}
if ((keysE[5][1] == 0) and (lastE[5][1] == 0) and ((millis() - BounceEOn[5][1]) > Delay)) {
MidiSend(noteOn4, 62, velocity);
lastE[5][1] = 7;
}
if (lastE[5][1] == 0) {
BounceEOff[5][1] = millis();
}
if ((keysE[5][1] == 1) and (lastE[5][1] == 7) and ((millis() - BounceEOff[5][1]) > Delay)) {
MidiSend(noteOff4, 62, velocity);
lastE[5][1] = 0;
}
//E63
if (lastE[5][2] == 7) {
BounceEOn[5][2] = millis();
}
if ((keysE[5][2] == 0) and (lastE[5][2] == 0) and ((millis() - BounceEOn[5][2]) > Delay)) {
MidiSend(noteOn4, 63, velocity);
lastE[5][2] = 7;
}
if (lastE[5][2] == 0) {
BounceEOff[5][2] = millis();
}
if ((keysE[5][2] == 1) and (lastE[5][2] == 7) and ((millis() - BounceEOff[5][2]) > Delay)) {
MidiSend(noteOff4, 63, velocity);
lastE[5][2] = 0;
}
//E64
if (lastE[5][3] == 7) {
BounceEOn[5][3] = millis();
}
if ((keysE[5][3] == 0) and (lastE[5][3] == 0) and ((millis() - BounceEOn[5][3]) > Delay)) {
MidiSend(noteOn4, 64, velocity);
lastE[5][3] = 7;
}
if (lastE[5][3] == 0) {
BounceEOff[5][3] = millis();
}
if ((keysE[5][3] == 1) and (lastE[5][3] == 7) and ((millis() - BounceEOff[5][3]) > Delay)) {
MidiSend(noteOff4, 64, velocity);
lastE[5][3] = 0;
}
//E65
if (lastE[5][4] == 7) {
BounceEOn[5][4] = millis();
}
if ((keysE[5][4] == 0) and (lastE[5][4] == 0) and ((millis() - BounceEOn[5][4]) > Delay)) {
MidiSend(noteOn4, 65, velocity);
lastE[5][4] = 7;
}
if (lastE[5][4] == 0) {
BounceEOff[5][4] = millis();
}
if ((keysE[5][4] == 1) and (lastE[5][4] == 7) and ((millis() - BounceEOff[5][4]) > Delay)) {
MidiSend(noteOff4, 65, velocity);
lastE[5][4] = 0;
}
//E66
if (lastE[5][5] == 7) {
BounceEOn[5][5] = millis();
}
if ((keysE[5][5] == 0) and (lastE[5][5] == 0) and ((millis() - BounceEOn[5][5]) > Delay)) {
MidiSend(noteOn4, 66, velocity);
lastE[5][5] = 7;
}
if (lastE[5][5] == 0) {
BounceEOff[5][5] = millis();
}
if ((keysE[5][5] == 1) and (lastE[5][5] == 7) and ((millis() - BounceEOff[5][5]) > Delay)) {
MidiSend(noteOff4, 66, velocity);
lastE[5][5] = 0;
}
//E67
if (lastE[6][0] == 7) {
BounceEOn[6][0] = millis();
}
if ((keysE[6][0] == 0) and (lastE[6][0] == 0) and ((millis() - BounceEOn[6][0]) > Delay)) {
MidiSend(noteOn4, 67, velocity);
lastE[6][0] = 7;
}
if (lastE[6][0] == 0) {
BounceEOff[6][0] = millis();
}
if ((keysE[6][0] == 1) and (lastE[6][0] == 7) and ((millis() - BounceEOff[6][0]) > Delay)) {
MidiSend(noteOff4, 67, velocity);
lastE[6][0] = 0;
}
//E68
if (lastE[6][1] == 7) {
BounceEOn[6][1] = millis();
}
if ((keysE[6][1] == 0) and (lastE[6][1] == 0) and ((millis() - BounceEOn[6][1]) > Delay)) {
MidiSend(noteOn4, 68, velocity);
lastE[6][1] = 7;
}
if (lastE[6][1] == 0) {
BounceEOff[6][1] = millis();
}
if ((keysE[6][1] == 1) and (lastE[6][1] == 7) and ((millis() - BounceEOff[6][1]) > Delay)) {
MidiSend(noteOff4, 68, velocity);
lastE[6][1] = 0;
}
//E69
if (lastE[6][2] == 7) {
BounceEOn[6][2] = millis();
}
if ((keysE[6][2] == 0) and (lastE[6][2] == 0) and ((millis() - BounceEOn[6][2]) > Delay)) {
MidiSend(noteOn4, 69, velocity);
lastE[6][2] = 7;
}
if (lastE[6][2] == 0) {
BounceEOff[6][2] = millis();
}
if ((keysE[6][2] == 1) and (lastE[6][2] == 7) and ((millis() - BounceEOff[6][2]) > Delay)) {
MidiSend(noteOff4, 69, velocity);
lastE[6][2] = 0;
}
//E70
if (lastE[6][3] == 7) {
BounceEOn[6][3] = millis();
}
if ((keysE[6][3] == 0) and (lastE[6][3] == 0) and ((millis() - BounceEOn[6][3]) > Delay)) {
MidiSend(noteOn4, 70, velocity);
lastE[6][3] = 7;
}
if (lastE[6][3] == 0) {
BounceEOff[6][3] = millis();
}
if ((keysE[6][3] == 1) and (lastE[6][3] == 7) and ((millis() - BounceEOff[6][3]) > Delay)) {
MidiSend(noteOff4, 70, velocity);
lastE[6][3] = 0;
}
//E71
if (lastE[6][4] == 7) {
BounceEOn[6][4] = millis();
}
if ((keysE[6][4] == 0) and (lastE[6][4] == 0) and ((millis() - BounceEOn[6][4]) > Delay)) {
MidiSend(noteOn4, 71, velocity);
lastE[6][4] = 7;
}
if (lastE[6][4] == 0) {
BounceEOff[6][4] = millis();
}
if ((keysE[6][4] == 1) and (lastE[6][4] == 7) and ((millis() - BounceEOff[6][4]) > Delay)) {
MidiSend(noteOff4, 71, velocity);
lastE[6][4] = 0;
}
//E72
if (lastE[6][5] == 7) {
BounceEOn[6][5] = millis();
}
if ((keysE[6][5] == 0) and (lastE[6][5] == 0) and ((millis() - BounceEOn[6][5]) > Delay)) {
MidiSend(noteOn4, 72, velocity);
lastE[6][5] = 7;
}
if (lastE[6][5] == 0) {
BounceEOff[6][5] = millis();
}
if ((keysE[6][5] == 1) and (lastE[6][5] == 7) and ((millis() - BounceEOff[6][5]) > Delay)) {
MidiSend(noteOff4, 72, velocity);
lastE[6][5] = 0;
}
//E73
if (lastE[7][0] == 7) {
BounceEOn[7][0] = millis();
}
if ((keysE[7][0] == 0) and (lastE[7][0] == 0) and ((millis() - BounceEOn[7][0]) > Delay)) {
MidiSend(noteOn4, 73, velocity);
lastE[7][0] = 7;
}
if (lastE[7][0] == 0) {
BounceEOff[7][0] = millis();
}
if ((keysE[7][0] == 1) and (lastE[7][0] == 7) and ((millis() - BounceEOff[7][0]) > Delay)) {
MidiSend(noteOff4, 73, velocity);
lastE[7][0] = 0;
}
//E74
if (lastE[7][1] == 7) {
BounceEOn[7][1] = millis();
}
if ((keysE[7][1] == 0) and (lastE[7][1] == 0) and ((millis() - BounceEOn[7][1]) > Delay)) {
MidiSend(noteOn4, 74, velocity);
lastE[7][1] = 7;
}
if (lastE[7][1] == 0) {
BounceEOff[7][1] = millis();
}
if ((keysE[7][1] == 1) and (lastE[7][1] == 7) and ((millis() - BounceEOff[7][1]) > Delay)) {
MidiSend(noteOff4, 74, velocity);
lastE[7][1] = 0;
}
//E75
if (lastE[7][2] == 7) {
BounceEOn[7][2] = millis();
}
if ((keysE[7][2] == 0) and (lastE[7][2] == 0) and ((millis() - BounceEOn[7][2]) > Delay)) {
MidiSend(noteOn4, 75, velocity);
lastE[7][2] = 7;
}
if (lastE[7][2] == 0) {
BounceEOff[7][2] = millis();
}
if ((keysE[7][2] == 1) and (lastE[7][2] == 7) and ((millis() - BounceEOff[7][2]) > Delay)) {
MidiSend(noteOff4, 75, velocity);
lastE[7][2] = 0;
}
//E76
if (lastE[7][3] == 7) {
BounceEOn[7][3] = millis();
}
if ((keysE[7][3] == 0) and (lastE[7][3] == 0) and ((millis() - BounceEOn[7][3]) > Delay)) {
MidiSend(noteOn4, 76, velocity);
lastE[7][3] = 7;
}
if (lastE[7][3] == 0) {
BounceEOff[7][3] = millis();
}
if ((keysE[7][3] == 1) and (lastE[7][3] == 7) and ((millis() - BounceEOff[7][3]) > Delay)) {
MidiSend(noteOff4, 76, velocity);
lastE[7][3] = 0;
}
//E77
if (lastE[7][4] == 7) {
BounceEOn[7][4] = millis();
}
if ((keysE[7][4] == 0) and (lastE[7][4] == 0) and ((millis() - BounceEOn[7][4]) > Delay)) {
MidiSend(noteOn4, 77, velocity);
lastE[7][4] = 7;
}
if (lastE[7][4] == 0) {
BounceEOff[7][4] = millis();
}
if ((keysE[7][4] == 1) and (lastE[7][4] == 7) and ((millis() - BounceEOff[7][4]) > Delay)) {
MidiSend(noteOff4, 77, velocity);
lastE[7][4] = 0;
}
//E78
if (lastE[7][5] == 7) {
BounceEOn[7][5] = millis();
}
if ((keysE[7][5] == 0) and (lastE[7][5] == 0) and ((millis() - BounceEOn[7][5]) > Delay)) {
MidiSend(noteOn4, 78, velocity);
lastE[7][5] = 7;
}
if (lastE[7][5] == 0) {
BounceEOff[7][5] = millis();
}
if ((keysE[7][5] == 1) and (lastE[7][5] == 7) and ((millis() - BounceEOff[7][5]) > Delay)) {
MidiSend(noteOff4, 78, velocity);
lastE[7][5] = 0;
}
//E79
if (lastE[8][0] == 7) {
BounceEOn[8][0] = millis();
}
if ((keysE[8][0] == 0) and (lastE[8][0] == 0) and ((millis() - BounceEOn[8][0]) > Delay)) {
MidiSend(noteOn4, 79, velocity);
lastE[8][0] = 7;
}
if (lastE[8][0] == 0) {
BounceEOff[8][0] = millis();
}
if ((keysE[8][0] == 1) and (lastE[8][0] == 7) and ((millis() - BounceEOff[8][0]) > Delay)) {
MidiSend(noteOff4, 79, velocity);
lastE[8][0] = 0;
}
//E80
if (lastE[8][1] == 7) {
BounceEOn[8][1] = millis();
}
if ((keysE[8][1] == 0) and (lastE[8][1] == 0) and ((millis() - BounceEOn[8][1]) > Delay)) {
MidiSend(noteOn4, 80, velocity);
lastE[8][1] = 7;
}
if (lastE[8][1] == 0) {
BounceEOff[8][1] = millis();
}
if ((keysE[8][1] == 1) and (lastE[8][1] == 7) and ((millis() - BounceEOff[8][1]) > Delay)) {
MidiSend(noteOff4, 80, velocity);
lastE[8][1] = 0;
}
//E81
if (lastE[8][2] == 7) {
BounceEOn[8][2] = millis();
}
if ((keysE[8][2] == 0) and (lastE[8][2] == 0) and ((millis() - BounceEOn[8][2]) > Delay)) {
MidiSend(noteOn4, 81, velocity);
lastE[8][2] = 7;
}
if (lastE[8][2] == 0) {
BounceEOff[8][2] = millis();
}
if ((keysE[8][2] == 1) and (lastE[8][2] == 7) and ((millis() - BounceEOff[8][2]) > Delay)) {
MidiSend(noteOff4, 81, velocity);
lastE[8][2] = 0;
}
//E82
if (lastE[8][3] == 7) {
BounceEOn[8][3] = millis();
}
if ((keysE[8][3] == 0) and (lastE[8][3] == 0) and ((millis() - BounceEOn[8][3]) > Delay)) {
MidiSend(noteOn4, 82, velocity);
lastE[8][3] = 7;
}
if (lastE[8][3] == 0) {
BounceEOff[8][3] = millis();
}
if ((keysE[8][3] == 1) and (lastE[8][3] == 7) and ((millis() - BounceEOff[8][3]) > Delay)) {
MidiSend(noteOff4, 82, velocity);
lastE[8][3] = 0;
}
//E83
if (lastE[8][4] == 7) {
BounceEOn[8][4] = millis();
}
if ((keysE[8][4] == 0) and (lastE[8][4] == 0) and ((millis() - BounceEOn[8][4]) > Delay)) {
MidiSend(noteOn4, 83, velocity);
lastE[8][4] = 7;
}
if (lastE[8][4] == 0) {
BounceEOff[8][4] = millis();
}
if ((keysE[8][4] == 1) and (lastE[8][4] == 7) and ((millis() - BounceEOff[8][4]) > Delay)) {
MidiSend(noteOff4, 83, velocity);
lastE[8][4] = 0;
}
//E84
if (lastE[8][5] == 7) {
BounceEOn[8][5] = millis();
}
if ((keysE[8][5] == 0) and (lastE[8][5] == 0) and ((millis() - BounceEOn[8][5]) > Delay)) {
MidiSend(noteOn4, 84, velocity);
lastE[8][5] = 7;
}
if (lastE[8][5] == 0) {
BounceEOff[8][5] = millis();
}
if ((keysE[8][5] == 1) and (lastE[8][5] == 7) and ((millis() - BounceEOff[8][5]) > Delay)) {
MidiSend(noteOff4, 84, velocity);
lastE[8][5] = 0;
}
//Expression Pedal controls
//Expression pedal on analog pin A13 to Channel 6
int Cur6 = analogRead(14);
int Map6 = map(Cur6, 0, 1023, 0, 127);
if (abs(Cur6 - LastPot6) >= PotT) {
MidiSend(CCchan6,Exp,Map6);
LastPot6 = Cur6;
}
//Expression pedal on analog pin A14 to Channel 7
int Cur7 = analogRead(15);
int Map7 = map(Cur7, 0, 1023, 0, 127);
if (abs(Cur7 - LastPot7) >= PotT) {
MidiSend(CCchan7,Exp,Map7);
LastPot7 = Cur7;
}
//Midi Thru
if (byteReady) {
byteReady = false;
Serial.write(midiByte);
}
}
void MidiSend(int one, int two, int three) {
Serial.write(one);
Serial.write(two);
Serial.write(three);
}
void serialEvent() {
if (Serial.available()) {
// get the new byte:
midiByte = (unsigned char)Serial.read();
byteReady = true;
}
}
Comments