Drum pad

Status
Not open for further replies.

Sandro

Well-known member
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):

Code:
#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"        // http://www.freesound.org/people/KEVOY/sounds/82583/
#include "AudioSampleTomtom.h"       // http://www.freesound.org/people/zgump/sounds/86334/
#include "AudioSampleHihat.h"        // http://www.freesound.org/people/mhc/sounds/102790/
#include "AudioSampleKick.h"         // http://www.freesound.org/people/DWSD/sounds/171104/
#include "AudioSampleGong.h"         // http://www.freesound.org/people/juskiddink/sounds/86773/
#include "AudioSampleCashregister.h" // http://www.freesound.org/people/kiddpark/sounds/201159/

// 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
  AudioMemory(10);

  // turn on the output
  audioShield.enable();
  audioShield.volume(0.5);

  // 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
  //dac.analogReference(INTERNAL);

  // 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
  button0.update();
  button1.update();
  button2.update();
  button3.update();
  button4.update();
  button5.update();

  // 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()) {
    sound0.play(AudioSampleSnare);
  }
  if (button1.fallingEdge()) {
    sound1.play(AudioSampleTomtom);
  }
  if (button2.fallingEdge()) {
    sound2.play(AudioSampleHihat);
  }
  if (button3.fallingEdge()) {
    sound3.play(AudioSampleKick);
  }
  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
    sound4.play(AudioSampleGong);
  }
  if (button5.fallingEdge()) {
    sound5.play(AudioSampleCashregister);
  }
}

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!:)
 
I just bought a W25Q128FV chip, I belive it's a good solution!!
Post closed! :)
 
Last edited:
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.
 
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).
 
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.
 
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:
Screenshot_20190805-215941.jpg
 
Hi Ofishar, this an example for W25Q128FV in SMD size:
https://www.ebay.it/itm/W25Q128FVSSIG-W25Q128FVSIG-W25Q128FVSG-25Q128FVSIG-25Q128FVSG-25Q128/272904061861?ssPageName=STRK%3AMEBIDX%3AIT&var=572087559806&_trksid=p2060353.m2749.l2649

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:
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()
{
  board.enable();
  board.volume(0.4);
  
  AudioMemory(10);

  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
  SPI.setMOSI(7);
  SPI.setMISO(12);
  SPI.setSCK(14);
  
  SerialFlash.begin(6);
}

void loop()
{
  playFlash0.play("0.RAW");
  delay(1000);
  playFlash1.play("1.RAW");
  delay(1000);
  playFlash2.play("2.RAW");
  delay(1000);
  playFlash3.play("3.RAW");
  delay(1000);
}

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.
bye
 
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?
 
You need this library: https://github.com/PaulStoffregen/SerialFlash

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.
 
JotaEfe13, I ran SerialFlash and the monitor gave me the following readout. So this means I did not solder it correctly, right?

14:06:49.135 -> Raw SerialFlash Hardware Test
14:06:49.135 ->
14:06:49.135 -> Read Chip Identification:
14:06:49.135 -> JEDEC ID: FF FF FF
14:06:49.135 -> Part Nummber: (unknown chip)
14:06:49.135 -> Memory Size: 0 bytes
14:06:49.135 ->
14:06:49.135 -> Tests Failed :{
14:06:49.135 ->
14:06:49.135 -> The flash chip may be left in an improper state.
14:06:49.135 -> You might need to power cycle to return to normal.
 
JotaEfe13, I ran SerialFlash and the monitor gave me the following readout. So this means I did not solder it correctly, right?

14:06:49.135 -> Raw SerialFlash Hardware Test
14:06:49.135 ->
14:06:49.135 -> Read Chip Identification:
14:06:49.135 -> JEDEC ID: FF FF FF
14:06:49.135 -> Part Nummber: (unknown chip)
14:06:49.135 -> Memory Size: 0 bytes
14:06:49.135 ->
14:06:49.135 -> Tests Failed :{
14:06:49.135 ->
14:06:49.135 -> The flash chip may be left in an improper state.
14:06:49.135 -> You might need to power cycle to return to normal.

If the Audio Adaptor is connected properly to your Teensy, and the memory chip is a W25Q128, than I agree, it could mean that there is some contact/solder issue.
 
If the Audio Adaptor is connected properly to your Teensy, and the memory chip is a W25Q128, than I agree, it could mean that there is some contact/solder issue.

Yes. That is the most likely explanation. Those tiny chips are tricky to solder properly. At least for me.
 
It would be nice if we could order audio shields with or without extra flash memory. Yeah soldering that chip is tricky. I guess I'll keep trying.
 
It's not so difficult if you use a very thin soldering iron tip, the right temperature ana a good tin wire... This is my procedure: place the IC on its position, fix it perfectly with scotch tape, check with magnifier, than solder one side, remove the tape and go on to the other side; than remove with a solvent the solder paste; again magnifier lens, than test with a tester each contact...
One more suggestion, but I believe this not new for you: most active devices like these are terribly scared of high impulsive tension, more than hot teperature, so try to avoid contact with plastic/not conductive materials that can host electrostatic charge.
 
Hi Sandro,

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):

[...]
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!:)

I am using samples stored in PROGMEM with a Teensy-3.6. Fortunately, samples and program fit into PROGMEM (using 94%). My code is located at https://codeberg.org/dcoredump/MicroMDAEPiano.

Regards, Holger
 
C0d3man, I would like to test your piano program and visited the site you referenced (https://codeberg.org/dcoredump/MicroMDAEPiano), but am unclear what files need to be in the folder of the program and/or which programs need to be on an SD card. Or am I too mixed up to understand how the program works. And lastly, are you using a board with midi hardware, and a midi keyboard connected to a midi sound device?
 
C0d3man, I would like to test your piano program and visited the site you referenced (https://codeberg.org/dcoredump/MicroMDAEPiano), but am unclear what files need to be in the folder of the program and/or which programs need to be on an SD card. Or am I too mixed up to understand how the program works. And lastly, are you using a board with midi hardware, and a midi keyboard connected to a midi sound device?

The code is currently designed for the TeensyMIDIAudio breakout board and is still a work in progress (I'm just desperate at programming a chorus effect). It should work without a display but changing parameters is not easy (storing is withoud LCD/Encoders impossible). Some parameters are mapped to MIDI-CC. The breakout board has a DIN-MIDI circuit onboard and there is a solution for using the USB-Host of the Teensy-3.6 for connecting a MIDI keyboard.

You don't need a SD card for MicroMDAEpiano (but for MicroDexed you can use a simple 2GB SD card for SYSEX files). There is a "hex" folder and you can install the
precompiled hex file directly using the Teensy loader:
https://www.pjrc.com/teensy/loader.html.

Another way: I just added a folder named "third-party". Copy them to your library folder and try to compile/upload.

Regards, Holger
 
Last edited:
Steel drum

C0d3man, I would like to test your piano program and visited the site you referenced (https://codeberg.org/dcoredump/MicroMDAEPiano), but am unclear what files need to be in the folder of the program and/or which programs need to be on an SD card. Or am I too mixed up to understand how the program works. And lastly, are you using a board with midi hardware, and a midi keyboard connected to a midi sound device?

How did your steel drum project work? I am beginning the process of building a digital steel drum and would appreciate you insight.
 
Status
Not open for further replies.
Back
Top