├── README.md ├── library.properties ├── .gitignore ├── library.json ├── LICENSE ├── examples ├── piano │ └── piano.ino ├── drum │ └── drum.ino └── FurElise │ ├── FurElise.ino │ └── melody.h └── src ├── M5UnitSynth.h ├── M5UnitSynthDef.h └── M5UnitSynth.cpp /README.md: -------------------------------------------------------------------------------- 1 | # M5Unit-Synth 2 | 3 | ## Overview 4 | 5 | Contains case programs of M5Stack Unit Synth. 6 | 7 | ## License 8 | 9 | [Unit Synth - MIT](LICENSE) 10 | 11 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=M5UnitSynth 2 | version=1.0.1 3 | author=M5Stack 4 | maintainer=M5Stack 5 | sentence=Library for M5Stack M5Unit Synth 6 | paragraph=M5Stack, M5UnitSynth, See more on http://M5Stack.com 7 | category=Display 8 | url=https://github.com/m5stack/M5Unit-Synth.git 9 | architectures=esp32 10 | includes=M5UnitSynth.h 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | .clang-format -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "M5UnitSynth", 3 | "description": "Library for M5Stack M5Unit Synth", 4 | "keywords": "M5GFX,M5Stack,M5UnitSynth", 5 | "authors": { 6 | "name": "M5Stack, Sean", 7 | "url": "http://www.m5stack.com" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/m5stack/M5Unit-Synth.git" 12 | }, 13 | "version": "1.0.1", 14 | "frameworks": [ 15 | "arduino" 16 | ], 17 | "platforms": [ 18 | "espressif32", 19 | "native" 20 | ], 21 | "headers": "M5UnitSynth.h" 22 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 M5Stack Technology CO LTD 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/piano/piano.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * @file piano.ino 3 | * @author SeanKwok (shaoxiang@m5stack.com) 4 | * @brief Unit Synth Piano Example 5 | * @version 0.2 6 | * @date 2024-04-07 7 | * 8 | * 9 | * @Hardwares: M5Core + Unit Synth 10 | * @Platform Version: Arduino M5Stack Board Manager v2.1.0 11 | * @Dependent Library: 12 | * M5UnitSynth: https://github.com/m5stack/M5Unit-Synth 13 | */ 14 | 15 | #include "M5UnitSynth.h" 16 | 17 | M5UnitSynth synth; 18 | 19 | void setup() { 20 | Serial.begin(115200); 21 | Serial.println("Unit Synth Piano"); 22 | synth.begin(&Serial2, UNIT_SYNTH_BAUD, 16, 17); 23 | synth.setInstrument(0, 0, GrandPiano_1); // synth piano 1 24 | } 25 | 26 | void loop() { 27 | synth.setNoteOn(0, NOTE_C4, 127); 28 | delay(1000); 29 | synth.setNoteOn(0, NOTE_D4, 127); 30 | delay(1000); 31 | synth.setNoteOn(0, NOTE_E4, 127); 32 | delay(1000); 33 | synth.setNoteOn(0, NOTE_F4, 127); 34 | delay(1000); 35 | synth.setNoteOn(0, NOTE_G4, 127); 36 | delay(1000); 37 | synth.setNoteOn(0, NOTE_A4, 127); 38 | delay(1000); 39 | synth.setNoteOn(0, NOTE_B4, 127); 40 | delay(1000); 41 | synth.setNoteOn(0, NOTE_C5, 127); 42 | delay(1000); 43 | } 44 | -------------------------------------------------------------------------------- /examples/drum/drum.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * @file drum.ino 3 | * @author SeanKwok (shaoxiang@m5stack.com) 4 | * @brief Unit Synth Drum Example 5 | * @version 0.2 6 | * @date 2024-04-07 7 | * 8 | * 9 | * @Hardwares: M5Core + Unit Synth 10 | * @Platform Version: Arduino M5Stack Board Manager v2.1.0 11 | * @Dependent Library: 12 | * M5UnitSynth: https://github.com/m5stack/M5Unit-Synth 13 | */ 14 | 15 | #include "M5UnitSynth.h" 16 | 17 | M5UnitSynth synth; 18 | 19 | void setup() { 20 | Serial.begin(115200); 21 | Serial.println("Unit Synth Drum"); 22 | synth.begin(&Serial2, UNIT_SYNTH_BAUD, 16, 17); 23 | synth.setInstrument(0, 9, SynthDrum); // synth drum 24 | } 25 | 26 | void loop() { 27 | synth.setNoteOn(9, 36, 127); 28 | synth.setNoteOn(9, 42, 127); 29 | delay(300); 30 | synth.setNoteOn(9, 42, 127); 31 | delay(300); 32 | synth.setNoteOn(9, 38, 127); 33 | synth.setNoteOn(9, 42, 127); 34 | delay(300); 35 | synth.setNoteOn(9, 42, 127); 36 | delay(300); 37 | 38 | synth.setNoteOn(9, 36, 127); 39 | synth.setNoteOn(9, 42, 127); 40 | delay(300); 41 | synth.setNoteOn(9, 36, 127); 42 | synth.setNoteOn(9, 42, 127); 43 | delay(300); 44 | synth.setNoteOn(9, 38, 127); 45 | synth.setNoteOn(9, 42, 127); 46 | delay(300); 47 | synth.setNoteOn(9, 42, 127); 48 | delay(300); 49 | } 50 | -------------------------------------------------------------------------------- /examples/FurElise/FurElise.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Fur Elise 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | 9 | /* 10 | 11 | Original Sketch by Robson Couto 2019 12 | https://github.com/robsoncouto/arduino-songs and Converted for use with the 13 | M5Stack Core Ink by LeRoy Miller in Jan 2021 14 | 15 | Mar 12, 2024 modified by LeRoy Miller for use with the M5StickC and the Synth 16 | Midi Unit 17 | -> Changed note definitions to values that will work with the Synth Midi Unit 18 | -> Changed tone/notone to setNoteOn and setNoteOff 19 | -> added the M5UnitSynth library 20 | -> added a variable to change the instrument used 21 | 22 | */ 23 | 24 | #include 25 | #include "melody.h" 26 | 27 | M5UnitSynth synth; 28 | 29 | // change this to make the song slower or faster 30 | int tempo = 80; 31 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 32 | // bits) there are two values per note (pitch and duration), so for each note 33 | // there are four bytes 34 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 35 | 36 | // this calculates the duration of a whole note in ms 37 | int wholenote = (60000 * 4) / tempo; 38 | 39 | int divider = 0, noteDuration = 0; 40 | 41 | void play() { 42 | // iterate over the notes of the melody. 43 | // Remember, the array is twice the number of notes (notes + durations) 44 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 45 | // calculates the duration of each note 46 | divider = melody[thisNote + 1]; 47 | if (divider > 0) { 48 | // regular note, just proceed 49 | noteDuration = (wholenote) / divider; 50 | } else if (divider < 0) { 51 | // dotted notes are represented with negative durations!! 52 | noteDuration = (wholenote) / abs(divider); 53 | noteDuration *= 54 | 1.5; // increases the duration in half for dotted notes 55 | } 56 | 57 | // we only play the note for 90% of the duration, leaving 10% as a pause 58 | synth.setNoteOn(0, melody[thisNote], 127); // noteDuration * 0.9); 59 | // Wait for the specief duration before playing the next note. 60 | delay(noteDuration); 61 | // stop the waveform generation before the next note. 62 | synth.setNoteOff(0, melody[thisNote], 127); 63 | } 64 | } 65 | 66 | void setup() { 67 | synth.begin(&Serial2, UNIT_SYNTH_BAUD, 16, 17); 68 | synth.setInstrument(0, 0, ElGrdPiano_3); // synth piano 1 69 | play(); 70 | } 71 | 72 | void loop() { 73 | // no need to repeat the melody. 74 | } 75 | -------------------------------------------------------------------------------- /src/M5UnitSynth.h: -------------------------------------------------------------------------------- 1 | #ifndef _M5_UNIT_SYNTH_H 2 | #define _M5_UNIT_SYNTH_H 3 | 4 | #include "M5UnitSynthDef.h" 5 | #include "Arduino.h" 6 | 7 | #define UNIT_SYNTH_BAUD 31250 8 | 9 | #define MIDI_CMD_NOTE_OFF 0x80 // Note Off 10 | #define MIDI_CMD_NOTE_ON 0x90 // Note On 11 | #define MIDI_CMD_POLYPHONIC_AFTERTOUCH \ 12 | 0xA0 // Polyphonic Aftertouch (or Key Pressure) 13 | #define MIDI_CMD_CONTROL_CHANGE \ 14 | 0xB0 // Control Change (or Channel Mode 15 | // Message) 16 | #define MIDI_CMD_PROGRAM_CHANGE 0xC0 // Program Change 17 | #define MIDI_CMD_CHANNEL_AFTERTOUCH \ 18 | 0xD0 // Channel Aftertouch (or Channel Pressure) 19 | #define MIDI_CMD_PITCH_BEND 0xE0 // Pitch Bend 20 | #define MIDI_CMD_SYSTEM_EXCLUSIVE 0xF0 // System Exclusive (SysEx) Start 21 | #define MIDI_CMD_TIME_CODE 0xF1 // MIDI Time Code Quarter Frame 22 | #define MIDI_CMD_SONG_POSITION 0xF2 // Song Position Pointer 23 | #define MIDI_CMD_SONG_SELECT 0xF3 // Song Select 24 | #define MIDI_CMD_TUNE_REQUEST 0xF6 // Tune Request 25 | #define MIDI_CMD_END_OF_SYSEX 0xF7 // End of SysEx 26 | #define MIDI_CMD_TIMING_CLOCK \ 27 | 0xF8 // Timing Clock (used in System Real-Time Messages) 28 | #define MIDI_CMD_START 0xFA // Start (used in System Real-Time Messages) 29 | #define MIDI_CMD_CONTINUE 0xFB // Continue (used in System Real-Time Messages) 30 | #define MIDI_CMD_STOP 0xFC // Stop (used in System Real-Time Messages) 31 | #define MIDI_CMD_ACTIVE_SENSING \ 32 | 0xFE // Active Sensing (used in System Real-Time Messages) 33 | #define MIDI_CMD_SYSTEM_RESET 0xFF // System Reset 34 | 35 | class M5UnitSynth { 36 | private: 37 | HardwareSerial *_serial; 38 | void sendCMD(uint8_t *buffer, size_t size); 39 | 40 | public: 41 | void begin(HardwareSerial *serial = &Serial1, int baud = UNIT_SYNTH_BAUD, 42 | uint8_t RX = 16, uint8_t TX = 17); 43 | 44 | void setInstrument(uint8_t bank, uint8_t channel, uint8_t value); 45 | void setNoteOn(uint8_t channel, uint8_t pitch, uint8_t velocity); 46 | void setNoteOff(uint8_t channel, uint8_t pitch, uint8_t velocity); 47 | void setAllNotesOff(uint8_t channel); 48 | 49 | void setPitchBend(uint8_t channel, int value); 50 | void setPitchBendRange(uint8_t channel, uint8_t value); 51 | 52 | void setMasterVolume(uint8_t level); // 0-127 53 | void setVolume(uint8_t channel, uint8_t level); // 0-127 54 | 55 | void setExpression(uint8_t channel, uint8_t expression); // 0-127 56 | 57 | void setReverb(uint8_t channel, uint8_t program, uint8_t level, 58 | uint8_t delayfeedback); 59 | 60 | void setChorus(uint8_t channel, uint8_t program, uint8_t level, 61 | uint8_t feedback, uint8_t chorusdelay); 62 | void setPan(uint8_t channel, uint8_t value); 63 | void setEqualizer(uint8_t channel, uint8_t lowband, uint8_t medlowband, 64 | uint8_t medhighband, uint8_t highband, uint8_t lowfreq, 65 | uint8_t medlowfreq, uint8_t medhighfreq, 66 | uint8_t highfreq); 67 | 68 | void setTuning(uint8_t channel, uint8_t fine, 69 | uint8_t coarse); // 0-127, 64 is default t 70 | void setVibrate(uint8_t channel, uint8_t rate, uint8_t depth, 71 | uint8_t delay); 72 | 73 | void setTvf(uint8_t channel, uint8_t cutoff, uint8_t resonance); 74 | 75 | void setEnvelope(uint8_t channel, uint8_t attack, uint8_t decay, 76 | uint8_t release); 77 | 78 | void setModWheel(uint8_t channel, uint8_t pitch, uint8_t tvtcutoff, 79 | uint8_t amplitude, uint8_t rate, uint8_t pitchdepth, 80 | uint8_t tvfdepth, uint8_t tvadepth); 81 | 82 | void setAllInstrumentDrums(); 83 | 84 | void reset(); 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /src/M5UnitSynthDef.h: -------------------------------------------------------------------------------- 1 | #ifndef _M5_UNIT_SYNTH_INSTRUMENT_DEF_H 2 | #define _M5_UNIT_SYNTH_INSTRUMENT_DEF_H 3 | 4 | #define NOTE_B0 23 5 | #define NOTE_C1 24 6 | #define NOTE_CS1 25 7 | #define NOTE_D1 26 8 | #define NOTE_DS1 27 9 | #define NOTE_E1 28 10 | #define NOTE_F1 29 11 | #define NOTE_FS1 30 12 | #define NOTE_G1 31 13 | #define NOTE_GS1 32 14 | #define NOTE_A1 33 15 | #define NOTE_AS1 34 16 | #define NOTE_B1 35 17 | #define NOTE_C2 36 18 | #define NOTE_CS2 37 19 | #define NOTE_D2 38 20 | #define NOTE_DS2 39 21 | #define NOTE_E2 40 22 | #define NOTE_F2 41 23 | #define NOTE_FS2 42 24 | #define NOTE_G2 43 25 | #define NOTE_GS2 44 26 | #define NOTE_A2 45 27 | #define NOTE_AS2 46 28 | #define NOTE_B2 47 29 | #define NOTE_C3 48 30 | #define NOTE_CS3 49 31 | #define NOTE_D3 50 32 | #define NOTE_DS3 51 33 | #define NOTE_E3 52 34 | #define NOTE_F3 53 35 | #define NOTE_FS3 54 36 | #define NOTE_G3 55 37 | #define NOTE_GS3 56 38 | #define NOTE_A3 57 39 | #define NOTE_AS3 58 40 | #define NOTE_B3 59 41 | #define NOTE_C4 60 42 | #define NOTE_CS4 61 43 | #define NOTE_D4 62 44 | #define NOTE_DS4 63 45 | #define NOTE_E4 64 46 | #define NOTE_F4 65 47 | #define NOTE_FS4 66 48 | #define NOTE_G4 67 49 | #define NOTE_GS4 68 50 | #define NOTE_A4 69 51 | #define NOTE_AS4 70 52 | #define NOTE_B4 71 53 | #define NOTE_C5 72 54 | #define NOTE_CS5 73 55 | #define NOTE_D5 74 56 | #define NOTE_DS5 75 57 | #define NOTE_E5 76 58 | #define NOTE_F5 77 59 | #define NOTE_FS5 78 60 | #define NOTE_G5 79 61 | #define NOTE_GS5 80 62 | #define NOTE_A5 81 63 | #define NOTE_AS5 82 64 | #define NOTE_B5 83 65 | #define NOTE_C6 84 66 | #define NOTE_CS6 85 67 | #define NOTE_D6 86 68 | #define NOTE_DS6 87 69 | #define NOTE_E6 88 70 | #define NOTE_F6 89 71 | #define NOTE_FS6 90 72 | #define NOTE_G6 91 73 | #define NOTE_GS6 92 74 | #define NOTE_A6 93 75 | #define NOTE_AS6 94 76 | #define NOTE_B6 95 77 | #define NOTE_C7 96 78 | #define NOTE_CS7 97 79 | #define NOTE_D7 98 80 | #define NOTE_DS7 99 81 | #define NOTE_E7 100 82 | #define NOTE_F7 101 83 | #define NOTE_FS7 102 84 | #define NOTE_G7 103 85 | #define NOTE_GS7 104 86 | #define NOTE_A7 105 87 | #define NOTE_AS7 106 88 | #define NOTE_B7 107 89 | #define NOTE_C8 108 90 | #define NOTE_CS8 109 91 | #define NOTE_D8 110 92 | #define NOTE_DS8 111 93 | #define REST 0 94 | 95 | typedef enum { 96 | GrandPiano_1 = 0, 97 | BrightPiano_2, 98 | ElGrdPiano_3, 99 | HonkyTonkPiano, 100 | ElPiano1, 101 | ElPiano2, 102 | Harpsichord, 103 | Clavi, 104 | Celesta, 105 | Glockenspiel, 106 | MusicBox, 107 | Vibraphone, 108 | Marimba, 109 | Xylophone, 110 | TubularBells, 111 | Santur, 112 | DrawbarOrgan, 113 | PercussiveOrgan, 114 | RockOrgan, 115 | ChurchOrgan, 116 | ReedOrgan, 117 | AccordionFrench, 118 | Harmonica, 119 | TangoAccordion, 120 | AcGuitarNylon, 121 | AcGuitarSteel, 122 | AcGuitarJazz, 123 | AcGuitarClean, 124 | AcGuitarMuted, 125 | OverdrivenGuitar, 126 | DistortionGuitar, 127 | GuitarHarmonics, 128 | AcousticBass, 129 | FingerBass, 130 | PickedBass, 131 | FretlessBass, 132 | SlapBass1, 133 | SlapBass2, 134 | SynthBass1, 135 | SynthBass2, 136 | Violin, 137 | Viola, 138 | Cello, 139 | Contrabass, 140 | TremoloStrings, 141 | PizzicatoStrings, 142 | OrchestralHarp, 143 | Timpani, 144 | StringEnsemble1, 145 | StringEnsemble2, 146 | SynthStrings1, 147 | SynthStrings2, 148 | ChoirAahs, 149 | VoiceOohs, 150 | SynthVoice, 151 | OrchestraHit, 152 | Trumpet, 153 | Trombone, 154 | Tuba, 155 | MutedTrumpet, 156 | FrenchHorn, 157 | BrassSection, 158 | SynthBrass1, 159 | SynthBrass2, 160 | SopranoSax, 161 | AltoSax, 162 | TenorSax, 163 | BaritoneSax, 164 | Oboe, 165 | EnglishHorn, 166 | Bassoon, 167 | Clarinet, 168 | Piccolo, 169 | Flute, 170 | Recorder, 171 | PanFlute, 172 | BlownBottle, 173 | Shakuhachi, 174 | Whistle, 175 | Ocarina, 176 | Lead1Square, 177 | Lead2Sawtooth, 178 | Lead3Calliope, 179 | Lead4Chiff, 180 | Lead5Charang, 181 | Lead6Voice, 182 | Lead7Fifths, 183 | Lead8BassLead, 184 | Pad1Fantasia, 185 | Pad2Warm, 186 | Pad3PolySynth, 187 | Pad4Choir, 188 | Pad5Bowed, 189 | Pad6Metallic, 190 | Pad7Halo, 191 | Pad8Sweep, 192 | FX1Rain, 193 | FX2Soundtrack, 194 | FX3Crystal, 195 | FX4Atmosphere, 196 | FX5Brightness, 197 | FX6Goblins, 198 | FX7Echoes, 199 | FX8SciFi, 200 | Sitar, 201 | Banjo, 202 | Shamisen, 203 | Koto, 204 | Kalimba, 205 | BagPipe, 206 | Fiddle, 207 | Shanai, 208 | TinkleBell, 209 | Agogo, 210 | SteelDrums, 211 | Woodblock, 212 | TaikoDrum, 213 | MelodicTom, 214 | SynthDrum, 215 | ReverseCymbal, 216 | GtFretNoise, 217 | BreathNoise, 218 | Seashore, 219 | BirdTweet, 220 | TelephRing, 221 | Helicopter, 222 | Applause, 223 | Gunshot, 224 | } unit_synth_instrument_t; 225 | 226 | #endif 227 | -------------------------------------------------------------------------------- /src/M5UnitSynth.cpp: -------------------------------------------------------------------------------- 1 | #include "M5UnitSynth.h" 2 | 3 | void M5UnitSynth::begin(HardwareSerial *serial, int baud, uint8_t RX, 4 | uint8_t TX) { 5 | _serial = serial; 6 | _serial->begin(baud, SERIAL_8N1, RX, TX); 7 | } 8 | 9 | void M5UnitSynth::sendCMD(uint8_t *buffer, size_t size) { 10 | _serial->write(buffer, size); 11 | } 12 | 13 | void M5UnitSynth::setInstrument(uint8_t bank, uint8_t channel, uint8_t value) { 14 | uint8_t CMD_CONTROL_CHANGE_1[] = { 15 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 0x00, bank}; 16 | 17 | sendCMD(CMD_CONTROL_CHANGE_1, sizeof(CMD_CONTROL_CHANGE_1)); 18 | 19 | uint8_t CMD_PROGRAM_CHANGE_2[] = { 20 | (uint8_t)(MIDI_CMD_PROGRAM_CHANGE | (channel & 0x0f)), value}; 21 | sendCMD(CMD_PROGRAM_CHANGE_2, sizeof(CMD_PROGRAM_CHANGE_2)); 22 | } 23 | 24 | void M5UnitSynth::setNoteOn(uint8_t channel, uint8_t pitch, uint8_t velocity) { 25 | uint8_t CMD_NOTE_ON[] = {(uint8_t)(MIDI_CMD_NOTE_ON | (channel & 0x0f)), 26 | pitch, velocity}; 27 | sendCMD(CMD_NOTE_ON, sizeof(CMD_NOTE_ON)); 28 | } 29 | 30 | void M5UnitSynth::setNoteOff(uint8_t channel, uint8_t pitch, uint8_t velocity) { 31 | uint8_t CMD_NOTE_OFF[] = {(uint8_t)(MIDI_CMD_NOTE_OFF | (channel & 0x0f)), 32 | pitch, 0x00}; 33 | sendCMD(CMD_NOTE_OFF, sizeof(CMD_NOTE_OFF)); 34 | } 35 | void M5UnitSynth::setAllNotesOff(uint8_t channel) { 36 | uint8_t CMD_CONTROL_CHANGE[] = { 37 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 0x7b, 0x00}; 38 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 39 | } 40 | 41 | void M5UnitSynth::setPitchBend(uint8_t channel, int value) { 42 | value = map(value, 0, 1023, 0, 0x3fff); 43 | uint8_t CMD_PITCH_BEND[] = { 44 | (uint8_t)(MIDI_CMD_PITCH_BEND | (channel & 0x0f)), 45 | (uint8_t)(value & 0xef), (uint8_t)((value >> 7) & 0xff)}; 46 | sendCMD(CMD_PITCH_BEND, sizeof(CMD_PITCH_BEND)); 47 | } 48 | void M5UnitSynth::setPitchBendRange(uint8_t channel, uint8_t value) { 49 | uint8_t CMD_CONTROL_CHANGE[] = { 50 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 51 | 0x65, 52 | 0x00, 53 | 0x64, 54 | 0x00, 55 | 0x06, 56 | (uint8_t)(value & 0x7f)}; 57 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 58 | } 59 | 60 | void M5UnitSynth::setMasterVolume(uint8_t level) { 61 | uint8_t CMD_SYSTEM_EXCLUSIVE[] = {MIDI_CMD_SYSTEM_EXCLUSIVE, 62 | 0x7f, 63 | 0x7f, 64 | 0x04, 65 | 0x01, 66 | 0x00, 67 | (uint8_t)(level & 0x7f), 68 | MIDI_CMD_END_OF_SYSEX}; 69 | sendCMD(CMD_SYSTEM_EXCLUSIVE, sizeof(CMD_SYSTEM_EXCLUSIVE)); 70 | } 71 | void M5UnitSynth::setVolume(uint8_t channel, uint8_t level) { 72 | uint8_t CMD_CONTROL_CHANGE[] = { 73 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 0x07, level}; 74 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 75 | } 76 | 77 | void M5UnitSynth::setExpression(uint8_t channel, uint8_t expression) { 78 | uint8_t CMD_CONTROL_CHANGE[] = { 79 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 0x0b, expression}; 80 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 81 | } 82 | 83 | void M5UnitSynth::setReverb(uint8_t channel, uint8_t program, uint8_t level, 84 | uint8_t delayfeedback) { 85 | uint8_t CMD_CONTROL_CHANGE_1[] = { 86 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 0x50, 87 | (uint8_t)(program & 0x07)}; 88 | sendCMD(CMD_CONTROL_CHANGE_1, sizeof(CMD_CONTROL_CHANGE_1)); 89 | 90 | uint8_t CMD_CONTROL_CHANGE_2[] = { 91 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 0x5b, 92 | (uint8_t)(level & 0x7f)}; 93 | sendCMD(CMD_CONTROL_CHANGE_2, sizeof(CMD_CONTROL_CHANGE_2)); 94 | 95 | if (delayfeedback > 0) { 96 | uint8_t CMD_SYSTEM_EXCLUSIVE[] = {MIDI_CMD_SYSTEM_EXCLUSIVE, 97 | 0x41, 98 | 0x00, 99 | 0x42, 100 | 0x12, 101 | 0x40, 102 | 0x01, 103 | 0x35, 104 | (uint8_t)(delayfeedback & 0x7f), 105 | 0x00, 106 | MIDI_CMD_END_OF_SYSEX}; 107 | sendCMD(CMD_SYSTEM_EXCLUSIVE, sizeof(CMD_SYSTEM_EXCLUSIVE)); 108 | } 109 | } 110 | 111 | void M5UnitSynth::setChorus(uint8_t channel, uint8_t program, uint8_t level, 112 | uint8_t feedback, uint8_t chorusdelay) { 113 | uint8_t CMD_CONTROL_CHANGE_1[] = { 114 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 0x51, 115 | (uint8_t)(program & 0x07)}; 116 | sendCMD(CMD_CONTROL_CHANGE_1, sizeof(CMD_CONTROL_CHANGE_1)); 117 | 118 | uint8_t CMD_CONTROL_CHANGE_2[] = { 119 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 0x5d, 120 | (uint8_t)(level & 0x7f)}; 121 | sendCMD(CMD_CONTROL_CHANGE_2, sizeof(CMD_CONTROL_CHANGE_2)); 122 | 123 | if (feedback > 0) { 124 | uint8_t CMD_SYSTEM_EXCLUSIVE_1[] = {MIDI_CMD_SYSTEM_EXCLUSIVE, 125 | 0x41, 126 | 0x00, 127 | 0x42, 128 | 0x12, 129 | 0x40, 130 | 0x01, 131 | 0x3b, 132 | (uint8_t)(feedback & 0x7f), 133 | 0x00, 134 | MIDI_CMD_END_OF_SYSEX}; 135 | sendCMD(CMD_SYSTEM_EXCLUSIVE_1, sizeof(CMD_SYSTEM_EXCLUSIVE_1)); 136 | } 137 | 138 | if (chorusdelay > 0) { 139 | uint8_t CMD_SYSTEM_EXCLUSIVE_2[] = {MIDI_CMD_SYSTEM_EXCLUSIVE, 140 | 0x41, 141 | 0x00, 142 | 0x42, 143 | 0x12, 144 | 0x40, 145 | 0x01, 146 | 0x3c, 147 | (uint8_t)(feedback & 0x7f), 148 | 0x00, 149 | MIDI_CMD_END_OF_SYSEX 150 | 151 | }; 152 | sendCMD(CMD_SYSTEM_EXCLUSIVE_2, sizeof(CMD_SYSTEM_EXCLUSIVE_2)); 153 | } 154 | } 155 | 156 | void M5UnitSynth::setPan(uint8_t channel, uint8_t value) { 157 | uint8_t CMD_CONTROL_CHANGE[] = { 158 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 0x0A, value}; 159 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 160 | } 161 | 162 | void M5UnitSynth::setEqualizer(uint8_t channel, uint8_t lowband, 163 | uint8_t medlowband, uint8_t medhighband, 164 | uint8_t highband, uint8_t lowfreq, 165 | uint8_t medlowfreq, uint8_t medhighfreq, 166 | uint8_t highfreq) { 167 | uint8_t CMD_CONTROL_CHANGE[] = { 168 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 169 | 0x63, 170 | 0x37, 171 | 0x62, 172 | 0x00, 173 | 0x06, 174 | (uint8_t)(lowband & 0x7f)}; 175 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 176 | 177 | CMD_CONTROL_CHANGE[4] = 0x01; 178 | CMD_CONTROL_CHANGE[6] = (medlowband & 0x7f); 179 | 180 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 181 | 182 | CMD_CONTROL_CHANGE[4] = 0x02; 183 | CMD_CONTROL_CHANGE[6] = (medhighband & 0x7f); 184 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 185 | 186 | CMD_CONTROL_CHANGE[4] = 0x03; 187 | CMD_CONTROL_CHANGE[6] = (highband & 0x7f); 188 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 189 | 190 | CMD_CONTROL_CHANGE[4] = 0x08; 191 | CMD_CONTROL_CHANGE[6] = (lowfreq & 0x7f); 192 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 193 | 194 | CMD_CONTROL_CHANGE[4] = 0x09; 195 | CMD_CONTROL_CHANGE[6] = (medlowfreq & 0x7f); 196 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 197 | 198 | CMD_CONTROL_CHANGE[4] = 0x0A; 199 | CMD_CONTROL_CHANGE[6] = (medhighfreq & 0x7f); 200 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 201 | 202 | CMD_CONTROL_CHANGE[4] = 0x0B; 203 | CMD_CONTROL_CHANGE[6] = (highfreq & 0x7f); 204 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 205 | } 206 | 207 | void M5UnitSynth::setTuning(uint8_t channel, uint8_t fine, uint8_t coarse) { 208 | uint8_t CMD_CONTROL_CHANGE[] = { 209 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 210 | 0x65, 211 | 0x00, 212 | 0x64, 213 | 0x01, 214 | 0x06, 215 | (uint8_t)(fine & 0x7f)}; 216 | 217 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 218 | 219 | CMD_CONTROL_CHANGE[4] = 0x02; 220 | CMD_CONTROL_CHANGE[6] = (coarse & 0x7f); 221 | 222 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 223 | } 224 | void M5UnitSynth::setVibrate(uint8_t channel, uint8_t rate, uint8_t depth, 225 | uint8_t delay) { 226 | uint8_t CMD_CONTROL_CHANGE[] = { 227 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 228 | 0x63, 229 | 0x01, 230 | 0x62, 231 | 0x08, 232 | 0x06, 233 | (uint8_t)(rate & 0x7f)}; 234 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 235 | 236 | CMD_CONTROL_CHANGE[4] = 0x09; 237 | CMD_CONTROL_CHANGE[6] = (depth & 0x7f); 238 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 239 | 240 | CMD_CONTROL_CHANGE[4] = 0x0A; 241 | CMD_CONTROL_CHANGE[6] = (delay & 0x7f); 242 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 243 | } 244 | 245 | void M5UnitSynth::setTvf(uint8_t channel, uint8_t cutoff, uint8_t resonance) { 246 | uint8_t CMD_CONTROL_CHANGE[] = { 247 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 248 | 0x63, 249 | 0x01, 250 | 0x62, 251 | 0x20, 252 | 0x06, 253 | (uint8_t)(cutoff & 0x7f)}; 254 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 255 | 256 | CMD_CONTROL_CHANGE[4] = 0x21; 257 | CMD_CONTROL_CHANGE[6] = (resonance & 0x7f); 258 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 259 | } 260 | void M5UnitSynth::setEnvelope(uint8_t channel, uint8_t attack, uint8_t decay, 261 | uint8_t release) { 262 | uint8_t CMD_CONTROL_CHANGE[] = { 263 | 264 | (uint8_t)(MIDI_CMD_CONTROL_CHANGE | (channel & 0x0f)), 265 | 0x63, 266 | 0x01, 267 | 0x62, 268 | 0x63, 269 | 0x06, 270 | (uint8_t)(attack & 0x7f)}; 271 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 272 | 273 | CMD_CONTROL_CHANGE[4] = 0x64; 274 | CMD_CONTROL_CHANGE[6] = (decay & 0x7f); 275 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 276 | 277 | CMD_CONTROL_CHANGE[4] = 0x66; 278 | CMD_CONTROL_CHANGE[6] = (release & 0x7f); 279 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 280 | } 281 | 282 | void M5UnitSynth::setModWheel(uint8_t channel, uint8_t pitch, uint8_t tvtcutoff, 283 | uint8_t amplitude, uint8_t rate, 284 | uint8_t pitchdepth, uint8_t tvfdepth, 285 | uint8_t tvadepth) { 286 | uint8_t CMD_CONTROL_CHANGE[] = {MIDI_CMD_CONTROL_CHANGE, 287 | 0x41, 288 | 0x00, 289 | 0x42, 290 | 0x12, 291 | 0x40, 292 | (uint8_t)(0x20 | (channel & 0x0f)), 293 | 0x00, 294 | pitch, 295 | 0x00, 296 | MIDI_CMD_END_OF_SYSEX}; 297 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 298 | 299 | CMD_CONTROL_CHANGE[8] = 0x01; 300 | CMD_CONTROL_CHANGE[9] = tvtcutoff; 301 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 302 | 303 | CMD_CONTROL_CHANGE[8] = 0x02; 304 | CMD_CONTROL_CHANGE[9] = amplitude; 305 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 306 | 307 | CMD_CONTROL_CHANGE[8] = 0x03; 308 | CMD_CONTROL_CHANGE[9] = rate; 309 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 310 | 311 | CMD_CONTROL_CHANGE[8] = 0x04; 312 | CMD_CONTROL_CHANGE[9] = pitchdepth; 313 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 314 | 315 | CMD_CONTROL_CHANGE[8] = 0x05; 316 | CMD_CONTROL_CHANGE[9] = tvfdepth; 317 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 318 | 319 | CMD_CONTROL_CHANGE[8] = 0x06; 320 | CMD_CONTROL_CHANGE[9] = tvadepth; 321 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 322 | } 323 | 324 | void M5UnitSynth::setAllInstrumentDrums() { 325 | uint8_t CMD_CONTROL_CHANGE[] = {MIDI_CMD_CONTROL_CHANGE, 326 | 0x41, 327 | 0x00, 328 | 0x42, 329 | 0x12, 330 | 0x40, 331 | 0x10, 332 | 0x15, 333 | 0x01, 334 | 0x00, 335 | MIDI_CMD_END_OF_SYSEX}; 336 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 337 | 338 | for (uint8_t i = 1; i < 15; i++) { 339 | CMD_CONTROL_CHANGE[6] = i; 340 | sendCMD(CMD_CONTROL_CHANGE, sizeof(CMD_CONTROL_CHANGE)); 341 | } 342 | } 343 | 344 | void M5UnitSynth::reset() { 345 | uint8_t CMD_SYSTEM_RESET[] = {MIDI_CMD_SYSTEM_RESET}; 346 | sendCMD(CMD_SYSTEM_RESET, sizeof(CMD_SYSTEM_RESET)); 347 | } 348 | -------------------------------------------------------------------------------- /examples/FurElise/melody.h: -------------------------------------------------------------------------------- 1 | // notes of the moledy followed by the duration. 2 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 3 | // !!negative numbers are used to represent dotted notes, 4 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 5 | 6 | #include "M5UnitSynth.h" 7 | 8 | const int melody[] PROGMEM = { 9 | 10 | // Fur Elise - Ludwig van Beethovem 11 | // Score available at https://musescore.com/user/28149610/scores/5281944 12 | 13 | // starts from 1 ending on 9 14 | NOTE_E5, 15 | 16, 16 | NOTE_DS5, 17 | 16, // 1 18 | NOTE_E5, 19 | 16, 20 | NOTE_DS5, 21 | 16, 22 | NOTE_E5, 23 | 16, 24 | NOTE_B4, 25 | 16, 26 | NOTE_D5, 27 | 16, 28 | NOTE_C5, 29 | 16, 30 | NOTE_A4, 31 | -8, 32 | NOTE_C4, 33 | 16, 34 | NOTE_E4, 35 | 16, 36 | NOTE_A4, 37 | 16, 38 | NOTE_B4, 39 | -8, 40 | NOTE_E4, 41 | 16, 42 | NOTE_GS4, 43 | 16, 44 | NOTE_B4, 45 | 16, 46 | NOTE_C5, 47 | 8, 48 | REST, 49 | 16, 50 | NOTE_E4, 51 | 16, 52 | NOTE_E5, 53 | 16, 54 | NOTE_DS5, 55 | 16, 56 | 57 | NOTE_E5, 58 | 16, 59 | NOTE_DS5, 60 | 16, 61 | NOTE_E5, 62 | 16, 63 | NOTE_B4, 64 | 16, 65 | NOTE_D5, 66 | 16, 67 | NOTE_C5, 68 | 16, // 6 69 | NOTE_A4, 70 | -8, 71 | NOTE_C4, 72 | 16, 73 | NOTE_E4, 74 | 16, 75 | NOTE_A4, 76 | 16, 77 | NOTE_B4, 78 | -8, 79 | NOTE_E4, 80 | 16, 81 | NOTE_C5, 82 | 16, 83 | NOTE_B4, 84 | 16, 85 | NOTE_A4, 86 | 4, 87 | REST, 88 | 8, // 9 - 1st ending 89 | 90 | // repaets from 1 ending on 10 91 | NOTE_E5, 92 | 16, 93 | NOTE_DS5, 94 | 16, // 1 95 | NOTE_E5, 96 | 16, 97 | NOTE_DS5, 98 | 16, 99 | NOTE_E5, 100 | 16, 101 | NOTE_B4, 102 | 16, 103 | NOTE_D5, 104 | 16, 105 | NOTE_C5, 106 | 16, 107 | NOTE_A4, 108 | -8, 109 | NOTE_C4, 110 | 16, 111 | NOTE_E4, 112 | 16, 113 | NOTE_A4, 114 | 16, 115 | NOTE_B4, 116 | -8, 117 | NOTE_E4, 118 | 16, 119 | NOTE_GS4, 120 | 16, 121 | NOTE_B4, 122 | 16, 123 | NOTE_C5, 124 | 8, 125 | REST, 126 | 16, 127 | NOTE_E4, 128 | 16, 129 | NOTE_E5, 130 | 16, 131 | NOTE_DS5, 132 | 16, 133 | 134 | NOTE_E5, 135 | 16, 136 | NOTE_DS5, 137 | 16, 138 | NOTE_E5, 139 | 16, 140 | NOTE_B4, 141 | 16, 142 | NOTE_D5, 143 | 16, 144 | NOTE_C5, 145 | 16, // 6 146 | NOTE_A4, 147 | -8, 148 | NOTE_C4, 149 | 16, 150 | NOTE_E4, 151 | 16, 152 | NOTE_A4, 153 | 16, 154 | NOTE_B4, 155 | -8, 156 | NOTE_E4, 157 | 16, 158 | NOTE_C5, 159 | 16, 160 | NOTE_B4, 161 | 16, 162 | NOTE_A4, 163 | 8, 164 | REST, 165 | 16, 166 | NOTE_B4, 167 | 16, 168 | NOTE_C5, 169 | 16, 170 | NOTE_D5, 171 | 16, // 10 - 2nd ending 172 | // continues from 11 173 | NOTE_E5, 174 | -8, 175 | NOTE_G4, 176 | 16, 177 | NOTE_F5, 178 | 16, 179 | NOTE_E5, 180 | 16, 181 | NOTE_D5, 182 | -8, 183 | NOTE_F4, 184 | 16, 185 | NOTE_E5, 186 | 16, 187 | NOTE_D5, 188 | 16, // 12 189 | 190 | NOTE_C5, 191 | -8, 192 | NOTE_E4, 193 | 16, 194 | NOTE_D5, 195 | 16, 196 | NOTE_C5, 197 | 16, // 13 198 | NOTE_B4, 199 | 8, 200 | REST, 201 | 16, 202 | NOTE_E4, 203 | 16, 204 | NOTE_E5, 205 | 16, 206 | REST, 207 | 16, 208 | REST, 209 | 16, 210 | NOTE_E5, 211 | 16, 212 | NOTE_E6, 213 | 16, 214 | REST, 215 | 16, 216 | REST, 217 | 16, 218 | NOTE_DS5, 219 | 16, 220 | NOTE_E5, 221 | 16, 222 | REST, 223 | 16, 224 | REST, 225 | 16, 226 | NOTE_DS5, 227 | 16, 228 | NOTE_E5, 229 | 16, 230 | NOTE_DS5, 231 | 16, 232 | NOTE_E5, 233 | 16, 234 | NOTE_DS5, 235 | 16, 236 | NOTE_E5, 237 | 16, 238 | NOTE_B4, 239 | 16, 240 | NOTE_D5, 241 | 16, 242 | NOTE_C5, 243 | 16, 244 | NOTE_A4, 245 | 8, 246 | REST, 247 | 16, 248 | NOTE_C4, 249 | 16, 250 | NOTE_E4, 251 | 16, 252 | NOTE_A4, 253 | 16, 254 | 255 | NOTE_B4, 256 | 8, 257 | REST, 258 | 16, 259 | NOTE_E4, 260 | 16, 261 | NOTE_GS4, 262 | 16, 263 | NOTE_B4, 264 | 16, // 19 265 | NOTE_C5, 266 | 8, 267 | REST, 268 | 16, 269 | NOTE_E4, 270 | 16, 271 | NOTE_E5, 272 | 16, 273 | NOTE_DS5, 274 | 16, 275 | NOTE_E5, 276 | 16, 277 | NOTE_DS5, 278 | 16, 279 | NOTE_E5, 280 | 16, 281 | NOTE_B4, 282 | 16, 283 | NOTE_D5, 284 | 16, 285 | NOTE_C5, 286 | 16, 287 | NOTE_A4, 288 | 8, 289 | REST, 290 | 16, 291 | NOTE_C4, 292 | 16, 293 | NOTE_E4, 294 | 16, 295 | NOTE_A4, 296 | 16, 297 | NOTE_B4, 298 | 8, 299 | REST, 300 | 16, 301 | NOTE_E4, 302 | 16, 303 | NOTE_C5, 304 | 16, 305 | NOTE_B4, 306 | 16, 307 | NOTE_A4, 308 | 8, 309 | REST, 310 | 16, 311 | NOTE_B4, 312 | 16, 313 | NOTE_C5, 314 | 16, 315 | NOTE_D5, 316 | 16, // 24 (1st ending) 317 | 318 | // repeats from 11 319 | NOTE_E5, 320 | -8, 321 | NOTE_G4, 322 | 16, 323 | NOTE_F5, 324 | 16, 325 | NOTE_E5, 326 | 16, 327 | NOTE_D5, 328 | -8, 329 | NOTE_F4, 330 | 16, 331 | NOTE_E5, 332 | 16, 333 | NOTE_D5, 334 | 16, // 12 335 | 336 | NOTE_C5, 337 | -8, 338 | NOTE_E4, 339 | 16, 340 | NOTE_D5, 341 | 16, 342 | NOTE_C5, 343 | 16, // 13 344 | NOTE_B4, 345 | 8, 346 | REST, 347 | 16, 348 | NOTE_E4, 349 | 16, 350 | NOTE_E5, 351 | 16, 352 | REST, 353 | 16, 354 | REST, 355 | 16, 356 | NOTE_E5, 357 | 16, 358 | NOTE_E6, 359 | 16, 360 | REST, 361 | 16, 362 | REST, 363 | 16, 364 | NOTE_DS5, 365 | 16, 366 | NOTE_E5, 367 | 16, 368 | REST, 369 | 16, 370 | REST, 371 | 16, 372 | NOTE_DS5, 373 | 16, 374 | NOTE_E5, 375 | 16, 376 | NOTE_DS5, 377 | 16, 378 | NOTE_E5, 379 | 16, 380 | NOTE_DS5, 381 | 16, 382 | NOTE_E5, 383 | 16, 384 | NOTE_B4, 385 | 16, 386 | NOTE_D5, 387 | 16, 388 | NOTE_C5, 389 | 16, 390 | NOTE_A4, 391 | 8, 392 | REST, 393 | 16, 394 | NOTE_C4, 395 | 16, 396 | NOTE_E4, 397 | 16, 398 | NOTE_A4, 399 | 16, 400 | 401 | NOTE_B4, 402 | 8, 403 | REST, 404 | 16, 405 | NOTE_E4, 406 | 16, 407 | NOTE_GS4, 408 | 16, 409 | NOTE_B4, 410 | 16, // 19 411 | NOTE_C5, 412 | 8, 413 | REST, 414 | 16, 415 | NOTE_E4, 416 | 16, 417 | NOTE_E5, 418 | 16, 419 | NOTE_DS5, 420 | 16, 421 | NOTE_E5, 422 | 16, 423 | NOTE_DS5, 424 | 16, 425 | NOTE_E5, 426 | 16, 427 | NOTE_B4, 428 | 16, 429 | NOTE_D5, 430 | 16, 431 | NOTE_C5, 432 | 16, 433 | NOTE_A4, 434 | 8, 435 | REST, 436 | 16, 437 | NOTE_C4, 438 | 16, 439 | NOTE_E4, 440 | 16, 441 | NOTE_A4, 442 | 16, 443 | NOTE_B4, 444 | 8, 445 | REST, 446 | 16, 447 | NOTE_E4, 448 | 16, 449 | NOTE_C5, 450 | 16, 451 | NOTE_B4, 452 | 16, 453 | NOTE_A4, 454 | 8, 455 | REST, 456 | 16, 457 | NOTE_C5, 458 | 16, 459 | NOTE_C5, 460 | 16, 461 | NOTE_C5, 462 | 16, // 25 - 2nd ending 463 | 464 | // continues from 26 465 | NOTE_C5, 466 | 4, 467 | NOTE_F5, 468 | -16, 469 | NOTE_E5, 470 | 32, // 26 471 | NOTE_E5, 472 | 8, 473 | NOTE_D5, 474 | 8, 475 | NOTE_AS5, 476 | -16, 477 | NOTE_A5, 478 | 32, 479 | NOTE_A5, 480 | 16, 481 | NOTE_G5, 482 | 16, 483 | NOTE_F5, 484 | 16, 485 | NOTE_E5, 486 | 16, 487 | NOTE_D5, 488 | 16, 489 | NOTE_C5, 490 | 16, 491 | NOTE_AS4, 492 | 8, 493 | NOTE_A4, 494 | 8, 495 | NOTE_A4, 496 | 32, 497 | NOTE_G4, 498 | 32, 499 | NOTE_A4, 500 | 32, 501 | NOTE_B4, 502 | 32, 503 | NOTE_C5, 504 | 4, 505 | NOTE_D5, 506 | 16, 507 | NOTE_DS5, 508 | 16, 509 | NOTE_E5, 510 | -8, 511 | NOTE_E5, 512 | 16, 513 | NOTE_F5, 514 | 16, 515 | NOTE_A4, 516 | 16, 517 | NOTE_C5, 518 | 4, 519 | NOTE_D5, 520 | -16, 521 | NOTE_B4, 522 | 32, 523 | 524 | NOTE_C5, 525 | 32, 526 | NOTE_G5, 527 | 32, 528 | NOTE_G4, 529 | 32, 530 | NOTE_G5, 531 | 32, 532 | NOTE_A4, 533 | 32, 534 | NOTE_G5, 535 | 32, 536 | NOTE_B4, 537 | 32, 538 | NOTE_G5, 539 | 32, 540 | NOTE_C5, 541 | 32, 542 | NOTE_G5, 543 | 32, 544 | NOTE_D5, 545 | 32, 546 | NOTE_G5, 547 | 32, // 33 548 | NOTE_E5, 549 | 32, 550 | NOTE_G5, 551 | 32, 552 | NOTE_C6, 553 | 32, 554 | NOTE_B5, 555 | 32, 556 | NOTE_A5, 557 | 32, 558 | NOTE_G5, 559 | 32, 560 | NOTE_F5, 561 | 32, 562 | NOTE_E5, 563 | 32, 564 | NOTE_D5, 565 | 32, 566 | NOTE_G5, 567 | 32, 568 | NOTE_F5, 569 | 32, 570 | NOTE_D5, 571 | 32, 572 | NOTE_C5, 573 | 32, 574 | NOTE_G5, 575 | 32, 576 | NOTE_G4, 577 | 32, 578 | NOTE_G5, 579 | 32, 580 | NOTE_A4, 581 | 32, 582 | NOTE_G5, 583 | 32, 584 | NOTE_B4, 585 | 32, 586 | NOTE_G5, 587 | 32, 588 | NOTE_C5, 589 | 32, 590 | NOTE_G5, 591 | 32, 592 | NOTE_D5, 593 | 32, 594 | NOTE_G5, 595 | 32, 596 | 597 | NOTE_E5, 598 | 32, 599 | NOTE_G5, 600 | 32, 601 | NOTE_C6, 602 | 32, 603 | NOTE_B5, 604 | 32, 605 | NOTE_A5, 606 | 32, 607 | NOTE_G5, 608 | 32, 609 | NOTE_F5, 610 | 32, 611 | NOTE_E5, 612 | 32, 613 | NOTE_D5, 614 | 32, 615 | NOTE_G5, 616 | 32, 617 | NOTE_F5, 618 | 32, 619 | NOTE_D5, 620 | 32, // 36 621 | NOTE_E5, 622 | 32, 623 | NOTE_F5, 624 | 32, 625 | NOTE_E5, 626 | 32, 627 | NOTE_DS5, 628 | 32, 629 | NOTE_E5, 630 | 32, 631 | NOTE_B4, 632 | 32, 633 | NOTE_E5, 634 | 32, 635 | NOTE_DS5, 636 | 32, 637 | NOTE_E5, 638 | 32, 639 | NOTE_B4, 640 | 32, 641 | NOTE_E5, 642 | 32, 643 | NOTE_DS5, 644 | 32, 645 | NOTE_E5, 646 | -8, 647 | NOTE_B4, 648 | 16, 649 | NOTE_E5, 650 | 16, 651 | NOTE_DS5, 652 | 16, 653 | NOTE_E5, 654 | -8, 655 | NOTE_B4, 656 | 16, 657 | NOTE_E5, 658 | 16, 659 | REST, 660 | 16, 661 | 662 | REST, 663 | 16, 664 | NOTE_DS5, 665 | 16, 666 | NOTE_E5, 667 | 16, 668 | REST, 669 | 16, 670 | REST, 671 | 16, 672 | NOTE_DS5, 673 | 16, // 40 674 | NOTE_E5, 675 | 16, 676 | NOTE_DS5, 677 | 16, 678 | NOTE_E5, 679 | 16, 680 | NOTE_B4, 681 | 16, 682 | NOTE_D5, 683 | 16, 684 | NOTE_C5, 685 | 16, 686 | NOTE_A4, 687 | 8, 688 | REST, 689 | 16, 690 | NOTE_C4, 691 | 16, 692 | NOTE_E4, 693 | 16, 694 | NOTE_A4, 695 | 16, 696 | NOTE_B4, 697 | 8, 698 | REST, 699 | 16, 700 | NOTE_E4, 701 | 16, 702 | NOTE_GS4, 703 | 16, 704 | NOTE_B4, 705 | 16, 706 | NOTE_C5, 707 | 8, 708 | REST, 709 | 16, 710 | NOTE_E4, 711 | 16, 712 | NOTE_E5, 713 | 16, 714 | NOTE_DS5, 715 | 16, 716 | NOTE_E5, 717 | 16, 718 | NOTE_DS5, 719 | 16, 720 | NOTE_E5, 721 | 16, 722 | NOTE_B4, 723 | 16, 724 | NOTE_D5, 725 | 16, 726 | NOTE_C5, 727 | 16, 728 | 729 | NOTE_A4, 730 | 8, 731 | REST, 732 | 16, 733 | NOTE_C4, 734 | 16, 735 | NOTE_E4, 736 | 16, 737 | NOTE_A4, 738 | 16, // 46 739 | NOTE_B4, 740 | 8, 741 | REST, 742 | 16, 743 | NOTE_E4, 744 | 16, 745 | NOTE_C5, 746 | 16, 747 | NOTE_B4, 748 | 16, 749 | NOTE_A4, 750 | 8, 751 | REST, 752 | 16, 753 | NOTE_B4, 754 | 16, 755 | NOTE_C5, 756 | 16, 757 | NOTE_D5, 758 | 16, 759 | NOTE_E5, 760 | -8, 761 | NOTE_G4, 762 | 16, 763 | NOTE_F5, 764 | 16, 765 | NOTE_E5, 766 | 16, 767 | NOTE_D5, 768 | -8, 769 | NOTE_F4, 770 | 16, 771 | NOTE_E5, 772 | 16, 773 | NOTE_D5, 774 | 16, 775 | NOTE_C5, 776 | -8, 777 | NOTE_E4, 778 | 16, 779 | NOTE_D5, 780 | 16, 781 | NOTE_C5, 782 | 16, 783 | NOTE_B4, 784 | 8, 785 | REST, 786 | 16, 787 | NOTE_E4, 788 | 16, 789 | NOTE_E5, 790 | 16, 791 | REST, 792 | 16, 793 | REST, 794 | 16, 795 | NOTE_E5, 796 | 16, 797 | NOTE_E6, 798 | 16, 799 | REST, 800 | 16, 801 | REST, 802 | 16, 803 | NOTE_DS5, 804 | 16, 805 | 806 | NOTE_E5, 807 | 16, 808 | REST, 809 | 16, 810 | REST, 811 | 16, 812 | NOTE_DS5, 813 | 16, 814 | NOTE_E5, 815 | 16, 816 | NOTE_D5, 817 | 16, // 54 818 | NOTE_E5, 819 | 16, 820 | NOTE_DS5, 821 | 16, 822 | NOTE_E5, 823 | 16, 824 | NOTE_B4, 825 | 16, 826 | NOTE_D5, 827 | 16, 828 | NOTE_C5, 829 | 16, 830 | NOTE_A4, 831 | 8, 832 | REST, 833 | 16, 834 | NOTE_C4, 835 | 16, 836 | NOTE_E4, 837 | 16, 838 | NOTE_A4, 839 | 16, 840 | NOTE_B4, 841 | 8, 842 | REST, 843 | 16, 844 | NOTE_E4, 845 | 16, 846 | NOTE_GS4, 847 | 16, 848 | NOTE_B4, 849 | 16, 850 | NOTE_C5, 851 | 8, 852 | REST, 853 | 16, 854 | NOTE_E4, 855 | 16, 856 | NOTE_E5, 857 | 16, 858 | NOTE_DS5, 859 | 16, 860 | NOTE_E5, 861 | 16, 862 | NOTE_DS5, 863 | 16, 864 | NOTE_E5, 865 | 16, 866 | NOTE_B4, 867 | 16, 868 | NOTE_D5, 869 | 16, 870 | NOTE_C5, 871 | 16, 872 | 873 | NOTE_A4, 874 | 8, 875 | REST, 876 | 16, 877 | NOTE_C4, 878 | 16, 879 | NOTE_E4, 880 | 16, 881 | NOTE_A4, 882 | 16, // 60 883 | NOTE_B4, 884 | 8, 885 | REST, 886 | 16, 887 | NOTE_E4, 888 | 16, 889 | NOTE_C5, 890 | 16, 891 | NOTE_B4, 892 | 16, 893 | NOTE_A4, 894 | 8, 895 | REST, 896 | 16, 897 | REST, 898 | 16, 899 | REST, 900 | 8, 901 | NOTE_CS5, 902 | -4, 903 | NOTE_D5, 904 | 4, 905 | NOTE_E5, 906 | 16, 907 | NOTE_F5, 908 | 16, 909 | NOTE_F5, 910 | 4, 911 | NOTE_F5, 912 | 8, 913 | NOTE_E5, 914 | -4, 915 | NOTE_D5, 916 | 4, 917 | NOTE_C5, 918 | 16, 919 | NOTE_B4, 920 | 16, 921 | NOTE_A4, 922 | 4, 923 | NOTE_A4, 924 | 8, 925 | NOTE_A4, 926 | 8, 927 | NOTE_C5, 928 | 8, 929 | NOTE_B4, 930 | 8, 931 | NOTE_A4, 932 | -4, 933 | NOTE_CS5, 934 | -4, 935 | 936 | NOTE_D5, 937 | 4, 938 | NOTE_E5, 939 | 16, 940 | NOTE_F5, 941 | 16, // 72 942 | NOTE_F5, 943 | 4, 944 | NOTE_F5, 945 | 8, 946 | NOTE_F5, 947 | -4, 948 | NOTE_DS5, 949 | 4, 950 | NOTE_D5, 951 | 16, 952 | NOTE_C5, 953 | 16, 954 | NOTE_AS4, 955 | 4, 956 | NOTE_A4, 957 | 8, 958 | NOTE_GS4, 959 | 4, 960 | NOTE_G4, 961 | 8, 962 | NOTE_A4, 963 | -4, 964 | NOTE_B4, 965 | 4, 966 | REST, 967 | 8, 968 | NOTE_A3, 969 | -32, 970 | NOTE_C4, 971 | -32, 972 | NOTE_E4, 973 | -32, 974 | NOTE_A4, 975 | -32, 976 | NOTE_C5, 977 | -32, 978 | NOTE_E5, 979 | -32, 980 | NOTE_D5, 981 | -32, 982 | NOTE_C5, 983 | -32, 984 | NOTE_B4, 985 | -32, 986 | 987 | NOTE_A4, 988 | -32, 989 | NOTE_C5, 990 | -32, 991 | NOTE_E5, 992 | -32, 993 | NOTE_A5, 994 | -32, 995 | NOTE_C6, 996 | -32, 997 | NOTE_E6, 998 | -32, 999 | NOTE_D6, 1000 | -32, 1001 | NOTE_C6, 1002 | -32, 1003 | NOTE_B5, 1004 | -32, // 80 1005 | NOTE_A4, 1006 | -32, 1007 | NOTE_C5, 1008 | -32, 1009 | NOTE_E5, 1010 | -32, 1011 | NOTE_A5, 1012 | -32, 1013 | NOTE_C6, 1014 | -32, 1015 | NOTE_E6, 1016 | -32, 1017 | NOTE_D6, 1018 | -32, 1019 | NOTE_C6, 1020 | -32, 1021 | NOTE_B5, 1022 | -32, 1023 | NOTE_AS5, 1024 | -32, 1025 | NOTE_A5, 1026 | -32, 1027 | NOTE_GS5, 1028 | -32, 1029 | NOTE_G5, 1030 | -32, 1031 | NOTE_FS5, 1032 | -32, 1033 | NOTE_F5, 1034 | -32, 1035 | NOTE_E5, 1036 | -32, 1037 | NOTE_DS5, 1038 | -32, 1039 | NOTE_D5, 1040 | -32, 1041 | 1042 | NOTE_CS5, 1043 | -32, 1044 | NOTE_C5, 1045 | -32, 1046 | NOTE_B4, 1047 | -32, 1048 | NOTE_AS4, 1049 | -32, 1050 | NOTE_A4, 1051 | -32, 1052 | NOTE_GS4, 1053 | -32, 1054 | NOTE_G4, 1055 | -32, 1056 | NOTE_FS4, 1057 | -32, 1058 | NOTE_F4, 1059 | -32, // 84 1060 | NOTE_E4, 1061 | 16, 1062 | NOTE_DS5, 1063 | 16, 1064 | NOTE_E5, 1065 | 16, 1066 | NOTE_B4, 1067 | 16, 1068 | NOTE_D5, 1069 | 16, 1070 | NOTE_C5, 1071 | 16, 1072 | NOTE_A4, 1073 | -8, 1074 | NOTE_C4, 1075 | 16, 1076 | NOTE_E4, 1077 | 16, 1078 | NOTE_A4, 1079 | 16, 1080 | NOTE_B4, 1081 | -8, 1082 | NOTE_E4, 1083 | 16, 1084 | NOTE_GS4, 1085 | 16, 1086 | NOTE_B4, 1087 | 16, 1088 | 1089 | NOTE_C5, 1090 | 8, 1091 | REST, 1092 | 16, 1093 | NOTE_E4, 1094 | 16, 1095 | NOTE_E5, 1096 | 16, 1097 | NOTE_DS5, 1098 | 16, // 88 1099 | NOTE_E5, 1100 | 16, 1101 | NOTE_DS5, 1102 | 16, 1103 | NOTE_E5, 1104 | 16, 1105 | NOTE_B4, 1106 | 16, 1107 | NOTE_D5, 1108 | 16, 1109 | NOTE_C5, 1110 | 16, 1111 | NOTE_A4, 1112 | -8, 1113 | NOTE_C4, 1114 | 16, 1115 | NOTE_E4, 1116 | 16, 1117 | NOTE_A4, 1118 | 16, 1119 | NOTE_B4, 1120 | -8, 1121 | NOTE_E4, 1122 | 16, 1123 | NOTE_C5, 1124 | 16, 1125 | NOTE_B4, 1126 | 16, 1127 | NOTE_A4, 1128 | -8, 1129 | REST, 1130 | -8, 1131 | REST, 1132 | -8, 1133 | NOTE_G4, 1134 | 16, 1135 | NOTE_F5, 1136 | 16, 1137 | NOTE_E5, 1138 | 16, 1139 | NOTE_D5, 1140 | 4, 1141 | REST, 1142 | 8, 1143 | REST, 1144 | -8, 1145 | NOTE_E4, 1146 | 16, 1147 | NOTE_D5, 1148 | 16, 1149 | NOTE_C5, 1150 | 16, 1151 | 1152 | NOTE_B4, 1153 | -8, 1154 | NOTE_E4, 1155 | 16, 1156 | NOTE_E5, 1157 | 8, // 96 1158 | NOTE_E5, 1159 | 8, 1160 | NOTE_E6, 1161 | -8, 1162 | NOTE_DS5, 1163 | 16, 1164 | NOTE_E5, 1165 | 16, 1166 | REST, 1167 | 16, 1168 | REST, 1169 | 16, 1170 | NOTE_DS5, 1171 | 16, 1172 | NOTE_E5, 1173 | 16, 1174 | NOTE_DS5, 1175 | 16, 1176 | NOTE_E5, 1177 | 16, 1178 | NOTE_DS5, 1179 | 16, 1180 | NOTE_E5, 1181 | 16, 1182 | NOTE_B4, 1183 | 16, 1184 | NOTE_D5, 1185 | 16, 1186 | NOTE_C5, 1187 | 16, 1188 | NOTE_A4, 1189 | -8, 1190 | NOTE_C4, 1191 | 16, 1192 | NOTE_E4, 1193 | 16, 1194 | NOTE_A4, 1195 | 16, 1196 | NOTE_B4, 1197 | -8, 1198 | NOTE_E4, 1199 | 16, 1200 | NOTE_GS4, 1201 | 16, 1202 | NOTE_B4, 1203 | 16, 1204 | 1205 | NOTE_C5, 1206 | 8, 1207 | REST, 1208 | 16, 1209 | NOTE_E4, 1210 | 16, 1211 | NOTE_E5, 1212 | 16, 1213 | NOTE_DS5, 1214 | 16, // 102 1215 | NOTE_E5, 1216 | 16, 1217 | NOTE_DS5, 1218 | 16, 1219 | NOTE_E5, 1220 | 16, 1221 | NOTE_B4, 1222 | 16, 1223 | NOTE_D5, 1224 | 16, 1225 | NOTE_C5, 1226 | 16, 1227 | NOTE_A4, 1228 | -8, 1229 | NOTE_C4, 1230 | 16, 1231 | NOTE_E4, 1232 | 16, 1233 | NOTE_A4, 1234 | 16, 1235 | NOTE_B4, 1236 | -8, 1237 | NOTE_E4, 1238 | 16, 1239 | NOTE_C5, 1240 | 16, 1241 | NOTE_B4, 1242 | 16, 1243 | NOTE_A4, 1244 | -4, 1245 | }; --------------------------------------------------------------------------------