|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- #include <Audio.h>
- #include <Wire.h>
- #include <SPI.h>
- #include <SD.h>
- #include <SerialFlash.h>
- #include <Bounce.h>
-
-
- #include "AudioSampleSnare.h"
- #include "AudioSampleTomtom.h"
- #include "AudioSampleHihat.h"
- #include "AudioSampleKick.h"
- #include "AudioSampleGong.h"
- #include "AudioSampleCashregister.h"
-
-
-
-
- AudioPlayMemory sound0;
- AudioPlayMemory sound1;
- AudioPlayMemory sound2;
- AudioPlayMemory sound3;
- AudioPlayMemory sound4;
- AudioPlayMemory sound5;
- AudioMixer4 mix1;
- AudioMixer4 mix2;
- AudioOutputI2S headphones;
- AudioOutputAnalog dac;
-
-
-
- AudioConnection c1(sound0, 0, mix1, 0);
- AudioConnection c2(sound1, 0, mix1, 1);
- AudioConnection c3(sound2, 0, mix1, 2);
- AudioConnection c4(sound3, 0, mix1, 3);
- AudioConnection c5(mix1, 0, mix2, 0);
- AudioConnection c6(sound4, 0, mix2, 1);
- AudioConnection c7(sound5, 0, mix2, 2);
- AudioConnection c8(mix2, 0, headphones, 0);
- AudioConnection c9(mix2, 0, headphones, 1);
- AudioConnection c10(mix2, 0, dac, 0);
-
-
-
- AudioControlSGTL5000 audioShield;
-
-
-
- Bounce button0 = Bounce(0, 5);
- Bounce button1 = Bounce(1, 5);
- Bounce button2 = Bounce(2, 5);
- Bounce button3 = Bounce(3, 5);
- Bounce button4 = Bounce(4, 5);
- Bounce button5 = Bounce(5, 5);
-
-
- void setup() {
-
-
- pinMode(0, INPUT_PULLUP);
- pinMode(1, INPUT_PULLUP);
- pinMode(2, INPUT_PULLUP);
- pinMode(3, INPUT_PULLUP);
- pinMode(4, INPUT_PULLUP);
- pinMode(5, INPUT_PULLUP);
-
-
-
- AudioMemory(10);
-
-
- audioShield.enable();
- audioShield.volume(0.5);
-
-
-
-
-
-
-
-
- mix1.gain(0, 0.4);
- mix1.gain(1, 0.4);
- mix1.gain(2, 0.4);
- mix1.gain(3, 0.4);
- mix2.gain(1, 0.4);
- mix2.gain(2, 0.4);
- }
-
- void loop() {
-
- button0.update();
- button1.update();
- button2.update();
- button3.update();
- button4.update();
- button5.update();
-
-
-
-
-
- if (button0.fallingEdge()) {
- sound0.play(AudioSampleSnare);
- }
- if (button1.fallingEdge()) {
- sound1.play(AudioSampleTomtom);
- }
- if (button2.fallingEdge()) {
- sound2.play(AudioSampleHihat);
- }
- if (button3.fallingEdge()) {
- sound3.play(AudioSampleKick);
- }
- if (button4.fallingEdge()) {
-
-
- sound4.play(AudioSampleGong);
- }
- if (button5.fallingEdge()) {
- sound5.play(AudioSampleCashregister);
- }
-
- }
-
|