Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: Drum pad

  1. #1
    Member Sandro's Avatar
    Join Date
    Nov 2016
    Rimini - Italy

    Drum pad

    Hi all; using Teensy 3.2 and some and piezo sensors I built a nice drum pad (with touch sensitivity, dalay, filering, ..); now I'd like to improve the machine with more sounds, but of course inner memory is not big enough. I can actually store 8 samples, and the room is over. My code is based on SamplePlayer example (I paste it here just for our convenience):

    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    #include <Bounce.h>
    // WAV files converted to code by wav2sketch
    #include "AudioSampleSnare.h"        //
    #include "AudioSampleTomtom.h"       //
    #include "AudioSampleHihat.h"        //
    #include "AudioSampleKick.h"         //
    #include "AudioSampleGong.h"         //
    #include "AudioSampleCashregister.h" //
    // Create the Audio components.  These should be created in the
    // order data flows, inputs/sources -> processing -> outputs
    AudioPlayMemory    sound0;
    AudioPlayMemory    sound1;  // six memory players, so we can play
    AudioPlayMemory    sound2;  // all six sounds simultaneously
    AudioPlayMemory    sound3;
    AudioPlayMemory    sound4;
    AudioPlayMemory    sound5;
    AudioMixer4        mix1;    // two 4-channel mixers are needed in
    AudioMixer4        mix2;    // tandem to combine 6 audio sources
    AudioOutputI2S     headphones;
    AudioOutputAnalog  dac;     // play to both I2S audio board and on-chip DAC
    // Create Audio connections between the components
    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);   // output of mix1 into 1st input on mix2
    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);
    // Create an object to control the audio shield.
    AudioControlSGTL5000 audioShield;
    // Bounce objects to read six pushbuttons (pins 0-5)
    Bounce button0 = Bounce(0, 5);
    Bounce button1 = Bounce(1, 5);  // 5 ms debounce time
    Bounce button2 = Bounce(2, 5);
    Bounce button3 = Bounce(3, 5);
    Bounce button4 = Bounce(4, 5);
    Bounce button5 = Bounce(5, 5);
    void setup() {
      // Configure the pushbutton pins for pullups.
      // Each button should connect from the pin to GND.
      pinMode(0, INPUT_PULLUP);
      pinMode(1, INPUT_PULLUP);
      pinMode(2, INPUT_PULLUP);
      pinMode(3, INPUT_PULLUP);
      pinMode(4, INPUT_PULLUP);
      pinMode(5, INPUT_PULLUP);
      // Audio connections require memory to work.  For more
      // detailed information, see the MemoryAndCpuUsage example
      // turn on the output
      // by default the Teensy 3.1 DAC uses 3.3Vp-p output
      // if your 3.3V power has noise, switching to the
      // internal 1.2V reference can give you a clean signal
      // reduce the gain on mixer channels, so more than 1
      // sound can play simultaneously without clipping
      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() {
      // Update all the button objects
      // When the buttons are pressed, just start a sound playing.
      // The audio library will play each sound through the mixers
      // so any combination can play simultaneously.
      if (button0.fallingEdge()) {;
      if (button1.fallingEdge()) {;
      if (button2.fallingEdge()) {;
      if (button3.fallingEdge()) {;
      if (button4.fallingEdge()) {
        // comment this line to work with Teensy 3.0.
        // the Gong sound is very long, too much for 3.0's memory;
      if (button5.fallingEdge()) {;
    My idea is to store multiple audio files into an SD card and pull audio files into flash memory when required.. Is it possible? I prefer to keep audio files in memory for playing multiple sounds without problems..
    Thanks a lot!

  2. #2
    Member Sandro's Avatar
    Join Date
    Nov 2016
    Rimini - Italy
    I just bought a W25Q128FV chip, I belive it's a good solution!!
    Post closed!
    Last edited by Sandro; 12-21-2016 at 06:58 PM.

  3. #3
    Hey Sandro, I've got the same problem. Could you explain (and maybe show a photo) how you hooked the W25Q128FV chip to the teensy? I have a teensy 3.5 with the same audio board as you. I am trying to make a miniature steel drum with 30 sensors.

  4. #4
    Member Sandro's Avatar
    Join Date
    Nov 2016
    Rimini - Italy
    Hi Ofishal, you can buy one W25Q128FV in SMD package and solder it on the prepared position of the Audio Adaptor, or buy the traditional DIL8 package and connect its pins to the corresponding pins of the Audio Adaptor; both choices are valid in my experience (I prefer the first).

  5. #5
    Thanks for the reply Sandro, gosh I wasn't sure you were still around since 2016. I'm really struggling trying to add all the sounds I need and have run out of memory. I've been trying to put the sounds on an SD card, but being very inexperienced I can't figure out how to do that either.

    I think your solution of just adding flash memory and using the same code approach as simpleplayer (with h and cpp files in flash memory) is the best.

    So I'm not sure what "SMD pacage" means or which "corresponding pins" exist on the audio adaptor. I will work on trying to figure this out, unless you have a quick answer for me.

    Also, is there additional code to write to get the new flash memory to work?

    If you have the code for your program, could you share it and I can change it to access my steel drum notes?

    In any case, thanks for your help.

  6. #6
    Member Sandro's Avatar
    Join Date
    Nov 2016
    Rimini - Italy
    Yes I'm here, developing an amazing midi expander
    Ok, when I'll be back from my vacation I'll look for the code I wrote for my drum pad, much simpler than your I belive.
    Here in this pic the particular of the place for the flash memory on the Audio Adaptor:
    Click image for larger version. 

Name:	Screenshot_20190805-215941.jpg 
Views:	3 
Size:	66.0 KB 
ID:	17120

  7. #7
    Member Sandro's Avatar
    Join Date
    Nov 2016
    Rimini - Italy
    Hi Ofishar, this an example for W25Q128FV in SMD size:

    For the code, I found that I didn't develop my drum pad for flash memory. I only tested the "play from flash memory" functionality with this code:
    // GUItool: begin automatically generated code
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    // GUItool: begin automatically generated code
    AudioPlaySerialflashRaw  playFlash0;     //xy=205,175
    AudioPlaySerialflashRaw  playFlash1;     //xy=205,208
    AudioPlaySerialflashRaw  playFlash2;     //xy=205,241
    AudioPlaySerialflashRaw  playFlash3;     //xy=205,274
    AudioMixer4              mixer1;         //xy=394,220
    AudioOutputI2S           audio_out;      //xy=583,218
    AudioConnection          patchCord1(playFlash0, 0, mixer1, 0);
    AudioConnection          patchCord2(playFlash1, 0, mixer1, 1);
    AudioConnection          patchCord3(playFlash2, 0, mixer1, 2);
    AudioConnection          patchCord4(playFlash3, 0, mixer1, 3);
    AudioConnection          patchCord5(mixer1, 0, audio_out, 1);
    AudioConnection          patchCord6(mixer1, 0, audio_out, 0);
    AudioControlSGTL5000     board;          //xy=394,284
    // GUItool: end automatically generated code
    void setup()
      mixer1.gain(0, 0.5);
      mixer1.gain(1, 0.5);
      mixer1.gain(2, 0.5);
      mixer1.gain(3, 0.5);
      // set up SPI Teensy to SPI Flash
    void loop()
    I put toghether 4 "players": 4 it's an arbitrary number, you can use less or more players, depends on how many contemporary voices you want. Audio x.RAW files must be written on flash memory, you can use "CopyFromSD" example in Arduino IDE to copy files from SD card to flash memory.

  8. #8
    Sandro, I'm not sure I understand. I purchased and soldered on a new flash memory chip onto the audio board. My sketch (program) still shows that 77% is used and I've only connected nine (9) sensors. I want to connect 30 separate sensors and have 30 separate voices (sounds).

    1) Is there software I need to add to my program to access the new flash memory card?

    2) Or does it automatically access the flash and perhaps it is not soldered properly?

  9. #9
    Junior Member JotaEfe13's Avatar
    Join Date
    Jan 2019
    You need this library:

    It has an example sketch to test the hardware. If you run it succesfuly, you can run the sketch to copy files from a SD card. Then, you can check the Audio library example for playing raw audio files from serial flash. Note that for serial flash memory the audio library only supports RAW format files for playback.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts