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.
User avatar
pasi
VLSI Staff
Posts: 1510
Joined: Thu 2010-07-15 16:04

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

Post by pasi » Fri 2017-12-29 16:20

XTALI up to 14.318318MHz will most probably work, and even above that you probably have no issues as long as the max internal clock frequency is within limits.

Vorbis decoding sets the sample counter to specific values when it knows 'where it is'.

SampleCounter of the vs1053b patches package advances for each DAC interrupt whether there is a sample waiting or not. So, you should get a steady increment by samplerate each second. The first increment per 10s is 438040, the following are either 441363 or 441319 (only twice, each time 44 samples less, which means 1ms), so seem very steady. From 10s to 90s we get 44134.6625Hz, which is only 0.08% from nominal, which can be accounted by crystal frequency difference.

So, it looks like the issue appears just at the beginning. Could you do a read after each 500ms without clearing the sample counter at the beginning? If you read the first time just before sending data to SDI, you should get a few too many samples in the sample counter.

If there are audio underflows, the sample counter does not correspond to the decoded sample. You can read the number of audio underflows from Y:0x1a82 (WRAMADDR=0x5a82). Write 0 somewhere at the beginning.

User avatar
Henrik
VLSI Staff
Posts: 1107
Joined: Tue 2010-06-22 14:10

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

Post by Henrik » Tue 2018-01-09 12:23

Hello!
fwachsmuth wrote:
Thu 2017-12-21 16:47
It's year-end break time, so finally I got time for this project again. :)

To whom it may concern, I think there is a mistake in the 1053b patched PDF on page 12:

Code: Select all

unsigned long Read32BitsFromSCI(unsigned short memAddr) {
  unsigned short msbV1, lsb, msbV2;
  WriteVS10xxRegister(SCI_WRAMADDR, addr+1);
  msbV1 = (u_int16)ReadVS10xxRegister(SCI_WRAM);
  WriteVS10xxRegister(SCI_WRAMADDR, addr);
  lsb   = (u_int32)ReadVS10xxRegister(SCI_WRAM);
  msbV2 = (u_int16)ReadVS10xxRegister(SCI_WRAM);
  if (lsb < 0x8000U) {
    msbV1 = msbV2;
  }
  return ((u_int32)msbV1 << 16) | lsb;
}
This should use either addr or memAddr, but not both, correct?
You are quite right. The document will be corrected when the next patch version is released.

Kind regards,
- Henrik
Good signatures never die. They just fade away.

User avatar
Henrik
VLSI Staff
Posts: 1107
Joined: Tue 2010-06-22 14:10

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

Post by Henrik » Tue 2018-01-09 12:49

Hello!
fwachsmuth wrote:
Thu 2017-12-28 16:18
I made a 100 second m4a file with 44.1kHz. When playing it back, the sample count register is at about 4405286 (+/-200) at the end, so it somehow missed some samples. However, the playback time of rendered output is exactly 100 seconds long (I recorded the 1053 output with a DAW to verify).
What you are seeing is actually normal, and, rest assured, no samples are missed.

Let me explain. When you have sent the last bytes of the m4a file to VS1053, it hasn't fully played yet. The last kilobyte of your file is still waiting for processing in the VS1053 bitstream buffer. Even when the bits have been completely decoded, it will take an additional 2048 stereo samples before the file has fully come out of the audio buffer. So, even after you have sent the whole file, it will still play for a while. All of this can easily explain the discrepancy of a few thousand samples you are seeing, or even more for a low-bitrate stream, e.g. an 8 kbit/s mono 24 kHz MP3 file could show an "error" of up to about 25000 samples.

Kind regards,
- Henrik
Good signatures never die. They just fade away.

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

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

Post by fwachsmuth » Sat 2018-01-13 14:28

Thanks, guys. I am making serious progress now. :)

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

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

Post by fwachsmuth » Sun 2018-03-18 22:47

Guys,

thanks once again for all your great support. I finally managed to get everything going as intended and spent the last nights of my spare time on routing the PCB for my (currently three Breadboard spanning) project. Can't wait to get it delivered and see if it works. I'll keep you posted once it plays Hello World ;)

One more Question though for phase 2 of my project: Is samplerate finetuning possible during recording as well? Pasi mentioned "directly controlling the 20 sample control register when one has no memory for the patches" -- could you elaborate a bit further how and if this would allow recording with changing sample rates? (And yes, I know how that will sound, I need it though anyway...)


F

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

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

Post by fwachsmuth » Tue 2018-04-03 20:46

Any hint or insight for me regarding Samplerate Finetuning while recording? Would be much appreciated :)

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

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

Post by pasi » Thu 2018-04-05 17:35

fwachsmuth wrote:
Tue 2018-04-03 20:46
Any hint or insight for me regarding Samplerate Finetuning while recording? Would be much appreciated :)
There is no perfect solution, and the imperfect solution is also very hard.

Usually the encoder is the clock master, and other parts adapt to the produced rate. What causes you the need to adjust the encoding rate?
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

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

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

Post by fwachsmuth » Fri 2018-04-06 8:29

I want to record Audio in sync to old film cameras — such as Super 8 or even using a (wind-up) spring motor. These cameras don’t run perfectly stable, often +/- 10% off the desired frame rate, and then not even steady due to mechanical challenges.

My idea is to take the actual camera Speed (measured) and modulate the sampling rate accordingly, so that I get a “lip synced” audio recording.

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

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

Post by pasi » Mon 2018-04-09 9:30

Interesting.

The vs1063a patches has an "exact rate" option for encoding. The rate could also be changed during encoding, there just isn't a mechanism to do that in the patches package.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

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

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

Post by fwachsmuth » Mon 2018-04-09 10:23

That sounds promising. I guess tweaking a SCI_WRAM register should do the trick, similar as with 1053 playback?
I'll get my hands on a 1063 BoB soon to play with this. :)

Post Reply