OggInsert: Add comments to Ogg Vorbis files with microcontroller

Writing software for systems that use VLSI Solution's devices as slave codecs to a host microcontroller.
Post Reply
User avatar
Henrik
VLSI Staff
Posts: 1147
Joined: Tue 2010-06-22 14:10

OggInsert: Add comments to Ogg Vorbis files with microcontroller

Post by Henrik » Fri 2019-04-12 12:14

Hello!

There have occasionally been questions by our customers whether it would be possible to add custom comments to Ogg Vorbis files. Our ICs don't currently have direct support for this, but attached to this message is a program called OggInsert, written in standard ANSI C, which reads an Ogg Vorbis file created by VLSI Solution, then inserts some additional user comments to the headers of that file.

The example program reads from / writes to a file, but it has been written in such a way that it would be easy to modify to a streaming system.

I have provided with example files called ShortSampOrig.ogg, and ShortSampleModified.ogg, as examples of an VS10xx encoded file before and after modification. OggInsert has some debug outputs so that it would be easier to debug your port to your favourite microcontroller flavour.

When run with the provided .ogg files, the output of OggInsert looks like this:

Code: Select all

% ./ogginsert ShortSampleOrig.ogg ShortSampleModified.ogg
Comment frame:
  original pageLen 56
  new comments 4
  new commentLen 69
  new pageLen 141
Vendor length 16
Original 1 user comment(s):
  User comment 0 length 20
Adding 4 new user comment(s):
  User comment 0 length 20: ARTIST=Senor Coconut
  User comment 1 length 18: ALBUM=Yellow Fever
  User comment 2 length 17: TITLE=Bonus Track
  User comment 3 length 14: TRACKNUMBER=21
% ls -la ShortSampleOrig.ogg ShortSampleModified.ogg
-rw-rw-r-- 1 leopold users 6985 Apr 12 11:03 ShortSampleOrig.ogg
-rw-rw-r-- 1 leopold users 7070 Apr 12 12:58 ShortSampleModified.ogg
Analysis of the original file looks like this:

Code: Select all

Opened "ShortSampleOrig.ogg"
 Frame    0 @       0,   3a B,  1 pg, _F_, fCrc 844fa422, calc 844fa422 OK
    Ogg type: Vorbis
    Header frame type 1: IDENTIFICATION
      Vorbis version: 0, Audio channels: 2, Samplerate: 44100
      Bitrate max: 0, Bitrate nominal 148000, Bitrate min 0
      Block sizes 256 2048, Framing bit OK
      Serial Number 12345678
 Frame    1 @      3a,   54 B,  1 pg, ___, fCrc 0f939a07, calc 0f939a07 OK
    Ogg type: Vorbis
    Header frame type 3: COMMENT
      Vendor: "VLSI Solution Oy"
      Comment 1/1: "ENCODER=VS1005 v2.00"
 Frame    2 @      8e,  4eb B,  5 pg, ___, fCrc 59cba111, calc 59cba111 OK
    Ogg type: Vorbis
    Header frame type 5: SETUP
 Frame    3 @     579, 1002 B, 27 pg, ___, fCrc c40c8e73, calc c40c8e73 OK
 Frame    4 @    157b,  5ce B, 2a pg, C_L, fCrc 895520bb, calc 895520bb OK
End of file
Analysis of the modified file looks like this:

Code: Select all

Opened "ShortSampleModified.ogg"
 Frame    0 @       0,   3a B,  1 pg, _F_, fCrc 844fa422, calc 844fa422 OK
    Ogg type: Vorbis
    Header frame type 1: IDENTIFICATION
      Vorbis version: 0, Audio channels: 2, Samplerate: 44100
      Bitrate max: 0, Bitrate nominal 148000, Bitrate min 0
      Block sizes 256 2048, Framing bit OK
      Serial Number 12345678
 Frame    1 @      3a,   a9 B,  1 pg, ___, fCrc 58d1b3b7, calc 58d1b3b7 OK
    Ogg type: Vorbis
    Header frame type 3: COMMENT
      Vendor: "VLSI Solution Oy"
      Comment 1/5: "ENCODER=VS1005 v2.00"
      Comment 2/5: "ARTIST=Senor Coconut"
      Comment 3/5: "ALBUM=Yellow Fever"
      Comment 4/5: "TITLE=Bonus Track"
      Comment 5/5: "TRACKNUMBER=21"
 Frame    2 @      e3,  4eb B,  5 pg, ___, fCrc 59cba111, calc 59cba111 OK
    Ogg type: Vorbis
    Header frame type 5: SETUP
 Frame    3 @     5ce, 1002 B, 27 pg, ___, fCrc c40c8e73, calc c40c8e73 OK
 Frame    4 @    15d0,  5ce B, 2a pg, C_L, fCrc 895520bb, calc 895520bb OK
End of file
I hope this program is useful to you!

Kind regards,
- Henrik
Attachments
ogginsert_v100.zip
Source code for ogginsert, along with two example .ogg files: an original, and a modified one.
(15.49 KiB) Downloaded 19 times
Good signatures never die. They just fade away.

Post Reply