/ MIDI_FeatherWing / MIDI_FeatherWing.ino
MIDI_FeatherWing.ino
 1  // SPDX-FileCopyrightText: 2021 John Park for Adafruit Industries
 2  // SPDX-License-Identifier: MIT
 3  
 4  // MIDI FeatherWing note player example
 5  
 6  
 7  #include <MIDI.h>
 8  
 9  #ifdef USE_TINYUSB
10  #include <Adafruit_TinyUSB.h>
11  #endif
12  
13  MIDI_CREATE_DEFAULT_INSTANCE();
14  
15  int notes[] = {69, 72, 74, 76, 72, 81, 79};  // melody notes
16  int vels[] = {127, 96, 64, 96, 32, 127, 64};  // velocity per note
17  int rests[] = {50, 50, 50, 50, 50, 200, 50};  // rests between notes
18  int note_mods[] = {0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 5, 5, 3, 3};  // modifies notes for progression
19  
20  void setup(){
21      MIDI.begin(MIDI_CHANNEL_OMNI);
22  }
23  
24  void loop() {
25  
26    for(int j=0; j<16; j++){  // loop through four measures for progression
27      for(int i=0; i<7; i++){ //
28        MIDI.sendNoteOn(notes[i]+note_mods[j], vels[i], 1);
29        delay(100);
30        MIDI.sendNoteOff(notes[i]+note_mods[j], 0, 1);
31        delay(rests[i]);
32      }
33    }
34  }