Musical Instrument Shield Question

Status
Not open for further replies.

ofishal

Well-known member
BACKGROUND
I am new to the forum and inexperienced.

I have a project where I am trying to make a musical instrument and want to send sensor data to a non-powered speaker. There will be 30 separate sensors (piezos).

I have a Teensy 3.5, pjrc audio shield and pjrc prop shield.

My understanding is that the audio shield will help provide audio support and sound files and the prop shield will provide amplified output.

QUESTIONS
Can I connect and solder BOTH the audio shield and prop shield to the Teensy 3.5 or will that mess things up?

Is there a better way to make my project?
 
BACKGROUND
I am new to the forum and inexperienced.

I have a project where I am trying to make a musical instrument and want to send sensor data to a non-powered speaker. There will be 30 separate sensors (piezos).

I have a Teensy 3.5, pjrc audio shield and pjrc prop shield.

My understanding is that the audio shield will help provide audio support and sound files and the prop shield will provide amplified output.

QUESTIONS
Can I connect and solder BOTH the audio shield and prop shield to the Teensy 3.5 or will that mess things up?

Is there a better way to make my project?

The prop shield and audio shields won't work together (the audio shield needs to switch some pins to their alternate usages, but the prop shield wants the pins in their normal usage). And there are some pins that overlap between the two.

If you went with just the prop shield, which provides lower quality mono sound output, you would have to solder a wire from pin A21 to the prop shield for the on-board DAC (digital to analog converter).

The audio shields provides better quality stereo sound output as well as the ability to do other sound processing. If you haven't chosen the speakers yet, given the audio shield has direct headphone output, it would just simple to use speakers that plug into the headphone jack and provide their own amplification. For example, this was one of the first units that popped up when I did a search on amazon:

Other than that, it should be easier to provide amplification to the outputs of the audio shield. It has been awhile since I played with the audio shield, and I don't remember the exact pinout. I think something like this would work (you would need to tie the L- and R- to the middle pin of the audio shield), but I'm not sure:
 
Last edited:
MichaelMeissner (and others)

Thanks for your input. So now I am just trying to get a simple (really simple!) drum machine to play just using my Teensy 3.5 on a windows machine. There are so many simple drums, but I just can't make them play with my audio shield.

I have followed the instructions in Hackspace Magazine (August 2018, Issue #09, pages 106 to 109).

It is a bit difficult to write the code described in the magazine because it is broken down into a number of pieces rather than just all the code together.

Below is the code I have tried to run.

I have included the two sound fines in the sketch file ("audiosamplekick.h" and "audiosamplekick.cpp"). I think my audio sample files are good, I developed them with wav2sketch

When I check my code, I get this error:

C:\Program Files\Arduino_Teensy\arduino-1.8.9\hardware\teensy\avr\libraries\SD
Not used: C:\Program Files\Arduino_Teensy\arduino-1.8.9\libraries\SD
#include expects "FILENAME" or <FILENAME>

What am I doing wrong?


Code:
//firt three lines from magazine

#include “AudioSampleKick.h”
boolean previousKickButtonStatus = false;
unsigned long previousKickTime = 0;

void setup() {
  // put your setup code here, to run once:
  
//six more lines from magazine
void setup() {
AudioMemory(10);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
pinMode(2, INPUT_PULLUP);
}
void loop() {
boolean newKickButtonStatus = !digitalRead(2);
if(newKickButtonStatus !=
previousKickButtonStatus && millis() >
previousKickTime + 30) {
if(newKickButtonStatus) playMem1.
play(AudioSampleKick);
previousKickButtonStatus =
newKickButtonStatus;
previousKickTime = millis();
}
}


}

void loop() {
  // put your main code here, to run repeatedly:

}

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioPlayMemory          playMem3;       //xy=269,225
AudioPlayMemory          playMem1;       //xy=289,373
AudioPlayMemory          playMem2;       //xy=293,297
AudioMixer4              mixer1;         //xy=742,272
AudioOutputI2S           Audio_Board Output;           //xy=1031,274
AudioConnection          patchCord1(playMem3, 0, mixer1, 0);
AudioConnection          patchCord2(playMem1, 0, mixer1, 3);
AudioConnection          patchCord3(playMem2, 0, mixer1, 1);
AudioConnection          patchCord4(mixer1, 0, Audio_Board Output, 0);
AudioConnection          patchCord5(mixer1, 0, Audio_Board Output, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=591,435
// GUItool: end automatically generated code
 
Code:
#include “AudioSampleKick.h”
Those are the wrong kind of quotes. Use this:
Code:
#include "AudioSampleKick.h"

Pete
 
el_suprimo,

I fixed the first error (the wrong type of quotes).

Now I am getting these errors for the exact same code I have in my original post (except the fixed quotations).

the red line with the erros is over the voidsetup () { right after my note //six more lines from magazine

sketch_jul14b_drum2: In function 'void setup()':
sketch_jul14b_drum2:12: error: a function-definition is not allowed here before '{' token
void setup() {

^

sketch_jul14b_drum2:56: error: expected '}' at end of input
AudioControlSGTL5000 sgtl5000_1; //xy=591,435

^

Multiple libraries were found for "SD.h"
Used: C:\Program Files\Arduino_Teensy\arduino-1.8.9\hardware\teensy\avr\libraries\SD
Not used: C:\Program Files\Arduino_Teensy\arduino-1.8.9\libraries\SD
a function-definition is not allowed here before '{' token
 
The first problem is that you've got two definitions of setup()
Code:
void setup() {
  // put your setup code here, to run once:
  
//six more lines from magazine
void setup() {
You've also got two loop functions, the Audio library declarations are in the wrong place, plus a few other errors.
I've fixed it up so that it should compile now:
Code:
//firt three lines from magazine

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioPlayMemory          playMem3;       //xy=269,225
AudioPlayMemory          playMem1;       //xy=289,373
AudioPlayMemory          playMem2;       //xy=293,297
AudioMixer4              mixer1;         //xy=742,272
AudioOutputI2S           Audio_Board_Output;           //xy=1031,274
AudioConnection          patchCord1(playMem3, 0, mixer1, 0);
AudioConnection          patchCord2(playMem1, 0, mixer1, 3);
AudioConnection          patchCord3(playMem2, 0, mixer1, 1);
AudioConnection          patchCord4(mixer1, 0, Audio_Board_Output, 0);
AudioConnection          patchCord5(mixer1, 0, Audio_Board_Output, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=591,435
// GUItool: end automatically generated code
#include "AudioSampleKick.h"
boolean previousKickButtonStatus = false;
unsigned long previousKickTime = 0;


//six more lines from magazine
void setup()
{
  AudioMemory(10);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.5);
  pinMode(2, INPUT_PULLUP);
}
void loop()
{
  boolean newKickButtonStatus = !digitalRead(2);
  if(newKickButtonStatus !=
      previousKickButtonStatus && millis() >
      previousKickTime + 30) {
    if(newKickButtonStatus) playMem1.play(AudioSampleKick);
    previousKickButtonStatus = newKickButtonStatus;
    previousKickTime = millis();
  }
}

Pete
 
Pete, You are a great help. Thanks for the fixes on the code. I'm down to just one (or maybe two) error(s) now.

It looks like problem is associated with the location of the sound files and the code's reference to SD.

I did not put an SD in the Teensy 3.5, but eventually want to have the sound files there so I can run the Teensy without a computer.

Currently the sound files ("audiosamplekick.h" and "audiosamplekick.cpp") are in the same folder as the program code.

When I compiled my original code, I saw the two folders on the top of the program. Now I do not see them any more.

The current location of the two sound files is in the same folder as the code.

Is this a quick fix or two?

Again, thanks for your help.

Al

I can see the other


Multiple libraries were found for "SD.h"
C:\Users\OFishAl\Documents\Arduino\sketch_jul14b_drum3\sketch_jul14b_drum3.ino:22:29: fatal error: AudioSampleKick.h: No such file or directory

Used: C:\Program Files\Arduino_Teensy\arduino-1.8.9\hardware\teensy\avr\libraries\SD
compilation terminated.

Not used: C:\Program Files\Arduino_Teensy\arduino-1.8.9\libraries\SD
Error compiling for board Teensy 3.5.
 
No Pete wait, I forgot to put the sound files in the same folder as the new program code you wrote.

It compiled without any errors. I might be good to go here.

THANKS for you help. You made my Sunday a happy day!
 
Pete/and or anybody else.

So the program code in message #7 now runs my kick drum! Wow, fantastic. I am stoked!

But it only makes does the kick drum once when I start the program.

How do I change the code so it triggers the sound when I activate a switch (ideally a peizo)?

I don't care which pin, but ideally an analog pin.
 
The code is set up to read a button on pin 2. Even if you just have a piece of wire connected to pin 2, the sound should be played whenever you touch the wire to ground and then release it again.

Pete
 
Status
Not open for further replies.
Back
Top