HOW-TO:Setup XBMC for Karaoke

Using Karaoke with XBMC Media Center
This guide will help you to set up your XBMC Media Center to play karaoke.

Features
XBMC Media Center supports the following Karaoke features:
 * Supports CDG, LRCv1 and LRCv2 lyrics formats;
 * Supports UltraStar song lyrics and video formats;
 * Supports MIDI music and KAR files;
 * Plays directly from MP3+CDG archived together;
 * Supports song numbering with permanent numbers, which means the song could be selected by number, even if another song is being played. The numbering information could be exported into HTML file and used to print catalogs.
 * Supports real-time lyrics timing modification, allowing to modify the lyrics-music delay. The delay is associated to the song, and then restored when this song is played again.
 * Supports different background modes, including visualization, still picture or video.

Missing features
What is not currently supported:
 * Playing CD-G disks directly. The suggested workaround is to rip them into MP3+CDG files using available software.
 * Using digitized microphone input. The microphone should work in pass-through mode, but will not work in digitized mode, where the sound should be digitally processed by XBMC Media Center. This also means that any voice post-processing is not possible yet.
 * Pitch modification.

What will not be implemented

 * Playing vendor-specific Karaoke disks (like California Electronics or LG). Those disks need to be converted to playable files set first.
 * Automatic voice removal. This is not possible to do automatically without seriously degrading music quality.
 * Scoring table, nicknames and other attributes of karaoke-based games.

Supported formats
The following karaoke formats are supported by XBMC Media Center.

MP3+CDG
The karaoke song consist of two files: the music file (usually MP3 but could be any playable type), and a separate binary file with the same file name as the music file, but with .cdg extension. This is the most popular format in the NA/USA, with a lot of English language music in this format available both legally and illegally. The source of those files are usually original CD disks in CD-G formats designed for hardware karaoke players. Those disks got ripped by any of freely available CD rippers, repacked and shared via typical channels, or sold on multiple web sites around the world.

The main feature of this format is that the lyrics are stored in the binary format, in form of drawing instructions. This means the CDG file could contain text in any language, or even graphics, and will be properly rendered on any supported device no matter what fonts are installed. However those drawing instructions operate on a small 300x216 window, and therefore have to be upscaled. As a result, this format combines usually very good music quality with very poor graphics. Because of upscaling the lyrics visualization quality is the worst through all supported formats, especially on large screen TVs. Other problems of this format are inability for the ordinary user to fix the typos or synchronization issues in the song, and that software required to create .CDG files is not widely available. There are only two programs, and neither is cheap.

MP3+LRC
Same as with CDG, the karaoke song consist of two files: the music file (usually MP3 but could be any playable type), and a separate text file with the same file name as the music file, but with .lrc extension. This is the most popular format in the Asia, and the most widespread lyrics format in the Internet. The source of those files are either original karaoke CDs where text in CD-G format was replaced by text in LRC by the person who ripped it, or a home-made music often made from MIDI files. There is also a lot of legitimate lyrics web sites where the lyrics in LRC format are available for download, usually for free.

The main feature of this format is that the lyrics are stored in the text file, usually in UTF-8 encoding. This means nothing but text (i.e. no graphics), and that the rendering software (XBMC Media Center) must have all necessary fonts installed. However since the rendering device uses real scalable fonts to render the text, the lyrics visualization quality is very good, especially on large screens. Being a text file it could also contain meta information (artist and song name, overall song delay and so on), is easy to edit/fix, and easy to create. Under Linux such files could be created in five minutes using free software.

MP3+TXT (UltraStar)
Similar to CDG and LRC, the karaoke song consist of several files. Usually it's just two files - the music file (usually MP3 but could be any playable type), and a separate text file with the same file name as the music file, but with .txt extension. This is relatively new and a very popular format due to its usage in UltraStar game and its numerous clones. This format also supports pitch, which is now ignored but in future may be used to track the individual performance. Also the song archive often includes video and pictures. At this moment the pictures are ignored, however the video will be played at background if available.

There are several song packages available in Internet. For starters, the Performous web site, http://performous.org/, contains a few songs with a liberal license. A bunch of websites over Internet are also providing Ultrastar lyrics (only text, they do not provide music).

MIDI/KAR
The karaoke song consist of a single MIDI file which usually has .kar or .mid extension. The MIDI file inside usually contains multiple tracks, and one of those tracks contains lyrics synchronized with the music. Because MIDI file only contains instructions for the music synthesizer (like //play note "A" using instrument "Grand Piano"//) and do not contain the music itself, the file is usually very small. Most song files are around 50K. Vast majority of MIDI files is created by amateurs, and legally offered for download for free. This format is very popular in Eastern Europe. But for any language it's usually much easier to find a MIDI karaoke song than MP3 karaoke song.

To play MIDI files, XBMC Media Center incorporates a MIDI synthesizer Timidity++. This is a full-featured synthesizer which supports soundfonts, but special configuration is required. Since the lyrics in the MIDI file are in text format, a good quality rendering is possible. However there is no standard which would require MIDI files to use only UTF8 encoding, and therefore some of them use UTF8, and some of them use local encoding. XBMC Media Center tries to auto-detect whether to use UTF-8 but it might not always succeed. The text in MIDI files is relatively hard to edit or modify, however a lot of editors is available on all the platforms, and there is open-source free software like Rosegarden to edit MIDI files.

Configuration
XBMC Media Center needs to be configured to support karaoke. You need is to enable karaoke in the Setup -> Music -> Karaoke. I also suggest to disable "Music -> General -> Auto play next item" as it's usually not desirable for karaoke.

Skin selection
Skins other than default PM3.HD might require extra files to support Karaoke. Please make sure everything works with the default skin before switching to another, and if something does not work, please make sure it does not work on default skin too. The rule is the following: bugs in karaoke which happen using default skin, are assigned to me. Bugs which only happen using non-default skin, should be assigned to the team/person responsible for this skin.

Checking timings
You need to make sure there is no delay between audio and lyrics, or set up the appropriate value to compensate it. For this, get a couple of songs which you're sure are synchronized properly, and try to play it. If the lyrics are not synchronized, adjust delay through advancedsettings.xml. Note that there are two different delays for CDG and for LRC files. There is no delay for MIDI playback, it must be always synchronized.

MIDI playback
There are two ways to configure embedded Timidity synthesizer and enable MIDI playback - a simple way, and a more advanced way.

Simple way, you need a single soundfont file. Those are typically large (50Mb+) files with .sf2 extension, the most popular resource is http://www.sf2midi.com I recommend using widespread and well-tested SGM-180 soundfont, google for it or get 2.01 version from http://www.geocities.jp/shansoundfont/ (this one is included into Arch linux in the soundfont-sgm180 package). Download the file, rename it to soundfont.sf2 and put it into your XBMC Media Center system directory (not your home directory) into system/players/paplayer/timidity subdirectory (you must create it first).

Advanced way, you need to prepare timidity.cfg configuration file. Usually this is necessary when you use multiple soundfonts or want to add post-processing effects. This means you know enough of Timidity, and could handle it yourself. XBMC Media Center embeds version 2.13 of Timidity. Create timidity.cfg and put it in the system/players/paplayer/timidity subdirectory, and check XBMC Media Center log file for errors if it doesn't work.

Please note that for SGM-180 soundfont playback you need a decent machine with at least 256Mb of RAM and at least Pentium 2.4GHz CPU. Otherwise get a smaller soundfont.

Selection by number
To enable song selection by number, your music collection needs to be scanned (or rescanned if it was scanned already). During scan, the karaoke songs are detected, and the song numbers will be automatically assigned. After the scan is completed, you can export the numbered songs as HTML file (Setup -> Music -> Karaoke -> Export Karaoke titles... -> Export as HTML), open them in the OpenOffice Writer and print a song directory to have a professional Karaoke setup. Use two-column mode if you want to save space.

It is also possible to change the song numbering if you don't like it or if you want to maintain compatibility with your printed guide. For this you need to export numbered songs as CSV (Setup -> Music -> Karaoke -> Export Karaoke titles... -> Export as CSV), modify it as necessary, and import it back (Setup -> Music -> Karaoke -> Import Karaoke titles). The CSV format is TAB-separated, no quotes, no escape characters. The first field is song number, second field is artist name, third is song name, and fourth is path to the music file.

It is possible to select songs while a karaoke song is still played, by using numbers on your remote. This feature is enabled by default, however you need to make sure that the number buttons from your remote generate Number* events. By default they do not, so you need to modify your Keymap.xml. Put the following in your section:

When you start pressing numbers, a small dialog will pop up in a left top screen corner. It will show selected song number and song name or "Unknown" if there is no such song for this name. Once the song is selected, press "Select" on your remote to add it into the playlist.

Auto-popup selection by number
If the setting "Auto-popup song selector" is enabled, the song selection dialog will pop up after the karaoke song ends if there are no more songs in the queue. It will not pop up after a non-Karaoke song. This dialog works exactly as the in-song dialog, however once the song is selected, it starts playing immediately.

Setting up default background mode
Default background mode is "no background". If you wish to use visualization, video or a picture as background, it should be enabled in advancedsettings.xml.

For video background the video file must be available in supported format. Currently all the formats which could be played by XBMC are supported with exception of DVD and DVD images. Video playback is in alpha phase, so currently only one video could be selected as background. Using highly compressed video is not recommended; MPEG2 is recommended for fast machines and MPEG1 for slow machines. Educational videos like National Geography look very good for background. Stripping audio is not needed, as any available audio stream will be ignored.

When playing CDG+MP3 files, note that they usually have their own background which you can turn on/off in advancedsettings.xml as well.

Where to get Karaoke files
MP3+CDG. CD-G disks are available from many online retailers such as http://www.shopkaraoke.com or http://www.mycdg.com, as well as from some high street shops. Since at this moment XBMC Media Center cannot play such disks, you're suggested to rip them using available tools. Once you have ripped the disks to MP3+G format, you can play the songs directly from your hard disk using XBMC Media Center.

Alternatively there are some online retailers offering downloadable MP3+G files. See http://www.tricerasoft.com for a good example. From sites like this you can download the files already in MP3+G format and play them directly using XBMC Media Center. There is also a bunch of web sites selling huge collections of MP3+G songs on multiple DVD disks.

MP3+LRC. At this moment we do not know about any vendor which would sell legit MP3 karaoke files with LRC lyrics. A lot of LRC karaoke files and music is available on Asian (mostly Chinese) web sites, either free or commercially, but their legality is questionable. However LRC lyrics alone are freely available in a lot of web sites, and relatively easy to create, see the article in this wiki on HOW-TO create LRC karaoke lyrics files.

MIDI. MIDI karaoke files are most available for free as "public domain", while only few of them is available commercially. They are often found in specialized musician/karaoke forums as well as on dedicated websites. The MIDI format was very popular before introduction of MP3, and tons of them could be found in the old newsgroups archives.

Playing
Select the Karaoke song (either on disk or by number) and press "Select". The screen should change to visualization, and the song should start playing with the lyrics shown on screen. For us the best visualization for karaoke so far was Goom, but it is very resource-consuming so if your hardware is not top notch, you might want to switch to Project M instead, which is also very good.

If the lyrics for this specific song need to start earlier or later, press the button associated with SubtitleDelayPlus or SubtitleDelayMinus until lyrics are synchronized. Each press changes the delay by 50ms.

Advanced settings
The following advanced settings are added for karaoke support. All they must be stored in the advancedsettings.xml file in the section:

http://wiki.xbmc.org/?title=Advancedsettings.xml#.3Ckaraoke.3E