Guest User

Untitled

a guest
May 25th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. #include <hellodrum.h>
  2. #include <MIDI.h>
  3.  
  4. MIDI_CREATE_DEFAULT_INSTANCE();
  5.  
  6. //Please name your pad and controller.
  7. HelloDrum kick(0);
  8. HelloDrum snare(1);
  9. HelloDrum hihat(2);
  10. HelloDrum hihatControl(3);
  11. HelloDrum ride(4, 5);
  12.  
  13. //Set the DIGITAL pin number to which the button and the LCD are connected.
  14. HelloDrumButton button(6, 7, 8, 9, 10); //(EDIT,UP,DOWN,NEXT,BACK)
  15. HelloDrumLCD lcd(12, 11, 5, 4, 3, 2); //(rs, en, d4, d5, d6, d7)
  16.  
  17.  
  18. void setup() {
  19.  
  20. //If you use Hairless MIDI, you have to comment out the next line.
  21. MIDI.begin(10);
  22. //And uncomment the next two lines. Please set the baud rate of Hairless to 38400.
  23. //MIDI.begin();
  24. //Serial.begin(38400);
  25.  
  26. //Give each pad a name to be displayed on the LCD.
  27. //It is necessary to make the order in exactly the same order as you named the pad first.
  28. kick.settingName("KICK");
  29. snare.settingName("SNARE");
  30. hihat.settingName("HIHAT");
  31. hihatControl.settingName("HIHAT PEDAL");
  32. ride.settingName("RIDE");
  33.  
  34.  
  35. //Load settings from EEPROM.
  36. //It is necessary to make the order in exactly the same order as you named the pad first.
  37. kick.loadMemory();
  38. snare.loadMemory();
  39. hihat.loadMemory();
  40. hihatControl.loadMemory();
  41. ride.loadMemory();
  42. }
  43.  
  44. void loop() {
  45.  
  46. /////////// 1. LCD & SETTING MODE /////////////
  47.  
  48. button.readButtonState();
  49. lcd.show();
  50.  
  51. kick.settingEnable();
  52. snare.settingEnable();
  53. hihat.settingEnable();
  54. hihatControl.settingEnable();
  55. ride.settingEnable();
  56.  
  57.  
  58. ////////// 2. SENSING & SENDING MIDI////////////
  59.  
  60. //Sensing each pad.
  61. kick.singlePiezo();
  62. snare.singlePiezo();
  63. hihat.singlePiezo();
  64. hihatControl.TCRT5000();
  65. ride.cymbal3zone();
  66.  
  67. //Sending MIDI signals.
  68. //KICK//
  69. if (kick.hit == true) {
  70. MIDI.sendNoteOn(kick.note, kick.velocity, 10); //(note, velocity, channel)
  71. MIDI.sendNoteOff(kick.note, 0, 10);
  72. }
  73.  
  74. //SNARE//
  75. if (snare.hit == true) {
  76. MIDI.sendNoteOn(snare.note, snare.velocity, 10); //(note, velocity, channel)
  77. MIDI.sendNoteOff(snare.note, 0, 10);
  78. }
  79.  
  80. //HIHAT//
  81. if (hihat.hit == true) {
  82. //check open or close
  83. //1.open
  84. if (hihatControl.openHH == true) {
  85. MIDI.sendNoteOn(hihat.note, hihat.velocity, 10); //(note of open, velocity, channel)
  86. MIDI.sendNoteOff(hihat.note, 0, 10);
  87. }
  88. //2.close
  89. else {
  90. MIDI.sendNoteOn(hihat.noteCup, hihat.velocity, 10); //(note of close, velocity, channel)
  91. MIDI.sendNoteOff(hihat.noteCup, 0, 10);
  92. }
  93. }
  94.  
  95. //HIHAT CONTROLLER//
  96. //when hihat is closed
  97. if (hihatControl.closeHH == true) {
  98. MIDI.sendNoteOn(hihatControl.note, hihatControl.velocity, 10); //(note of pedal, velocity, channel)
  99. MIDI.sendNoteOff(hihatControl.note, 0, 10);
  100. }
  101.  
  102. //sending state of pedal with controll change
  103. if (hihatControl.moving == true) {
  104. MIDI.sendControlChange(4, hihatControl.pedalCC, 10);
  105. }
  106.  
  107. //RIDE//
  108. //1.bow
  109. if (ride.hit == true) {
  110. MIDI.sendNoteOn(ride.note, ride.velocity, 10); //(note, velocity, channel)
  111. MIDI.sendNoteOff(ride.note, 0, 10);
  112. }
  113.  
  114. //2.edge
  115. else if (ride.hitRim == true) {
  116. MIDI.sendNoteOn(ride.noteRim, ride.velocity, 10); //(note, velocity, channel)
  117. MIDI.sendNoteOff(ride.noteRim, 0, 10);
  118. }
  119.  
  120. //3.cup
  121. else if (ride.hitCup == true) {
  122. MIDI.sendNoteOn(ride.noteCup, ride.velocity, 10); //(note, velocity, channel)
  123. MIDI.sendNoteOff(ride.noteCup, 0, 10);
  124. }
  125.  
  126. //4.choke
  127. if (ride.choke == true) {
  128. MIDI.sendPolyPressure(ride.note, 127, 10);
  129. MIDI.sendPolyPressure(ride.noteRim, 127, 10);
  130. MIDI.sendPolyPressure(ride.noteCup, 127, 10);
  131. MIDI.sendPolyPressure(ride.note, 0, 10);
  132. MIDI.sendPolyPressure(ride.noteRim, 0, 10);
  133. MIDI.sendPolyPressure(ride.noteCup, 0, 10);
  134. }
  135. }
Add Comment
Please, Sign In to add comment