Adjusting Volume on MusicPlayer Sheild VS1053

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ryandewitt
 
Posts: 9
Joined: Mon Nov 21, 2016 4:36 pm

Adjusting Volume on MusicPlayer Sheild VS1053

Post by ryandewitt »

Listening to headphones using the inline barrel jack. The musicPlayer.setVolume(20,20) line does not seem to adjust the volume. Any tips? Whether it's O or 255 makes no diff. Thanks

Code: Select all

/*************************************************** 

// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>

// define the pins used
#define CLK 13       // SPI Clock, shared with SD card
#define MISO 12      // Input data, from VS1053/SD card
#define MOSI 11      // Output data, to VS1053/SD card
// Connect CLK, MISO and MOSI to hardware SPI pins. 
// See http://arduino.cc/en/Reference/SPI "Connections"

// These are the pins used for the breakout example
#define BREAKOUT_RESET  9      // VS1053 reset pin (output)
#define BREAKOUT_CS     10     // VS1053 chip select pin (output)
#define BREAKOUT_DCS    8      // VS1053 Data/command select pin (output)
// These are the pins used for the music maker shield
#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)
#define SHIELD_CS     7      // VS1053 chip select pin (output)
#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield
#define CARDCS 4     // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin

// The relay to control the tens unit
#define SWITCH 7

// Define timing
#define SOUND_ON_TIME 5
#define SOUND_DELAY 5
#define SWITCH_ON_TIME 5
#define SWITCH_DELAY 5
                                                                                                                                                                                                                          
int mode;
int previousRandomInt = 0;
char randNumberString = "wav";
long indexToWrite;
long randNumber = random(3);

char toPlay[11];     //  string array for file to play 00.mp3 to 49.mp3

Adafruit_VS1053_FilePlayer musicPlayer = 
  // create shield-example object!
  Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
  
void setup() {
  Serial.begin(9600);
  pinMode(SWITCH, OUTPUT); 
  Serial.println("VS1053 Simple Test");

  if (! musicPlayer.begin()) { // initialise the music player
     Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
     while (1);
  }
  Serial.println(F("VS1053 found"));

musicPlayer.sineTest(200, 500);    // Make a tone to indicate VS1053 is working

   if (!SD.begin(CARDCS)) {
    Serial.println(F("SD failed, or not present"));
    while (1);  // don't do anything more
  }
  
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(20,20);

  // If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background
  // audio playing
  musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int
}

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adjusting Volume on MusicPlayer Sheild VS1053

Post by adafruit_support_mike »

What are you using as a power source?

Speakers.. even headphones.. are current-hungry, and the most common reason for "changing the volume has no effect" is that the power supply is already maxed out.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”