Help with MP3 Player Shield

Hello all,
I've been working on a electronic drum project now for sometime. And I'll like to share it's progress and also get some help.

It's 32 piezo sensor pad, each trigger a specific midi note and light a specific LED. With help from GrummpyMike, CrossRoads and other I was able to get it up and running. Not bad for for first arudino project.

No I need to expand it a little. I'm trying to trigger a specific MP3 file, one for each sensor.
I've been looking at the Sparkfun-MP3-Player-Shield-Arduino-Library.

I've tried the examples successfully but can't figure out how to request a file using an index variable
such as:

MP3player.playTrack(1);

I prefer for use numbers rather that filename as there are lots of buttons, although I'm not adverse to using another method.

This is what I've tried

for (int  i=0; 1<16; 1++)
 if (analogPin==0) {
   if(activePad[pad]
 MP3player.playTrack(current_track[i]); 
eles
MP3player.stopTrack();

but that didn't work. didn't even compile.
What an I doing wrong. What should I be doing?

Call for Help
Thank much
Cheers
A

ArtEnRoute

code attached sans MP3Sheild

scaledup_CC_mcp_ada_II_c_senitivity_retuneMOD_5.ino (9.14 KB)

but nothing works, or even complies at this point.

If the code you have does not compile, and you do not understand why not, it is not useful to just post that complaint here. Post your code and your error messages.

I've been looking at the SPFMP3-Player-Shield-Library.

The one on sale this week at WalMart?

This is what I added to the main loop

/////////////////TEST/////TEST////////TEST////////
if(analogPin==1)
      {
         if (activePad[pad])
           MP3player.playTrack([i]);
         else
            MP3player.stopTrack();
      }
////////////////////////TESTING//////////////////

the error I get is:

262: error: expected unqualified-id before 'if'

the other options I was considering are:

if(analogPin==1)
      {
         if (activePad[pad])
           MP3player.playTrack([pad]);
         else
            MP3player.stopTrack();
      }

and

if(analogPin==1)
      {
         if (activePad[pad])
           MP3player.playTrack([current_track]);
         else
            MP3player.stopTrack();
      }

both of which results in the same error.
The sketch, MP3 part added

Any ideas?
Thanks much.

mcp_ada_II_c_senitivity_retuneMOD_6.ino (9.95 KB)

Something about free standing code. Perhaps I'll try to place that bit into another section of the sloop and see what happens.

if(analogPin==1)

What type of variable is this? It suggests that it is a pin number not a value read from a pin.

         if (activePad[pad])

Again, no context, so it isn't clear that acrivePad is an array.

           MP3player.playTrack([i]);

Why is i inside square brackets?

262: error: expected unqualified-id before 'if'

And, we are left to guess which line is line 262. No thanks.

I was able to compile the sketch (NO THANKS TO THE BIG SALE on AT WALMART this week) by moving this new portion earlier in the loop. Now to see if it behaves as expected.

       /////////////////TEST/////TEST////////TEST////////
if(analogPin==1)
      {
         if (activePad[pad])
           MP3player.playTrack(pad);
         else
            MP3player.stopTrack();
      }
////////////////////////TESTING//////////////////

I've tracked an issue down to these lines.

if(!sd.begin(9, SPI_HALF_SPEED)) sd.initErrorHalt();
  if (!sd.chdir("/")) sd.errorHalt("sd.chdir");

  MP3player.begin();
  MP3player.setVolume(10,10);

With them added the tone/midi parts of the program doesn't work.

I have still to add the hardware to see if the mp3 part works without the aforementioned code ( I'm guessing NOT).

Meanwhile I'm converting the intended mp3 files from .wav to mp3 as wav format may or maynot be supported. I'm also considering whether to use interrupts for the sensors.

Stay tuned.

PS. Still seeking advice/guidance.
Thanks much

digidrumduino_8.ino (9.94 KB)

Not relevant to the post.

(Hey look, its Columbus Circle :slight_smile: ) I think I've seen that guy playing before too.

Yep. There are pin conflicts between the Mux shield and mp3Shield.

https://learn.sparkfun.com/tutorials/mp3-player-shield-hookup

I'm thinking it'll be easier to change the mux control pin than to change the pin config in mp3library.
As it is now MUX control pin D2,3,4,5; may needto be changed to D3,4,5,10. Any one know if that can be done?

Also pins D3 and D4 on the mp3shield needs to be cut to be availale

The project works sans (minus) the mp3 part with these lines added:

  MP3player.begin();
  MP3player.setVolume(10,10);

but NOT with these:

if(!sd.begin(9, SPI_HALF_SPEED)) sd.initErrorHalt();
  if (!sd.chdir("/")) sd.errorHalt("sd.chdir");

A:
Changing the mux control pins doesn't work, so that leaves editing the mp3 library in addition to shorting two pins and remapping MP3-DREQ (2)

Quote from: dc42 on December 09, 2012, 03:43:59 am
Quote from: enemydodo on December 08, 2012, 09:14:23 pm
I am using the MP3 Player Shield from Sparkfun(SparkFun MP3 Player Shield - DEV-12660 - SparkFun Electronics) and the MPU-6050(https://www.sparkfun.com/products/11028) at the same time. But both of them uses the digital pin 2 and they can't work together. The MP3 shield uses it as "MP3-DREQ" as stated beside the pin and the MPU uses it as the interrupt pin. I tried all of the solution but none of them worked:

  1. Remap the pin in the MP3 library. I changed a line that declares the pin for the DREQ and it still don't work without pin 2.

Pin 2 will be connected to some hardware on the MP3 shield, so by itself, that isn't gong to work.

Quote from: enemydodo on December 08, 2012, 09:14:23 pm
2. Bend the pin on the MP3 Shield so that it doesn't go into the Arduino. The MP3 won't work. It need the pin for sure.

What you need to do is both 1 and 2 and also connect pin 2 on the MP3 shield to whatever pin you remapped it to in the software. That should work as long as the MP3 software isn't using any special functions of pin 2, e.g. the interrupt.

http://forum.arduino.cc/index.php/topic,136550.0.html

B:

i was wundering if i could use other digital pins by wiring them manually, but i cannot find documentation saying that is possible allthough it looks logical to me that it can,
i could easely define other digital pins as input in the code for the different mux shield unless the shields are hardcoded internally to make uses of predefined input pins.

Poor choice of digital pins (stealing both external interrupt pins), in my opinion.

http://forum.arduino.cc/index.php?topic=68108.0

I am using the Arduino-Mega. Can I use the vs1053 shield with different digital pins as in the recommended setup as those aren't available and the controller has more input than your average arduino? In true breakout board fashion the shield doesn't need to mounted on the arduino, it could be wired in place.

I know this (midi instruments) is nothing new to the forum nonetheless.....

As it happen I'm currently sending midi data to an external midi synth. and simple buzzer uses pitches.h to play the corresponding tone two separate events and hardware . It occurred to me that the vs1053 can play midi as well. using wavetables on the chip. Which will eliminate the need for an external synth. If may be possible the switch from audio samples (mp3 or wav) mode to midi, if not both modes at once. All on one shield.
https://gist.githubusercontent.com/microtherion/2636608/raw/68f8b3d99879440e28a750c9e35eb8c05dbe2a1c/MP3_Shield_RealtimeMIDI.ino
Pondering..........

Seems like

in SFEMP3ShieldConfig.h

change

#else // otherwise use pinout of typical Sparkfun MP3 Player Shield.
  #define MP3_XCS              6 //Control Chip Select Pin (for accessing SPI Control/Status registers)
  #define MP3_XDCS             7 //Data Chip Select / BSYNC Pin
  #define MP3_DREQ             2 //Data Request Pin: Player asks for more data

to:

#else // otherwise use pinout of typical Sparkfun MP3 Player Shield.
  #define MP3_XCS              6 //Control Chip Select Pin (for accessing SPI Control/Status registers)
  #define MP3_XDCS             7 //Data Chip Select / BSYNC Pin
  #define MP3_DREQ             10 //Data Request Pin: Player asks for more data

then cut the leads on Midi-In and GPIO1 (D3 &4) with an exacto knife.

that din't work......
I've tried editing #Define MP3-DREQ in SFEMP3ShieldConfig.h. No good.
Pin 2 seems hard wired to the chip. I tried jumping pins 2 and 10 but that cause the file to play while fast forwarding (very fast ) and only if D2 is wired in.
So it's back to the drawing board
From one forum post it appears to be a way to edit the control for the mux-shield
as the mega uses different pins for SPI I thought I'd use 10,11,12,13 for the mux so I changed

// MuxShield:
// Give convenient names to the control pins of the muxshield
#define CONTROL0 5    
#define CONTROL1 4
#define CONTROL2 3
#define CONTROL3 2

to

// MuxShield:
// Give convenient names to the control pins of the muxshield
#define CONTROL0 13    
#define CONTROL1 12
#define CONTROL2 11
#define CONTROL3 10

That didn't work.
I running out of ideas. Can anyone offer some assistance?
This post suggests that modifying the control pin is possiable.
http://forum.arduino.cc/index.php?topic=62298.0