Go Down

Topic: Audio File Problem (Read 189 times) previous topic - next topic

Domino60


I have a problem using the right file, the VS1053B chip describs that it can play mp3 files

Decodes formats
Ogg Vorbis
MP3 = MPEG 1 & 2 audio layer III (CBR+VBR+ABR)
MP1 & MP2 = MPEG 1 & 2 audio layers I & II optional
MPEG4 / 2 AAC-LC(+PNS), HE-AAC v2 (Level 3) (SBR + PS)
WMA4.0/4.1/7/8/9 all profiles (5-384 kbps)
FLAC lossless audio with software plugin (upto 24 bits, 48 kHz)
WAV (PCM + IMA ADPCM)
General MIDI 1 / SP-MIDI format 0


I tried mp3, mp2, wav, non of them work correctly + I need to down my bit rate, but doing that
it kills the audio quality, any info on what's the best file format/specs for audio file, cause till now
I get only problems, non of the files are good quality.

I use Audacity to create my audio files.

Code:
Code: [Select]


#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>

#if defined(USE_MP3_REFILL_MEANS) && USE_MP3_REFILL_MEANS == USE_MP3_Timer1
  #include <TimerOne.h>
#elif defined(USE_MP3_REFILL_MEANS) && USE_MP3_REFILL_MEANS == USE_MP3_SimpleTimer
  #include <SimpleTimer.h>
#endif

SdFat sd;
SFEMP3Shield MP3player;
int16_t last_ms_char; // milliseconds of last recieved character from Serial port.
int8_t buffer_pos; // next position to recieve character from Serial port.
char buffer[6]; // 0-35K+null
int x;
void setup() {
  x = 0;
  uint8_t result;

  Serial.begin(115200);

  //Initialize the SdCard.
  if(!sd.begin(SD_SEL, SPI_FULL_SPEED)) sd.initErrorHalt();
  // depending upon your SdCard environment, SPI_HAVE_SPEED may work better.
  if(!sd.chdir("/")) sd.errorHalt("sd.chdir");
 
result = MP3player.begin();
x=1;

/*
MP3player.playTrack(1);
delay(150);
MP3player.stopTrack();

MP3player.playTrack(2);
delay(150);
MP3player.stopTrack();

MP3player.playTrack(3);
delay(150);
MP3player.stopTrack();

MP3player.playTrack(11);
delay(2000);
MP3player.stopTrack();
*/
}

void loop() {
 
  if(!MP3player.isPlaying()) {
    MP3player.playTrack(x);
   x+=1;
  }
  //delay(1000);
}
 
To be or not to be? Read a book and you will see.
Join Discord Free_World (Arduino_Room) Live chat
https://discord.gg/bBXEuKQ

MarkT

The datasheet says: "Note: Layer I / II decoding must be specifically enabled from register SCI_MODE."
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Domino60

Hi MarkT,

Thanks for info, but is there a guide how to do that?
I'll be looking as well but if you got any info on how, let me know pls.

Thanks in advance.

Best Regards,
 D60
To be or not to be? Read a book and you will see.
Join Discord Free_World (Arduino_Room) Live chat
https://discord.gg/bBXEuKQ

Domino60



So if I'm not mistaken I have just to define:

Code: [Select]

#define SM_STREAM           0x0040

/**
 * \brief A macro of the SM_EARSPEAKER_HI bit mask of the SCI_MODE register
 *
 * SM_STREAM activates VS1053b's stream mode. In this mode, data should be sent with as
 * even intervals as possible and preferable in blocks of less than 512 bytes, and VS1053b makes
 * every attempt to keep its input buffer half full by changing its playback speed upto 5%. For best
 * quality sound, the average speed error should be within 0.5%, the bitrate should not exceed
 * 160 kbit/s and VBR should not be used. For details, see Application Notes for VS10XX. This
 * mode only works with MP3 and WAV files.
 */


at the beginning of the code and that's it ?

As well make sure to manually set a constant bit rate for all my audio files:
Code: [Select]
void setBitRate(uint16_t);

I'll try this, if this doesn't work as well then not sure what else to do.
To be or not to be? Read a book and you will see.
Join Discord Free_World (Arduino_Room) Live chat
https://discord.gg/bBXEuKQ

MarkT

Does the datasheet explain the SCI_MODE register?
Have you read the source of the library?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Domino60

No,
Yes,

The above message is the "code"/comment from the library.

To be or not to be? Read a book and you will see.
Join Discord Free_World (Arduino_Room) Live chat
https://discord.gg/bBXEuKQ

MarkT

These are the mode bits defined in the VS1053B library
Code: [Select]


#define VS1053_MODE_SM_DIFF 0x0001
#define VS1053_MODE_SM_LAYER12 0x0002
#define VS1053_MODE_SM_RESET 0x0004
#define VS1053_MODE_SM_CANCEL 0x0008
#define VS1053_MODE_SM_EARSPKLO 0x0010
#define VS1053_MODE_SM_TESTS 0x0020
#define VS1053_MODE_SM_STREAM 0x0040
#define VS1053_MODE_SM_SDINEW 0x0800
#define VS1053_MODE_SM_ADPCM 0x1000
#define VS1053_MODE_SM_LINE1 0x4000
#define VS1053_MODE_SM_CLKRANGE 0x8000

So I presume you need to set the LAYER12 bit.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up