Karaoke

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).

You can create your own MP3 and TXT files from Karaoke MIDI files or ABC files. Since the timing of lyrics is already in the Karaoke MIDI file, it's easier to programatically convert this information to the TXT format rather than trying to create lyrics files by hand. See the tips under the Karaoke MIDI section for creating Karaoke MIDI files from ABC files. To convert a Karaoke MIDI file to MP3, you can use Timidity itself. Timidity can take a MIDI file and convert it to WAV or other formats. If your version of Timidity doesn't support MP3, you can convert to WAV and then use a program like Audacity or Sox to convert to MP3. Many UltraStar files are also availabe in Ogg Vorbis (rather than MP3). Again, you can use tools like Audacity or Sox to convert audio file formats as necessary. To create a text file with lyrics automatically from a Karaoke MIDI file, so far, the only program I've found for this is MidiKar2UltraStar. It's written in Java and isn't Open Source. It would be nice to find some Open Source programs to automate the lyrics conversion.

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 are available on all platforms, and there is open-source free software like Rosegarden to edit MIDI files.

You can create your own Karaoke MIDI files using a standard text editor, ABC notation and the Open Source program abc2midi. This will work on all platforms. If you're familiar with notes or can read sheet music, ABC Notation should be easy to work with. You can also convert available ABC files to MIDI or Karaoke MIDI files to use with XBMC. If you have a MIDI file and want to edit it to add or tweak lyrics or change some notes, you can use midi2abc to convert to ABC notation and then edit in a text editor. (You may lose some information in the conversion to ABC, but you can now change the music however you want.) After editing, you can convert back to Karaoke MIDI using abc2midi. If you want a more lossless way to edit MIDI files, try mf2t and t2mf or midicomp (combination of mf2t and t2mf available at Freepats site). These Open Source programs let you convert a Karoake MIDI file directly into a text format that can edited in any standard text editor. You can easily edit Karaoke lyrics in this format. The programs then convert the text file back to Karaoke MIDI format.

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 directory:
 * For revisions before 35301 copy it into system/players/paplayer/timidity subdirectory (you must create it first).
 * For revisions after 35301 copy it into timidity subdirectory in your home userdata folder, i.e. something like .xbmc/userdata/timidity/soundfont.sf2

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.2 of Timidity. (Note: Versions of Timidity created in 2010 and after have better support for Karaoke midi files created by ABC notation and better timing for lyrics especially in the xaw part of the code.) 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. There's a soundfont configurator tool available online at Tim Brechbill's Timidity site. It's assumes you're on a Windows system, but should be okay with Posix systems too if you correct your paths appropriately. You can use it to generate the Timidity.cfg file for you. There are also links to other good soundfonts at this site.

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.

If you want to use soundfonts with Open Source and/or Creative Commons licenses, check out the Freepats Project. Many Linux distributions offer a Freepats package. The Freepats Project has Open Source and/or Creative Commons licensed soundfonts, instruments sounds and tools to create your own soundfonts.

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:

Number0 Number1 Number2 Number3 Number4 Number5 Number6 Number7 Number8 Number9

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.

Show song selector automatically
If the setting "Show song selector automatically" 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 are available on Asian (mostly Chinese) web sites, either freely or commercially, but their legality is questionable. However, LRC lyrics alone are freely available at a lot of web sites, and relatively easy to create, see the article in this wiki on HOW-TO create LRC karaoke lyrics files.

MP3+TXT. A few Creative Commons licensed songs come with UltraStar Deluxe. These will work on POSIX platforms as well as Windows. You can do a search on Creative Commons licensed MP3 files to find songs you can legally share with others. You'll probably need to create your own lyrics files though. You can also check Ultrastar, Ultrastar Deluxe and Performous forums for more songs and/or lyrics. If you legally own songs on CD, you can rip them to WAV for personal use using Open Source tools like CDex or Asunder or K3B and then convert to MP3 with tools like Audacity or Sox. Some software may convert directly to MP3.

MIDI. MIDI karaoke files are mostly available for free as "public domain", while only a few of them are available commercially. (Note: Some freely available MIDI Karaoke files have copyright notifications embedded in them. Also, just because the MIDI file is available for free, doesn't mean it's public domain. If the song itself is under copyright, the midi file is not legally in the public domain.) 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. There's also a search engine for Karaoke MIDI files at the VanBasco site, but the site isn't always available.

ABC. ABC Notation text files files can easily be converted to Karaoke MIDI files or even MP3 files with text lyrics. Many are free, in the public domain or have friendly licensing restrictions. There are several search engines available for them. Another good place to look for them is The Mudcat Cafe.

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.

If you're in the middle of a song and decide you want to hear something else, press x to get back to your song listings. You can also move through your songs lists by pressing, or. to go backward or forward in your song listings.

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