Can I change 1053 playback speed with a DDS as XTAL?

Designing hardware that uses VLSI Solution's devices as slave codecs such as an external MP3 decoder chip for a host microcontroller.
fwachsmuth
Senior User
Posts: 28
Joined: Sun 2016-01-10 14:58

Re: Can I change 1053 playback speed with a DDS as XTAL?

Post by fwachsmuth » Tue 2019-02-05 16:19

You are right.
It was my code being bad, now it works. Feels good to not have to peek for Byte 40 and 41 in the file header :)

fwachsmuth
Senior User
Posts: 28
Joined: Sun 2016-01-10 14:58

Re: Can I change 1053 playback speed with a DDS as XTAL?

Post by fwachsmuth » Thu 2019-02-07 13:50

Sorry for being so persistent, but I have one more question.

To allow a "sync start" with my film projector, I load the audio file and pause it right away, so that I can start it without any further delay once the film starts. However, when the audio doesn't start with silence, one can hear a brief piece of the audio before playback is paused.

While trying to find out why this is, I found this in the vs1053 library I use, look at the bottom:

Code: Select all

uint8_t vs1053::playFile(char* fileName, uint32_t timecode) {

  if(isPlaying()) return 1;
  if(!digitalRead(MP3_RESET)) return 3;

  //Open the file in read mode.
  if(!track.open(fileName, O_READ)) return 2;

  // find length of array at pointer
  int fileNamefileName_length = 0;
  while(*(fileName + fileNamefileName_length))
    fileNamefileName_length++;

  playing_state = playback;
  
  Mp3WriteRegister(SCI_DECODE_TIME, 0); // Reset the Decode and bitrate from previous play back.
  delay(100); // experimentally found that we need to let this settle before sending data.

  //gotta start feeding that hungry mp3 chip
  refill();

  //attach refill interrupt off DREQ line, pin 2
  enableRefill();

  return 0;
}
It seems the delay(100) is the culprit. When I remove it, the "loading noise" is gone. However, the sampling rate returned from SCI_AUDATA is now 8 kHz, even for a 44.1 kHz file. The delay really seems to fix this, but I could not go below 50 ms (which can still cause very audible noise).

I actually wonder why the line

Code: Select all

Mp3WriteRegister(SCI_DECODE_TIME, 0);
is necessary at all. If I don't write that zero, I also get 8 kHz reported back (no matter if I wait in a delay or not).

Is there any way to "pause-load" a track (for immediate playback start) without having audible artefacts from the first bytes AND having the correct sampling rate in SCI_AUDATA?

 Should I read the Samping rate from Byte 40:41 again and write it to SCI_AUDATA? That would feel very hacky...


User avatar
pasi
VLSI Staff
Posts: 1560
Joined: Thu 2010-07-15 16:04

Re: Can I change 1053 playback speed with a DDS as XTAL?

Post by pasi » Fri 2019-02-08 13:38

Are you implementing pause by pausing the sending of the data?

You see 8000Hz in SCI_AUDATA until the decoder has a) successfully received a full mp3 frame, b) successfully decoded the frame and c) has output the first samples to the audio FIFO. If you wain until AUDATA is updated, the first audio frame has been decoded and sent to audio FIFO. After the samples have been played, and the audio FIFO underflows, the output will be faded towards zero. When you continue sending data, the next frame gets decoded, is windowed with the samples from the previous frame, is output, and the output jumps from zero to the level of the first sample in the second frame, causing a "snap".

The vs1053b patches package has a pause mode (compatible with vs1063a pause mode). If you set the bit, the input data is not read from the stream FIFO until you clear it. You can fill the stream FIFO, then clear the pause bit when you want to start decoding. However, AUDATA gets updated only after you clear pause, and there will be some delay in decoding the first audio frame that you must account for.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

Post Reply