I am using Windows 8.1, a Teensy 4.0 and a Teensy Audio Shield.
I am running a modified SamplePlayer code which worked well with 8 separate sounds (notes) connected to three mixers (code below).
I am trying to build an electric steel drum and have a way to go since I want to have 29 separate sounds (notes).
I added two additional sounds to mixer 3 (bringing the total number of sounds (notes) to 10) and the program would not compile.
I got three errors, one says "...data' will not fit in region `DTCM'" and two say "...bss' is not within region `DTCM'".
I'm not sure what these mean, am I out of memory?
I am running a modified SamplePlayer code which worked well with 8 separate sounds (notes) connected to three mixers (code below).
I am trying to build an electric steel drum and have a way to go since I want to have 29 separate sounds (notes).
I added two additional sounds to mixer 3 (bringing the total number of sounds (notes) to 10) and the program would not compile.
I got three errors, one says "...data' will not fit in region `DTCM'" and two say "...bss' is not within region `DTCM'".
I'm not sure what these mean, am I out of memory?
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 "AudioSampleC_drum.h" // AudioSampleC_drum (C4) // 1st note into mixer 1
#include "AudioSampleD_drum.h" // AudioSampleD_drum (D4) // 2nd note into mixer 1
#include "AudioSampleE_drum.h" // AudioSampleE_drum (E4) // 3rd note into mixer 1
#include "AudioSampleF_drum.h" // AudioSampleF_drum (F4) // 4th note into mixer 1
#include "AudioSampleG_drum.h" // AudioSampleG_drum (G4) // 5th note into mixer 2
#include "AudioSampleA_drum.h" // AudioSampleA_drum (A4) // 6th note into mixer 2
#include "AudioSampleB_drum.h" // AudioSampleB_drum (B4) // 7th note into mixer 2
#include "AudioSampleC1_drum.h" // AudioSampleC1_drum (C5) // 8th note into mixer 3
#include "AudioSampleD1_drum.h" // AudioSampleD1_drum (D5) // 9th note into mixer 3
#include "AudioSampleE1_drum.h" // AudioSampleE1_drum (E5) // 10th note into mixer 3
// GUItool: begin automatically generated code
AudioPlayMemory playMem3;
AudioPlayMemory playMem4;
AudioPlayMemory playMem1;
AudioPlayMemory playMem2;
AudioPlayMemory playMem5;
AudioPlayMemory playMem6;
AudioPlayMemory playMem7;
AudioPlayMemory playMem8; // 8th note into mixer 3
AudioPlayMemory playMem9; // 9th note into mixer 3
AudioPlayMemory playMem10; // 10th note into mixer 3
// Mixers and Output
AudioMixer4 mixer1;
AudioMixer4 mixer2;
AudioMixer4 mixer3; // new mixer 3
AudioOutputI2S headphones;
// Inputs to Mixer 1
AudioConnection patchCord3(playMem1, 0, mixer1, 0); // AudioSample C4
AudioConnection patchCord4(playMem2, 0, mixer1, 1); // AudioSample D4
AudioConnection patchCord1(playMem3, 0, mixer1, 2); // AudioSample E4
AudioConnection patchCord2(playMem4, 0, mixer1, 3); // AudioSample F4
// Inputs to Mixer 2
AudioConnection patchCord5(mixer1, 0, mixer2, 0); // output from mixer 1 into mixer 2
AudioConnection patchCord6(playMem5, 0, mixer2, 1); // AudioSample G4
AudioConnection patchCord7(playMem6, 0, mixer2, 2); // AudioSample A4
AudioConnection patchCord8(playMem7, 0, mixer2, 3); // AudioSample B4
// Inputs to Mixer 3
AudioConnection patchCord9(mixer2, 0, mixer3, 0); // output from mixer 2 into mixer 3
AudioConnection patchCord10(playMem8, 0, mixer3, 1); // AudioSample C1
AudioConnection patchCord11(playMem9, 0, mixer3, 2); // AudioSample D1
AudioConnection patchCord12(playMem10, 0, mixer3, 3); // AudioSample E1
// Outputs from Audio Shield to headphones
AudioConnection patchCord13(mixer3, 0, headphones, 0); // changed from mixer 2 to mixer 3
AudioConnection patchCord14(mixer3, 0, headphones, 1); // changed from mixer 2 to mixer 3
AudioControlSGTL5000 sgtl5000_1;
//Audio Connections
AudioConnection c1(playMem1, 0, mixer1, 0);
AudioConnection c2(playMem2, 0, mixer1, 1);
AudioConnection c3(playMem3, 0, mixer1, 2);
AudioConnection c4(playMem4, 0, mixer1, 3);
AudioConnection c5(playMem5, 0, mixer2, 1);
AudioConnection c6(playMem6, 0, mixer2, 2);
AudioConnection c7(playMem7, 0, mixer2, 3);
AudioConnection c8(playMem8, 0, mixer3, 1); // new 8th note into mixer 3
AudioConnection c9(playMem9, 0, mixer3, 2); // new 9th note into mixer 3
AudioConnection c10(playMem10, 0, mixer3, 3); // new 10th note into mixer 3
//play to both I2S audio board and on-chip DAC
AudioConnection c11(mixer3, 0, headphones, 1); // Changed to mixer 3
AudioOutputAnalog dac;
//Object to Control Audio Shield
AudioControlSGTL5000 audioShield;
// Bounce objects to read six pushbuttons (pins)
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);
Bounce button6 = Bounce(6, 5);
Bounce button9 = Bounce(9, 5); // pin 9 on Teensy
Bounce button10 = Bounce(10, 5); // pin 10 on Teensy
Bounce button11 = Bounce(11, 5); // pin 11 on Teensy
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);
pinMode(6, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP); // to Teensy pin 9
pinMode(10, INPUT_PULLUP); // to Teensy pin 10
pinMode(11, INPUT_PULLUP); // to Teensy pin 11
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(12); // maybe need to change audiomemory at some point? Can't find MemoryAndCpuUsage example. Was 10; changed to 12
// turn on the output
audioShield.enable();
audioShield.volume(0.5);
// reduce the gain on mixer channels, so more than 1
// sound can play simultaneously without clipping
mixer1.gain(0, 0.4);
mixer1.gain(1, 0.4);
mixer1.gain(2, 0.4);
mixer1.gain(3, 0.4);
mixer2.gain(0, 0.4); //added gains for all channels in mixer 2
mixer2.gain(1, 0.4);
mixer2.gain(2, 0.4);
mixer2.gain(3, 0.4);
mixer3.gain(0, 0.4); // added gains for channels in mixer 3
mixer3.gain(1, 0.4);
mixer3.gain(2, 0.4);
mixer3.gain(3, 0.4);
}
void loop() {
// Update all the button objects
button0.update();
button1.update();
button2.update();
button3.update();
button4.update();
button5.update();
button6.update();
button9.update();
button10.update();
button11.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()) {
playMem1.play(AudioSampleC_drum);
}
if (button1.fallingEdge()) {
playMem2.play(AudioSampleD_drum);
}
if (button2.fallingEdge()) {
playMem3.play(AudioSampleE_drum);
}
if (button3.fallingEdge()) {
playMem4.play(AudioSampleF_drum);
}
if (button4.fallingEdge()) {
playMem5.play(AudioSampleG_drum);
}
if (button5.fallingEdge()) {
playMem6.play(AudioSampleA_drum);
}
if (button6.fallingEdge()) {
playMem7.play(AudioSampleB_drum);
}
if (button9.fallingEdge()) {
playMem8.play(AudioSampleC1_drum);
}
if (button10.fallingEdge()) {
playMem9.play(AudioSampleD1_drum);
}
if (button11.fallingEdge()) {
playMem10.play(AudioSampleE1_drum);
}
}