Hows and Whys |
How to use Oni files and why
Oni DTD
The current DTD for the .oni file is :
<!Doctype multi-synch-lyric [
<!ELEMENT multi-synch-lyric (lyric-streams*)>
<!ELEMENT lyric-streams (lyrics*)>
<!ATTLIST lyric-streams stream-name CDATA #IMPLIED>
<!ELEMENT lyrics (#CDATA)>
<!ATTLIST lyrics lyric CDATA #REQUIRED>
<!ATTLIST lyrics start CDATA #REQUIRED>
<!ATTLIST lyrics end CDATA #REQUIRED>
]>
General Structure of an Oni File
The basic structure of an Oni file is essentially a series of streams each containing a series lyrics with timestamps. This is a very simple format but is still flexible and since its an XML based format it can be extended with new attributes or elements. Some other lyric formats use a simpler syntax and that would be faster, but I already had my parser put together so I just decided to use that. Since its a SAX parser its pretty damn fast and doesn't use much memory (compared to a DOM parser which most people equate to being slow and a memory hog) so I'm pretty fine with it. Its my own parser called the Ricin parser but it was put together mainly for databinding in my game. Currently it only supports US-ASCII encodings though and that very well may need to change since this whole project is about being multilingual.
Example:
<?xml version="1.0" encoding="US-ASCII"?> <multi-synch-lyric> <lyric-streams stream-name="english"> <lyrics lyric="ferret" start="0" end="2000"/> <lyrics lyric="bleemm" start="3000" end="4000"/> <lyrics lyric="sldfkjs" start="4000" end="10000"/> </lyric-streams> </multi-synch-lyric>
The start and end attributes are times in milliseconds
General Philosophy of Oni Usage
My idea for this whole endevour happened when I was looking for a way to listen to my TATY
and Jpop and have both the english and foreign language lyrics being played at the same time. Well looking around there wasn't anything that did that really. I couldn't even find a listing of most lyrics together. So I decided to start coding my own project to achieve what I wanted, the classic reason for open source projects :). So at first I figured that embedding the lyrics into mp3's directly would be the best way to go and most of my work focussed on learning the ID3 format and how to use ID3v2 tags. Most of my programming efforts were focussed on the editor and the winamp plugin in relation to the mp3 ID3v2 tags. Then almost as an after thought I decided to add functionality to load, save and use a seperate .oni file.
As I looked at some video subtitling projects I began to think that encoding the lyrics into the files might not be the best way to go about this. I now think that the preferred usage should be to have .oni files seperate from the audio file. This essentially adds support for every audio out there since the .oni files are not directly linked to an audio format and is not dependant on it. I also recommend that you keep the fils in an oni subdirectory for the MP3's and the .oni files must have the exact same name as the audio file that it goes with. For example, if you have Speed.mp3 file in a speed directory and want to hav an oni file for it I would recommend putting a speed.oni file into the oni subdirectory of the speed file. So you'd have this structure :
- /speed/Speed.mp3
- /speed/oni/Speed.oni
Currently the supported ways of loading the lyrics are in the ID3v2 tag of an mp3 file, in a file of the same name in the current directory where the audio file is, and in an /oni subdirectory of the directory that the audio file is in. The lyric location are checked in this order
- ID3v2 tag of the audio file
- Oni file with the exact name of the audio file in the current directory
- Oni file with the exact name of the audio file in an oni subdirectory