Controlling the GM Program in the S2 Synthesizer
Controlling the GM program in the S2 synthesizer using the Arduino Nano.
Components and supplies
1
Arduino Nano R3
1
Alphanumeric LCD, 16 x 2
Apps and platforms
1
Arduino IDE
Project description
Code
Code for Controlling the GM program in the S2 synthesizer using the Arduino nano
c_cpp
Code for Controlling the GM program in the S2 synthesizer using the Arduino nano
1// Controlling the GM program in the S2 synthesizer using the Arduino nano 2// R. Milewski 3 4#include <MIDI.h> // Add Midi Library 5//Create an instance of the library with default name, serial port and settings 6MIDI_CREATE_DEFAULT_INSTANCE(); 7 8#include <LiquidCrystal.h> 9 10LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 11#define channelPlus 6 12#define channelMinus 7 13#define programPlus 8 14#define programMinus 9 15#define programPlus8 10 16#define programMinus8 A0 17 18 19 20int delayTime = 5; 21int progNr = 1; 22int channNr = 1; 23String instrument[16] = { 24"Piano ", 25"Percusion ", 26"Organ ", 27"Guitar ", 28"Bass ", 29"Strings ", 30"Ensemble ", 31"Brass ", 32"Reed ", 33"Pipe ", 34"Synth Lead ", 35"Synth Pad ", 36"Synth Effects ", 37"Ethnic ", 38"Percussive ", 39"Effects ", 40 }; 41/* 42String instrument[128] = { 43"1 Acoustic Grand Piano", 44"2 Bright Acoustic Piano", 45"3 Electric Grand Piano", 46"4 Honky-tonk Piano", 47"5 Electric Piano 1", 48"6 Electric Piano 2", 49"7 Harpsichord", 50"8 Clavinet", 51"9 Celesta", 52 53"10 Glockenspiel", 54"11 Music Box", 55"12 Vibraphone", 56"13 Marimba", 57"14 Xylophone", 58"15 Tubular Bells", 59"16 Dulcimer", 60"17 Drawbar Organ", 61"18 Percussive Organ", 62"19 Rock Organ", 63"20 Church Organ", 64"21 Reed Organ", 65"22 Accordion", 66"23 Harmonica", 67"24 Tango Accordion", 68"25 Acoustic Guitar (nylon)", 69"26 Acoustic Guitar (steel)", 70"27 Electric Guitar (jazz)", 71"28 Electric Guitar (clean)", 72"29 Electric Guitar (muted)", 73"30 Overdriven Guitar", 74}; 75/* 76"31 Distortion Guitar", 77"32 Guitar Harmonics", 78"33 Acoustic Bass", 79"34 Electric Bass (finger)", 80"35 Electric Bass (pick)", 81"36 Fretless Bass", 82"37 Slap Bass 1", 83"38 Slap Bass 2", 84"39 Synth Bass 1", 85"40 Synth Bass 2", 86"41 Violin", 87"42 Viola", 88"43 Cello", 89"44 Contrabass", 90"45 Tremolo Strings", 91"46 Pizzicato Strings", 92"47 Orchestral Harp", 93"48 Timpani", 94"49 String Ensemble 1", 95"50 String Ensemble 2", 96"51 Synth Strings 1", 97"52 Synth Strings 2", 98"53 Choir Aahs", 99"54 Voice Oohs", 100"55 Synth Choir", 101"56 Orchestra Hit", 102"57 Trumpet" 103"58 Trombone", 104"59 Tuba", 105"60 Muted Trumpet", 106"61 French Horn", 107"62 Brass Section", 108"63 Synth Brass 1", 109"64 Synth Brass 2", 110"65 Soprano Sax", 111"66 Alto Sax", 112"67 Tenor Sax", 113"68 Baritone Sax", 114"69 Oboe", 115"70 English Horn", 116"71 Bassoon", 117"72 Clarinet", 118"73 Piccolo", 119"74 Flute", 120"75 Recorder", 121"76 Pan Flute", 122"77 Blown bottle", 123"78 Shakuhachi", 124"79 Whistle", 125"80 Ocarina81 Lead 1 (square)", 126"82 Lead 2 (sawtooth)", 127"83 Lead 3 (calliope)", 128"84 Lead 4 (chiff)", 129"85 Lead 5 (charang)", 130"86 Lead 6 (voice)", 131"87 Lead 7 (fifths)", 132"88 Lead 8 (bass + lead)", 133"89 Pad 1 (new age)", 134"90 Pad 2 (warm)", 135"91 Pad 3 (polysynth)", 136"92 Pad 4 (choir)", 137"93 Pad 5 (bowed)", 138"94 Pad 6 (metallic)", 139"95 Pad 7 (halo)", 140"96 Pad 8 (sweep)", 141"97 FX 1 (rain)", 142"98 FX 2 (soundtrack)", 143"99 FX 3 (crystal)", 144"100 FX 4 (atmosphere)", 145"101 FX 5 (brightness)", 146"102 FX 6 (goblins)", 147"103 FX 7 (echoes)", 148"104 FX 8 (sci-fi)105 Sitar", 149"106 Banjo", 150"107 Shamisen", 151"108 Koto", 152"109 Kalimba", 153"110 Bagpipe", 154"111 Fiddle", 155"112 Shanai", 156"113 Tinkle Bell", 157"114 Agogo", 158"115 Steel Drums", 159"116 Woodblock", 160"117 Taiko Drum", 161"118 Melodic Tom", 162"119 Synth Drum", 163"120 Reverse Cymbal", 164"121 Guitar Fret Noise", 165"122 Breath Noise", 166"123 Seashore", 167"124 Bird Tweet", 168"125 Telephone Ring", 169"126 Helicopter", 170"127 Applause", 171"128 Gunshot" 172}; 173*/ 174void setup() { 175pinMode(channelPlus,INPUT_PULLUP); 176pinMode(channelMinus,INPUT_PULLUP); 177pinMode(programPlus,INPUT_PULLUP); 178pinMode(programMinus,INPUT_PULLUP); 179pinMode(programPlus8,INPUT_PULLUP); 180pinMode(programMinus8,INPUT_PULLUP); 181 182 MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize the Midi Library. 183 // OMNI sets it to listen to all channels.. MIDI.begin(2) would set it 184 // to respond to notes on channel 2 only. 185 186 lcd.begin(16,2); 187 188delay(1000); 189 190lcd.print(" Helo, GM SYNTH: "); 191delay(1000); 192 193MIDI.sendProgramChange(progNr,channNr); 194wypiszjakikomunikatmidi(); 195 196} 197 198void loop(){ 199MIDI.read(); // Continuously check if Midi data has been received. 200 201if (digitalRead(channelPlus) == LOW) { // sprawdza przycisk zwiekszenia nr kanału 202 203 channNr++; 204 if (channNr > 16) { 205 channNr = 16; 206 MIDI.sendProgramChange(progNr,channNr); 207 wypiszjakikomunikatmidi(); 208 } 209 else { 210 MIDI.sendProgramChange(progNr,channNr); 211 wypiszjakikomunikatmidi(); 212 } 213} 214 215if (digitalRead(channelMinus) == LOW) { 216 channNr--; 217 if (channNr < 1) { 218 channNr = 1; 219 MIDI.sendProgramChange(progNr,channNr); 220 wypiszjakikomunikatmidi(); 221 } 222 else { 223 MIDI.sendProgramChange(progNr,channNr); 224 wypiszjakikomunikatmidi(); 225 } 226} 227 228if (digitalRead(programPlus) == LOW) { 229 progNr++; 230 if (progNr > 128) { 231 progNr = 128; 232 MIDI.sendProgramChange(progNr,channNr); 233 wypiszjakikomunikatmidi(); 234 } 235 else { 236 MIDI.sendProgramChange(progNr,channNr); 237 wypiszjakikomunikatmidi(); 238 } 239} 240 241if (digitalRead(programMinus) == LOW) { 242 progNr--; 243 if (progNr < 1) { 244 progNr = 1; 245 MIDI.sendProgramChange(progNr,channNr); 246 wypiszjakikomunikatmidi(); 247 } 248 else { 249 MIDI.sendProgramChange(progNr,channNr); 250 wypiszjakikomunikatmidi(); 251 } 252} 253if (digitalRead(programPlus8) == LOW) { 254 progNr=progNr + 8; 255 if (progNr > 128) { 256 progNr = 128; 257 MIDI.sendProgramChange(progNr,channNr); 258 wypiszjakikomunikatmidi(); 259 } 260 else { 261 MIDI.sendProgramChange(progNr,channNr); 262 wypiszjakikomunikatmidi(); 263 } 264} 265if (digitalRead(programMinus8) == LOW) { 266 progNr=progNr - 8; 267 if (progNr < 1) { 268 progNr = 1; 269 MIDI.sendProgramChange(progNr,channNr); 270 wypiszjakikomunikatmidi(); 271 } 272 else { 273 MIDI.sendProgramChange(progNr,channNr); 274 wypiszjakikomunikatmidi(); 275 } 276} 277 278} 279 280void wypiszjakikomunikatmidi(){ 281 282lcd.clear(); 283 284lcd.setCursor(0,0); 285lcd.print("MIDI Channel: "); 286lcd.print(channNr); 287 288 289lcd.setCursor(0,1); 290lcd.print(instrument[(progNr-1)/8]); 291lcd.print((progNr-1)%8+1); 292delay(delayTime); 293pauzowanie(); 294} 295 296void pauzowanie(){ 297 int k=millis()/100; 298 while(millis()/100 < k + 6){ 299 MIDI.read(); // Continuously check if Midi data has been received. 300 } 301}
Comments
Only logged in users can leave comments