pykaraoke — free CDG/MIDI/MPEG karaoke player
Synopsispycdg [ options ] songfilename.cdg
Overviewpykaraoke is a free karaoke player for Linux, FreeBSD and Windows.
pycdg is a CDG karaoke player which supports MP3+G and OGG+G tracks.
The player uses the pygame library (www.pygame.org), and can therefore run on any operating system that runs pygame (currently Linux, FreeBSD, Windows and OSX).
You can use this file as a standalone player, or together with PyKaraoke. PyKaraoke provides a graphical user interface, playlists, searchable song database etc.
For those writing a media player or similar project who would like CDG support, this module has been designed to be easily incorporated into such projects and is released under the LGPL.
Numeric module (numpy.sourceforge.net) is required only if you do not use the compiled C low-level CDG implementation in _pycdgAux.c
UsageTo start the player, pass the CDG filename/path on the command line:
python pycdg.py /path/song.cdg
You can also incorporate a CDG player in your own projects by importing this module. The class cdgPlayer is exported by the module. You can import and start it as follows:
player = pycdg.cdgPlayer("/path/song.cdg")
If you do this, you must also arrange to call pycdg.manager.Poll() from time to time, at least every 100 milliseconds or so, to allow the player to do its work.
The class also exports Close(), Pause(), Rewind(), GetPos().
There are two optional parameters to the initialiser, errorNotifyCallback and doneCallback:
errorNotifyCallback, if provided, will be used to print out any error messages (e.g. song file not found). This allows the module to fit together well with GUI playlist managers by utilising the same GUI's error popup window mechanism (or similar). If no callback is provided, errors are printed to stdout. errorNotifyCallback should take one parameter, the error string, e.g.:
def errorPopup (ErrorString):
doneCallback can be used to register a callback so that the player calls you back when the song is finished playing. The callback should take no parameters, e.g.:
msgBox ("Song is finished")
To register callbacks, pass the functions in to the initialiser:
cdgPlayer ("/path/song.cdg", errorPopup, songFinishedCallback)
These parameters are optional and default to None.
If the initialiser fails (e.g. the song file is not present), __init__ raises an exception.
Optionspycdg also takes various command-line options for setting the window size, position, and update rate. Type the following for a full list of options:
$ pycdg --help