HE-AAC with VS1053

Designing hardware that uses VLSI Solution's devices as slave codecs such as an external MP3 decoder chip for a host microcontroller.
Post Reply
thba
User
Posts: 4
Joined: Wed 2020-07-22 20:07

HE-AAC with VS1053

Post by thba » Thu 2020-07-23 8:07

Hi,

I'm developing a internet radio application using a ESP32 MCU and a VS1053 is decoder.

In general that works fine, I can play various streams in MP3 or AAC (LC) format.

But there is one station which streams in HE-AAC and causes trouble:
It starts playing just fine, but after a random time (1 .. 10s) it stops. When it stops I'm observing the following:

- SCI_STATUS changes to 0xC and than 0x48 (was 0x40)
- HDAT1 changes to 0 (was "AT")
- DREQ is constant high

After that it is no longer possible to decode the stream. If I do a software reset of the VS1053, I can continue decoding the same stream.

For better analyzing I saved a part of the stream (see attach.) which I'm streaming from a server on the local network. Nevertheless I still observe the random lockups even it is always the same data.

So, my question is: Is there any "trick" I have to do, to successfully play HE-AAC files?

Thanks!

output from ffprobe:
Input #0, aac, from '988_FMAAC_orig.aac':
Duration: 00:01:14.89, bitrate: 65 kb/s
Stream #0:0: Audio: aac (HE-AAC), 44100 Hz, stereo, fltp, 65 kb/s
Attachments
988_FMAAC_orig.aac
(598.74 KiB) Downloaded 38 times

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

Re: HE-AAC with VS1053

Post by pasi » Thu 2020-07-23 10:21

Hi,

I can play your file without issues with vs1053b with and without the vs1053b-patches loaded.
- SCI_STATUS changes to 0xC and than 0x48 (was 0x40)
It sounds like vs1053b gets reset from somewhere. It could be an erraneous write to SCI (software reset), or something external.

The most probable issues are:
- chip select handling. You can only change the chip selects when the SPI is idle. Do you perform SCI reads during playing? Does it start to work if you do not read/write SCI registers during the playback?
- SPI clock speed. What's your SPI speed? It should be below CLKI/4, where CLKI is the internal clock of the vs1053b.

What SCI_CLOCKF value are you using?
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

thba
User
Posts: 4
Joined: Wed 2020-07-22 20:07

Re: HE-AAC with VS1053

Post by thba » Thu 2020-07-23 13:36

Hi,

thanks for conforming the stream is ok.

I don't do any SCI reads during playback, I only added it only later for debugging purposes.

Regarding SPI speed: for contol I'm using ~1.4Mhz and for data ~6Mhz[1].
CLOCKF is

Code: Select all

(HZ_TO_SC_FREQ(12288000) | SC_MULT_53_35X | SC_ADD_53_10X) [2]
- SPI clock speed. What's your SPI speed? It should be below CLKI/4, where CLKI is the internal clock of the vs1053b.
If I understand it correctly, my SPI speed is to high. I've changed the data SPI speed to

Code: Select all

I (749) VS1003_driver: data spi freq: 2962962
Now it plays for a couple of minutes, so it seems to work! Great, Thanks!

I want to use the highest speed possible, so what do you recommand for SPI control, data speed and CLOCKF?

[1]
13:22:20.416 > I (749) VS1003_driver: control spi freq=1403508
13:22:20.416 > I (749) VS1003_driver: data spi freq: 6153846

[2]
WriteSci(vs1003_drv, SCI_CLOCKF, HZ_TO_SC_FREQ(12288000) | SC_MULT_53_35X | SC_ADD_53_10X);

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

Re: HE-AAC with VS1053

Post by pasi » Thu 2020-07-23 13:42

If you're playing HE-AAC regularly, I would think you're not looking at the lowest possible power consumption, and thus I would suggest always using 5.0x clock instead of 3.5x+1.0x. That would also allow to use higher SPI clock (up to 15MHz instead of 10.5MHz).

You could change CLOCKF and your SPI speed depending on the format, but it might be too complex compared to the benefit.

If you can't get to 10MHz with 3.5x clock, then maybe there is a clock polarity issue. Note that for SCI reads the max clock is CLK/7, i.e. 6MHz with 3.5x clock, and 8.7MHz for 5.0x clock. Until you have written CLOCKF you should use around 1.5MHz (1*12.288MHz/7).
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

thba
User
Posts: 4
Joined: Wed 2020-07-22 20:07

Re: HE-AAC with VS1053

Post by thba » Thu 2020-07-23 16:34

I've set CLOCKF to 5.0x, but when playing AAC files 3Mhz SPI speed seems to be the maximum.

When using MP3 I can use SPI speeds > 10Mhz without any issue. It seems there is something special about AAC files ...

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

Re: HE-AAC with VS1053

Post by pasi » Fri 2020-07-24 10:03

(HE-)AAC should not be any different than mp3. It does decode directly from the stream buffer though, so DREQ probably goes up more often.

Check that you don't send more than 32 bytes after checking that DREQ is high.

Are you using the vs1053b-patches package?

Also note that mp3 resynchronizes easily (and is a more robust in decoding), so you don't necessarily notice bit errors and missing (or inserted) bytes.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

thba
User
Posts: 4
Joined: Wed 2020-07-22 20:07

Re: HE-AAC with VS1053

Post by thba » Sun 2020-07-26 21:13

I've tried a couple of combinations, the following works fine with HE-AAC: SPI speed 6.1Mhz and CLOCKF 3.5x+0.0x.

I've also tried to use the patches package. With the latest version (2.80) nothing works for me (even MP3).
Only the versions up to 2.00 without any extras (vs1053b-patches.plg) seem to work. Not sure what the reason might be ... maybe it has something to do with the size of the plugin.

Post Reply