VS1063 play G722 stream

Designing hardware that uses VLSI Solution's devices as slave codecs such as an external MP3 decoder chip for a host microcontroller.
Post Reply
madnik
User
Posts: 8
Joined: Wed 2017-02-08 2:52

VS1063 play G722 stream

Post by madnik » Mon 2019-01-28 16:13

Hello!
I have a question about working with audio G.722 codec.
I have two devices. The data is transmitted over the air between them.
It turns out that in order to start decoding on the receiver, I need to first turn on the receiver, then the transmitter. Is it possible for the transmitter to encode all time, and the receiver to turn on at any time? As I understand at the beginning of the encoding, some start information is required that is needed for the VS to determine the codec. How can I enable decoding at any place in the stream without rebooting the encoder?

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

Re: VS1063 play G722 stream

Post by pasi » Wed 2019-01-30 11:52

Because you know the format (and samplerate), you can generate a fixed header in the receiver and send that to vs1063 before you start sending the data.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

madnik
User
Posts: 8
Joined: Wed 2017-02-08 2:52

Re: VS1063 play G722 stream

Post by madnik » Wed 2019-01-30 17:59

Yes, thanks. I have already found a solution.
For my case:
1) For transmitter

Code: Select all

// Set bit 10 of SCI_AICTRL3, the RIFF WAV header is not generated.
vs_write_sci(SCI_RECMODE, RM_63_FORMAT_G722_ADPCM  | RM_63_ADC_MODE_MONO | RM_63_NO_RIFF);
2) For receiver

Code: Select all

// header for G722 
const uint8_t header[] = {
	0x52, 0x49, 0x46, 0x46,
	0xFF, 0xFF, 0xFF, 0xFF,
	0x57, 0x41, 0x56, 0x45,
	0x66, 0x6D, 0x74, 0x20,
	0x14, 0x00, 0x00, 0x00,
	0x8F, 0x02, 0x01, 0x00,
	0x80, 0x3E, 0x00, 0x00,
	0x40, 0x1F, 0x00, 0x00,
	0x01, 0x00, 0x04, 0x00,
	0x02, 0x00, 0x02, 0x00,
	0x64, 0x61, 0x74, 0x61,
	0xFF, 0xFF, 0xFF, 0xFF
};
	
// send header before stream
vs_write_sdi(header, SDI_MAX_TRANSFER_SIZE);
vs_write_sdi(&header[SDI_MAX_TRANSFER_SIZE], sizeof(header) - SDI_MAX_TRANSFER_SIZE);

madnik
User
Posts: 8
Joined: Wed 2017-02-08 2:52

Re: VS1063 play G722 stream

Post by madnik » Fri 2021-02-19 10:32

Hello again. Returned to this project.
Now I am using G722 16kHz 64kbit.
Sometimes, when I turn on or off the receiving device, the data stream is not decoded correctly and only noise is reproduced. As far as I understand, the receiver is not synchronized with the stream.
How should the received stream be synchronized?

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

Re: VS1063 play G722 stream

Post by pasi » Mon 2021-02-22 14:55

Hi,

I thought the decoder would eventually get back in sync, because it has (should have) code to saturate the states, and thus be able to pick up decoding mid-stream.

We'll need to take a look at that.
Edit: In my tests of starting the decoding at various parts of my test g722 file it worked perfectly each time. Even cutting portions of the file didn't cause any issues.

In the meanwhile you could try IMA ADPCM, because that is able to resynchronize and allows you to determine if there are also other restarting issues.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

madnik
User
Posts: 8
Joined: Wed 2017-02-08 2:52

Re: VS1063 play G722 stream

Post by madnik » Wed 2021-02-24 10:01

First thanks for the help!

I found an interesting effect.
When my board is powered on and a new firmware is being written, the stream always starts. Empirically, I found that adding a delay after initialization of vs1063 about 3 seconds also leads to a good result. Initialization is the same as in the examples. Then I start playing in the same way as in the examples. Next, I wait for the 3 kilobyte buffer to accumulate. After that I load the fixed header and then the buffer (no SDI data before that). Then I just copy the incoming stream to SDI. The encoded data stream is transmitted from another vs1063 in real time without interruption.
What could be the reason for the need for such a delay?
Perhaps I need to change the initialization? In other projects, when working with local data, everything works well.

Post Reply