VS1063A full-duplex operation query

Writing software that controls the system and peripherals such as displays, SD cards, Buttons, LEDs, Serial Ports etc.
Post Reply
Redhatter
User
Posts: 3
Joined: Sat 2018-02-10 6:50

VS1063A full-duplex operation query

Post by Redhatter » Sat 2018-02-10 7:05

Hi all,

I'm looking at building myself a small media player and WiFi-enabled full-duplex wireless audio streamer with the idea of making a device that can plug into a headset and making it wireless.

https://hackaday.io/project/49280/details/

Likely, I'll use the ESP8266 or ESP32 as the brains of the operation, and looking around, the VS1063a looked pretty good on the feature front in terms of offering both encoding and decoding of a number of CODECs. Back-of-the-envelope calculation suggests the 1.92Mbps data rate needed for 48kHz stereo 16-bit PCM, with a mono 48kHz 16-bit PCM back-channel can be met by WiFi… but will likely put a heavy load on a 11Mbps data link.

Sometimes you want lossless, other times, lossy compression is fine. This is where I think the VS1063a can come in. Now, in my research, I did stumble across this thread:

viewtopic.php?t=1566

That suggests, while the chip *can* do encode and decode, it can't do both simultaneously, at least not for MP3. I suspect the situation is similar for Vorbis, which would be my preferred CODEC.

One option is to use two VS1063as, one to encode, the other to decode. I am also looking at whether decoding could be done on the MCU and using the VS1063a to do the encode (which is more resource intensive). The decoding of Vorbis looks doable on ESP32:

http://iot-bits.com/ogg-vorbis-on-esp32-pico-d4/

The other end of the link may be another ESP32/8266 with a VS1063a, or it could be a laptop/desktop PC with some software linked into the PulseAudio or JACK audio stacks that connects over WiFi.

The question is… if a VS1063a is busy encoding a mono (from a microphone) stream at 48kHz sample rate, can I still feed it a stereo PCM stream to be played out the DAC? If I want a full-duplex stream between two VS1063a's linked via a wireless link, what options are available for audio CODECs?

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

Re: VS1063A full-duplex operation query

Post by Henrik » Mon 2018-02-12 9:48

Hello!

And welcome to our forum!

First of all let me thank you for explaining your system requirements and thought processes so eloquently! It makes it so much easier to write a (hopefully) useful answer.
Redhatter wrote:
Sat 2018-02-10 7:05
The question is… if a VS1063a is busy encoding a mono (from a microphone) stream at 48kHz sample rate, can I still feed it a stereo PCM stream to be played out the DAC?
Yes, you can. We call this codec mode in the VS1063 datasheet.
If I want a full-duplex stream between two VS1063a's linked via a wireless link, what options are available for audio CODECs?
Your options are PCM, G.711 (either u-law or A-law), G.722 ADPCM, and IMA ADPCM. Apart from PCM the best-sounding format is G.722 ADPCM, but because of its CPU intensity it's pretty much limited to encoding up to 16 kHz. Note that unless you use AEC, you can combine codecs and their sample rates freely: VS1063's input may be e.g. stereo 48 kHz 16-bit PCM, but at the same time it can encode e.g. mono 8 kHz IMA ADPCM.

If you want to try the two-VS1063 route or decoding-by-microcontroller route, MP3 and Ogg Vorbis are also options. Note, however, that these formats have significantly longer system delays (see VS1063 Datasheet Chapter 11.6.10, Estimated Maximum Encoder/Decoder Delays).

One thing you might not be aware of is that - for historical reasons - reading data from VS1063 has a 100% overhead. So, to read a mono 48 kHz 16-bit PCM stream, you actually have to transfer 1.536 Mbit/s over the SCI/SPI bus. The SDI/SPI bus that you use for sending data to VS1063 doesn't have this overhead. So, if you want to send a 48 kHz stereo stream and receive a 48 kHz mono stream, you are going to transfer 3.072 Mbit/s over the two SPi buses.

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

Redhatter
User
Posts: 3
Joined: Sat 2018-02-10 6:50

Re: VS1063A full-duplex operation query

Post by Redhatter » Sun 2018-02-18 2:08

Henrik wrote:
Mon 2018-02-12 9:48
Hello!

And welcome to our forum!

First of all let me thank you for explaining your system requirements and thought processes so eloquently! It makes it so much easier to write a (hopefully) useful answer.
No problems there, comes with the frustrations of answering other peoples' vaguely put questions. Thus I thought I'd put it all up-front. :-)
Henrik wrote:
Mon 2018-02-12 9:48
Redhatter wrote:
Sat 2018-02-10 7:05
The question is… if a VS1063a is busy encoding a mono (from a microphone) stream at 48kHz sample rate, can I still feed it a stereo PCM stream to be played out the DAC?
Yes, you can. We call this codec mode in the VS1063 datasheet.
If I want a full-duplex stream between two VS1063a's linked via a wireless link, what options are available for audio CODECs?
Your options are PCM, G.711 (either u-law or A-law), G.722 ADPCM, and IMA ADPCM. Apart from PCM the best-sounding format is G.722 ADPCM, but because of its CPU intensity it's pretty much limited to encoding up to 16 kHz. Note that unless you use AEC, you can combine codecs and their sample rates freely: VS1063's input may be e.g. stereo 48 kHz 16-bit PCM, but at the same time it can encode e.g. mono 8 kHz IMA ADPCM.
I was wondering about G.722… 16kHz would be fine for VoIP applications; it'll sound better than Bluetooth (woohoo, 8kHz, hello 1986!), but by the sounds of things, two VS1063a's is going to be the vastly more flexible option as I then get the choice of any two CODECs.

It also means I could be using one VS1063a in "low-fi" mode for computer interaction whilst playing music from a SD card. I'm not sure if that would be doable with one chip.
Henrik wrote:
Mon 2018-02-12 9:48
If you want to try the two-VS1063 route or decoding-by-microcontroller route, MP3 and Ogg Vorbis are also options. Note, however, that these formats have significantly longer system delays (see VS1063 Datasheet Chapter 11.6.10, Estimated Maximum Encoder/Decoder Delays).
Probably the biggest use case of Vorbis or MP3 would be streaming audio from a computer to the VS1063, there, the 36ms delay would be barely noticeable for most applications. So likely MP3 might be used for computer→VS1063; and G.722 for VS1063→computer, unless I really wanted the higher fidelity, then maybe I might use MP3, or more probable, PCM.
Henrik wrote:
Mon 2018-02-12 9:48
One thing you might not be aware of is that - for historical reasons - reading data from VS1063 has a 100% overhead. So, to read a mono 48 kHz 16-bit PCM stream, you actually have to transfer 1.536 Mbit/s over the SCI/SPI bus. The SDI/SPI bus that you use for sending data to VS1063 doesn't have this overhead. So, if you want to send a 48 kHz stereo stream and receive a 48 kHz mono stream, you are going to transfer 3.072 Mbit/s over the two SPi buses.
Yep, I had read that bit; thankfully bandwidth of the SPI bus is a plentiful resource, compared to radio link bandwidth, which is where I'm particularly paying attention. It's not hard for a MCU to emit zeros or drop half a frame.

I shall ponder this some more, but the concept looks doable.

Redhatter
User
Posts: 3
Joined: Sat 2018-02-10 6:50

Re: VS1063A full-duplex operation query

Post by Redhatter » Sun 2018-02-18 7:50

One further query… I'm still looking into the dual-chip solution as I think that's going to be by far the most flexible. The application I'm thinking of also calls for a SD card interface for local media playback.

A conundrum of sorts was raised when I considered how I was going to keep the buffers of all devices suitably fed with data. The ESP32 has just two SPI busses; HSPI and VSPI. Most MCUs have at most, three. Bit-banging is undesirable since we're dealing with audio; that's hard-realtime.

There are some MCUs out there that feature as many as 6 SPI busses, but I was trying to avoid having another MCU aside from the ESP chip in there.

Having a look at the application notes I see the following suggested configuration for sharing the VS10xx with another device:
Image

Question is, how safe is it to put two VS1063as together in that configuration? Or would I be better that my proposed SD card piggy-back off one of the VS1063As? Aside from hooking the DREQ pins to separate GPIOs, and watching those closely, are there any other gotchas I should be wary of?

User avatar
Panu
VLSI Staff
Posts: 2585
Joined: Tue 2010-06-22 13:43

Re: VS1063A full-duplex operation query

Post by Panu » Mon 2018-02-19 10:20

any other gotchas I should be wary of?
No, seems quite ok. Note that you'll need to run both VS10x3 chips in NEW_MODE (the "normal" SPI mode, default for VS10x3) and you'll need to connect both chip selected (XCS, XDCS) separately per each chip.

Although if you only do recording on the other chip and never playback, then I guess you don't need XDCS on that one...

-Panu
Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

Post Reply