Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

SimpleDrum.ino 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #include <Audio.h>
  2. #include <Wire.h>
  3. #include <SPI.h>
  4. #include <SD.h>
  5. #include <SerialFlash.h>
  6. #include <synth_simple_drum.h>
  7. #include <Audio.h>
  8. #include <Wire.h>
  9. #include <SPI.h>
  10. #include <SD.h>
  11. #include <SerialFlash.h>
  12. // GUItool: begin automatically generated code
  13. AudioSynthSimpleDrum drum2; //xy=399,244
  14. AudioSynthSimpleDrum drum3; //xy=424,310
  15. AudioSynthSimpleDrum drum1; //xy=431,197
  16. AudioSynthSimpleDrum drum4; //xy=464,374
  17. AudioMixer4 mixer1; //xy=737,265
  18. AudioOutputI2S i2s1; //xy=979,214
  19. AudioConnection patchCord1(drum2, 0, mixer1, 1);
  20. AudioConnection patchCord2(drum3, 0, mixer1, 2);
  21. AudioConnection patchCord3(drum1, 0, mixer1, 0);
  22. AudioConnection patchCord4(drum4, 0, mixer1, 3);
  23. AudioConnection patchCord5(mixer1, 0, i2s1, 0);
  24. AudioConnection patchCord6(mixer1, 0, i2s1, 1);
  25. AudioControlSGTL5000 sgtl5000_1; //xy=930,518
  26. // GUItool: end automatically generated code
  27. static uint32_t next;
  28. void setup() {
  29. // put your setup code here, to run once:
  30. Serial.begin(115200);
  31. // audio library init
  32. AudioMemory(15);
  33. next = millis() + 1000;
  34. AudioNoInterrupts();
  35. drum1.frequency(60);
  36. drum1.length(1500);
  37. drum1.secondMix(0.0);
  38. drum1.pitchMod(0.55);
  39. drum2.frequency(60);
  40. drum2.length(300);
  41. drum2.secondMix(0.0);
  42. drum2.pitchMod(1.0);
  43. drum3.frequency(550);
  44. drum3.length(400);
  45. drum3.secondMix(1.0);
  46. drum3.pitchMod(0.5);
  47. drum4.frequency(1200);
  48. drum4.length(150);
  49. drum4.secondMix(0.0);
  50. drum4.pitchMod(0.0);
  51. sgtl5000_1.enable();
  52. sgtl5000_1.volume(0.5);
  53. AudioInterrupts();
  54. }
  55. void loop() {
  56. // put your main code here, to run repeatedly:
  57. static uint32_t num = 0;
  58. if(millis() == next)
  59. {
  60. next = millis() + 1000;
  61. switch(num % 4)
  62. {
  63. case 0:
  64. drum1.noteOn();
  65. break;
  66. case 1:
  67. drum2.noteOn();
  68. break;
  69. case 2:
  70. drum3.noteOn();
  71. break;
  72. case 3:
  73. drum4.noteOn();
  74. break;
  75. }
  76. num++;
  77. Serial.print("Diagnostics: ");
  78. Serial.print(AudioProcessorUsageMax());
  79. Serial.print(" ");
  80. Serial.println(AudioMemoryUsageMax());
  81. AudioProcessorUsageMaxReset();
  82. }
  83. }