CodeVisionAVR

High Performance ANSI C Compiler
for Atmel AVR microcontrollers

X-Graph

Rabbit SBC - Atmel AVR XMega SBC - Arduino Shields
Touchscreen LCD - GPRS - MP3 - WiFi - Ethernet


MP3 Arduino Shield

29.00€


99 Units in Stock
Quantity Discounts:
+10 pcs = -3%
+30 pcs = -6%
+50 pcs = -8%
+100 pcs = -11%
(Rewarded at Checkout)
The XG8300 MP3 Shield transforms your Arduino module in a full featured MP3 player. This shield includes a 3.5mm stereo jack and a SDCard socket to store all your MP3 files. Just hook up your headphone and run the example Sketch to enjoy MP3 playback.

Add an X-Graph LCD Shield and you can start designing your own portable MP3 player.

This shield is easy to use (see Example code) and integrates in all your hardware designs. Add simple voice commands, sounds and MP3/WAV music to your projects. All these files are stored on a standard SDCard, up to 32GByte. The card can also be used to store any other data because it is fully compatible with the Arduino SD Library.

You can stack all X-Graph Arduino Shields (top headers to be installed).

  • Powerfull MP3 DSP processor
  • On-board 3.3V power supply for noise-free operation
  • microSDCard socket (MMC/SD/SDHC & Arduino library compatible)
  • compatible with cards up to 32GB formatted in FAT12,FAT16 & FAT32
  • Headphone Amplifier
  • 3.5mm audio jack
  • Arduino SPI bus compatible = minimum I/O pin requirement
  • MP3 Arduino library included
  • decodes MP1, MP2, MP3 (Layer I, II, III) CBR, VBR, ABR
  • decodes WAV files
  • works with sample rates up to 320kbit/sec
  • Volume, Bass, Treble, Balance controls
  • Very low power consumption (typical 20mA)
  • RoHS compliant
  • Very small footprint, compatible with all other X-Graph Arduino Shields
  • X-Graph Arduino stackable connectors. Stack as many X-Graph Arduino Shields as you need.
I/O pins used: SPI bus + 3 lines (includes CS of SDCard)

Add an XG8000 or XG8400 LCD Arduino shield and build your own portable MP3 player.

The XG8300 MP3 library uses the Arduino hardware SPI bus. Songs are streamed from the SDCard to the MP3 processor. The library includes functions for playback (play, stop, pause, fast forward, fast reverse) and audio control (volume, balance, bass, treble, virtual stereo).

To download the library and example code click on 'DOWNLOAD' in the top menu.


/*
 Play MP3 file from SD card

 This example shows how to read a MP3 file from the SD card using the
 SD library and play it with the © Copyright DELCOMp XG8300 MP3 shield.

 © Copyright DELCOMp 2011-2012, All Rights Reserved
 DELCOMp bvba, Technologielaan 3, B-3001 Leuven, Belgium
 http://www.xgraph.be ©

 Change History:
 Date: 1.0, 28 Sep 2011
       1.1, 9 Jan 2012
         - R2 pcb support
 
 This example code is in the public domain.

 XG8300 MP3 Shield functions demonstrated:
 - setup: inits the MP3 hardware
 - open: opens MP3 file (from sdcard)
 - close: stops playing then closes MP3 file
 - play: starts playing
 - stop: stop playing
 - pause: pause song
 - fastforward: fast-forward song
 - fastreverse: fast-reverse song
 - volume: set volume & balance
 - tone: set bass & treble level / cut-off frequency of bass & treble
 
 A real-life app would add
 - ID3 tag features: http://www.id3.org/id3v2.3.0
 - an LCD to display MP3 info. For example the XG8000 or XG8400
 - some user input signals, either a keypad or touchscreen
   (for example XG8000 or XG8400
*/

#include <SD.h>
#include <mp3.h>

// The MP3 Shield uses several 3 SPI CS pins:
const int SDChipSelect = 4;    // line 4 for existing shields compatibility
const int MP3cmdChipSelect = 8;
const int MP3dataChipSelect = 9;
// Note that even if it's not used as the CS pin, the hardware
// CS pin (10 on most Arduino boards, 53 on the Mega) must be
// left as an output or the SD/MP3 library functions will not work.

// Global vars
unsigned long time;
byte state;

void setup()
{
  // Setup the serial monitor
  Serial.begin(9600);

  // Setup the MP3 Shield
  Serial.print("Initializing MP3 shield...chip version: ");
  Serial.println(MP3.begin(MP3cmdChipSelect, MP3dataChipSelect));

  // Sound setup
  // A real-life UI should retrieve volume/balance/bass/treble settings
  // from a non-volatile memory and configure the MP3 Shield with these
  // settings.

  // Setup the SDCard, abort if no card present
  Serial.print("Initializing SD card...");
  if (!SD.begin(SDChipSelect)) {
    Serial.println("Card failed, or not present");
    return;
  }
  Serial.println("card initialized.");

  // Open a test file for demo purposes
  // The MP3 library allows only one file to be opened and played.
  // Make sure to close the playing file before opening a new file.
  if (MP3.open("test.mp3")) Serial.println("Error opening test.mp3");
  else MP3.play();      // If file opened ok, start playing the MP3
  // The MP3Play function will not skip ID3V2 tags
  // A ID3V2 parser could be implemented to improve the user
  // experience. Best would be to execute the parser before calling
  // MP3Play and adjusting mp3Position.
  // The extracted ID3 information can be used in a UI.
  // Check info on the web about ID3 tags.
  
  // Vars for demo only
  time = millis() + 5000;
  state = 0; 
}

void loop()
{
static int i;
int j;
static byte k;

  // Keep the MP3 chip fed with data from the sdcard
  // This function closes the file when no data is available anymore
  MP3.loop();
  
  // mp3Time holds the estimated play time in seconds. This is reasonable
  // accurate for CBR files, but not for VBR files.
  // Check MP3 file structure information to understand this.
  
  // Print the running time to the monitor.
  if (i != MP3.time) {
    Serial.print(MP3.time/60);
    j = MP3.time%60;
    Serial.print(":");
    if (j<10) Serial.print("0");
    Serial.println(j);
    i = MP3.time;
  }
  
  // Demo mode
  // Every 5 seconds switch to another play mode to demonstrate
  // all the available MP3 functionality in the MP3 library.
  if (time < millis()) {
    time = millis() + 5000;
    switch (state) {
      case 0:            // Stop playing, this will reset the MP3 player
        Serial.println("Stop");
        MP3.stop();
        state = 1;
        break;
      case 1:            // Start playing again from 0:00
        Serial.println("Play");
        MP3.play();
        k = 0;
        state = 2;
        break;
      case 2:            // Pause playing, no reset this time
        Serial.println("Pause");
        MP3.pause();
        state = 3;
        break;
      case 3:
        Serial.println("Play");
        MP3.play();      // Continue playing from the pause point
        state = 4;
        break;
      case 4:
        Serial.println("Fast Forward");
        MP3.ff(1000);    // Fast forward the song
        state = 5;
        break;
      case 5:
        Serial.println("Play");
        MP3.play();      // Release fast forward and continue playing
        state = 6;
        break;
      case 6:
        Serial.println("Fast Reverse");
        MP3.fr(1000);    // Fast reverse the song
        state = 7;
        break;
      case 7:
        Serial.println("Play");
        MP3.play();      // And release fast reverse, go to play again
        state = 8;
        break;
      case 8:
        if (k==0) Serial.println("Slowly mute volume");
        MP3.volume(k,k);  // Slowly mute volume
        time = millis() + 100;
        k++;
        if (k==100) {
          k = 0;
          state = 9;
        }
        break;
      case 9:
        if (k==0) Serial.println("Balance to left");
        MP3.volume(0,k);  // Mute right channel only = Balance
        time = millis() + 100;
        k++;
        if (k==100) {
          k = 0;
          Serial.println("Volume max");
          MP3.volume(0,0);
          state = 10;
        }
        break;
      case 10:
        if (k==0) Serial.println("Increase Bass");
        MP3.tone(8, 4, k, 10);      // Increase bass @ 100Hz / Treble is 0 at 4kHz
        time = millis() + 500;
        k++;
        if (k==15) {
          k = 0;
          Serial.println("No Bass");
          MP3.tone(8, 4, 0, 10);    // Reset default values
          state = 11;
        }
        break;
      case 11:
        break;
    }
  }
}



  • Model: XG8300
  • 99 Units in Stock
  • Manufactured by: DELCOMp


Copyright © 2017 CodeVisionAVR and X-Graph.