streaming to a pc

Writing software that controls the system and peripherals such as displays, SD cards, Buttons, LEDs, Serial Ports etc.
Post Reply
loggermaker
User
Posts: 3
Joined: Wed 2015-09-23 10:12

streaming to a pc

Post by loggermaker » Wed 2015-09-23 10:33

I would like to use an embedded encoder (eg using VS1063 but would consider others if more appropriate) to

i) encode an audio signal (probably Vorbis)
ii) stream the encoded data over a serial communications link (in packets) to a PC
iii) have the PC play the streamed audio live and also store it to a file.

Can anyone point me in the right direction for doing this please?

I can use a dsPIC or some other microcontroller to configure the VLSI chip appropriately.
The dsPIC would then read probably read encoded data out of the VS1063, split it into packets and send it over a serial link which is eventually received by a PC running Windows.

IMPORTANT: The PC might start receiving the streamed data anywhere in the stream so may not get any header information at the start of the stream.

We have a serial communication link working, but playing on a PC / getting the data into a correct format for saving to a file might be an issue for me.

Any advice especially on reconstructing the encoded data stream and playing on a PC would be appreciated.

Kind regards,

Derek

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

Re: streaming to a pc

Post by pasi » Wed 2015-09-23 10:54

The vs1063a encoder has an UART output mode with adjustable baud/rate. So all your controller needs to do is start the encoding mode with the right parameters and select the UART output.

In the PC you would just save the received data into a file.

However, if the PC needs to pick up at any point of the stream, then you either need to use mp3, or have handshaking from the PC to the controller to (stop and) restart encoding when the PC wants to start listening.

Or if you know the encoding parameters, it is conceivable to just add the right Ogg Vorbis header in the PC, and perhaps find the Ogg Vorbis frame boundaries before starting appending the data from the UART.

With a small user application and a SPI EEPROM for boot the vs1063a could do this by itself.

(We actually have an UART streaming example in the works, and it currently supports mp3. Maybe the restart-handshaking could be a feature to add when other formats with headers are added.)
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook

loggermaker
User
Posts: 3
Joined: Wed 2015-09-23 10:12

Re: streaming to a pc

Post by loggermaker » Wed 2015-09-23 13:23

Thank you for that information pasi- it was most helpful.
I think we will use mp3 to start with as that is easiest and gets us a first release.

When we get that working we can look at using VORBIS and adding a VORBIS header at the PC end. The advantage of VORBIS is that it would work down to 8kbps I think unlike MP3. With very poor communication systems that we might get sometimes we may need that ability. But for a first step MP3 operating down to 32kbps would be fine.

I would be very interested in your UART streaming example when you release it because I think we could use that. I will probably message you in a few weeks to check on that if you don't mind!

Kind regards,
Derek

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

Re: streaming to a pc

Post by Henrik » Wed 2015-09-23 13:56

Hello!

Our MP3 encoder can also get downto 8 kbps if you set it to 8, 11, 12, 16, 22, or 24 kHz sample rate (8 kHz mono strongly recommended). The sound quality will be in the "guess who's talking" domain, but you can do it. When bitrate is increased even slightly, audio fidelity quickly gets better. Already 16 kbps is quite usable.

Below are some examples made with the VS1063 MP3 encoder at different bitrates. Sample rates are selected as recommended in the VS1063a Datasheet Chapter 9.3.1, Supported MP3 Encoding Formats. Actually, I verified the recommended sample rates for this message, and they seemed to be optimal.

Having said all this, if you require the "best bang for the buck", or in other words, the best quality for a given bitrate, then Ogg Vorbis should be your choice. From a technical standpoint, it is the better format of the two, and our Ogg Vorbis encoder is slightly more highly tuned than our MP3 encoder counterpart. Then again, our Ogg Vorbis encoder doesn't have a CBR (Constant Bit-Rate) mode, so if you require the bit-rate to stay absolutely where you command it to, MP3 might still be your best bet.

Kind regards,
- Henrik
Attachments
vs1063enc_08kHz_08kbps.mp3
VS1063a: 8 kHz mono encoded to 8 kbps MP3
(58.78 KiB) Downloaded 130 times
vs1063enc_08kHz_16kbps.mp3
VS1063a: 8 kHz mono encoded to 16 kbps MP3
(117.56 KiB) Downloaded 128 times
vs1063enc_12kHz_24kbps.mp3
VS1063a: 12 kHz mono encoded to 24 kbps MP3
(176.06 KiB) Downloaded 137 times
vs1063enc_16kHz_32kbps.mp3
VS1063a: 16 kHz mono encoded to 32 kbps
(234.7 KiB) Downloaded 139 times
Good signatures never die. They just fade away.

loggermaker
User
Posts: 3
Joined: Wed 2015-09-23 10:12

Re: streaming to a pc

Post by loggermaker » Wed 2015-09-23 14:07

Thanks Henrik,

Excellent- I didn't realise that we could go down to 8kbps with your mp3 encoder. I guess I had some pre-conceived idea about mp3 encoding. It's clear that at 16kpbs the quality is much better but in any case, I think we can use it.

Thanks again.

Derek

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

Re: streaming to a pc

Post by Henrik » Wed 2015-09-23 14:38

You're welcome, Derek!

As a format, MP3 can encode to 32-320 kbps at sample rates 32, 44.1, and 48 kHz, and to 8-160 kbps at samplerates 8, 11.025, 12, 16, 22.05, and 24 kHz. Our encoder supports all these modes.

There are some pretty pathological sample rate / mono/stereo / bit-rate combinations, though. If you want to have some "fun", try to encode 16 or 24 kHz stereo to 8 kpbs. I dare you to recognize even the song you are encoding, because all you'll end up with is a few bleeps! Then again, it is equally pointless to encode 8 kHz mono at 160 kbps. After all, uncompressed 16-bit 8 kHz PCM is only 128 kbps, so compressing it to a larger, still lossy MP3 file makes absolutely no sense!

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

ducls
User
Posts: 2
Joined: Fri 2019-05-24 6:14

Re: streaming to a pc

Post by ducls » Fri 2019-05-24 6:37

Hi pasi,
Could you please post your UART streaming example, I'm very interested because my project is the same and I got stuck with this :(

Post Reply