Академический Документы
Профессиональный Документы
Культура Документы
***************************************************************************
************************************** // *
*
// * Arduino MIDI Drums *
// * 2017 (c) StanleyProjects.com *
// *
*
// * Custom code - no hi-hat pedal, 10 drum pads *
//
***************************************************************************
**************************************
#define NUMBER_OF_PADS 10 // number of drum pads (analog inputs)
#define VELOCITY_ACTIVE 1 // velocity sensitive ON-OFF [1-0] #define
MIDI_CHANNEL 1 // MIDI channel [1-16]
void setup() {
Serial.begin(31250);
// initialize the serial port at baud rate 115200
}
void loop() {
for (uint8_t pin = 0; pin < NUMBER_OF_PADS; pin++) {
// loop through all of the pads
uint8_t val = analogRead(pin);
// read the input pin
if ((val > padThreshold[pin]) && (!padActive(pin))) {
// if hit strong enough
midi_tx_note_on(padNote[pin], val);
// send a note on MIDI message
padCurrentCycles[pin] = 0;
// reset the current pad cycle counter
activePad |= 1 << pin;
// set corresponding bit (active flag)
}
if (padActive(pin)) {
// enter if pad is active
padCurrentCycles[pin] += 1;
// increment the cycle counter by 1