VS1053 split Ogg stream uninterrupted audio

Designing hardware and software for systems that use the VS1010 MP3 Audio DSP Microcontroller.
Post Reply
davideferrario
User
Posts: 4
Joined: Fri 2019-07-12 16:39

VS1053 split Ogg stream uninterrupted audio

Post by davideferrario » Fri 2019-07-19 16:57

Hello,

I am working on an ESP32 + VS1053 based Ogg audio record that will send audio files to a web server. I'd like split continuos audio into sequential files (of about 1 minute time lenght).

I am able to start VL1053 chip, start Ogg recording and save data to SD card.

In forum (viewtopic.php?f=11&t=1345&p=5975&hilit= ... tart#p5975) I see an old answer "If you need uninterrupted audio, then you need to store the header in a separate place so that you can apply it in front of any subsequent piece of the whole stream".

From Ogg stream, how can I identify the Ogg header I have to apply to every file?

Thank you

User avatar
Panu
VLSI Staff. Currently on holiday.
Posts: 2691
Joined: Tue 2010-06-22 13:43

Re: VS1053 split Ogg stream uninterrupted audio

Post by Panu » Fri 2019-07-19 21:31

Hi!

Hmm, I started to write an answer, but it seems that Henrik has already explained it in the post to which you link (the part with the OggS strings etc).

Maybe these can help you further:
Ogg bitstream reference: https://xiph.org/vorbis/doc/oggstream.html
Vorbis framing reference: https://xiph.org/vorbis/doc/framing.html

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

davideferrario
User
Posts: 4
Joined: Fri 2019-07-12 16:39

Re: VS1053 split Ogg stream uninterrupted audio

Post by davideferrario » Mon 2019-07-22 13:49

Hello,

I can not find in the older answer of Henrik and in the two links you paste how to detect the Ogg header that I need to save and replicate for different files.

Thank you

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

Re: VS1053 split Ogg stream uninterrupted audio

Post by Henrik » Fri 2019-07-26 11:31

Hello!
davideferrario wrote:
Fri 2019-07-19 16:57
I am working on an ESP32 + VS1053 based Ogg audio record that will send audio files to a web server. I'd like split continuos audio into sequential files (of about 1 minute time lenght).

I am able to start VL1053 chip, start Ogg recording and save data to SD card.

In forum (viewtopic.php?f=11&t=1345&p=5975&hilit= ... tart#p5975) I see an old answer "If you need uninterrupted audio, then you need to store the header in a separate place so that you can apply it in front of any subsequent piece of the whole stream".

From Ogg stream, how can I identify the Ogg header I have to apply to every file?
The instructions in the message you quoted is for a situation where you encode audio continuously, but someone comes in the middle of the stream to listen. In that case the headers need to be sent to the receiver before any audio data.

Your situation is different. If I understand correctly, you want to write separate Ogg Vorbis files which could be decoded (with some standard tools) to a continuous audio stream. (If I misunderstood, please let me know!)

Unfortunately your situation is tricky. To do what you require needs deep understanding on how the actual Vorbis audio data is encoded, because it would require certain pieces of compressed audio data to be duplicated to guarantee separate streams that could be combined seamlessly.

If you are ok with there being a seam, or missing audio for 3-20 milliseconds between files, then you can use the copy-headers method. In this method, you copy all data from the beginning of the file to the point where you see the first Ogg frame that does not contain the string "vorbis". Example below is a file created with an old version of the VS1053 Ogg Vorbis Encoder:

Code: Select all

0000  4f 67 67 53 00 02 00 00  00 00 00 00 00 00 78 56  |OggS..........xV|
0010  34 12 00 00 00 00 d8 0b  d5 86 01 1e 01 76 6f 72  |4.....Ø.Õ....vor|
0020  62 69 73 00 00 00 00 02  44 ac 00 00 00 00 00 00  |bis.....D¬......|
0030  58 0f 02 00 00 00 00 00  b8 01 4f 67 67 53 00 00  |X.......¸.OggS..|
0040  00 00 00 00 00 00 00 00  78 56 34 12 01 00 00 00  |........xV4.....|
0050  27 de 7a 38 01 38 03 76  6f 72 62 69 73 10 00 00  |'Þz8.8.vorbis...|
0060  00 56 4c 53 49 20 53 6f  6c 75 74 69 6f 6e 20 4f  |.VLSI Solution O|
0070  79 01 00 00 00 14 00 00  00 45 4e 43 4f 44 45 52  |y........ENCODER|
0080  3d 56 53 31 30 35 33 20  76 31 2e 35 30 01 4f 67  |=VS1053 v1.50.Og|
0090  67 53 00 00 00 00 00 00  00 00 00 00 78 56 34 12  |gS..........xV4.|
00a0  02 00 00 00 11 a1 cb 59  05 ff ff ff ff cf 05 76  |.....¡ËY.ÿÿÿÿÏ.v|
00b0  6f 72 62 69 73 0d 42 43  56 01 00 40 00 00 26 49  |orbis.BCV..@..&I|
[...]
0570  00 00 00 02 00 00 00 04  04 4f 67 67 53 00 00 40  |.........OggS..@|
0580  e7 00 00 00 00 00 00 78  56 34 12 03 00 00 00 4c  |ç......xV4.....L|
0590  cc cb 51 51 11 11 1b 1b  1b 1b 1b 1b 1b 1b 1b 1b  |ÌËQQ............|
05a0  1b 1b 1b 1b 1b 1b 1b 1b  1b 1b 1b 1b 1b 1b 1b 1b  |................|
[...]
In the example, you can find the OggS string at offsets 0x0000, 0x003a, 0x008e, and 0x579. In the three first frames, you can find the "vorbis" string a little bit later, so they are headers that need to be copied to the beginning of each file. The frame starting from 0x579 is audio data, and you don't need to copy that data to each Ogg Vorbis file.

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

davideferrario
User
Posts: 4
Joined: Fri 2019-07-12 16:39

Re: VS1053 split Ogg stream uninterrupted audio

Post by davideferrario » Fri 2019-07-26 15:15

Thank you Henrik.

You understand correctly my situation and thank you for your answer.

I think I understood your explanation and I think I am able to implement it in ESP32 source code.

Thank you really much.

Post Reply