Karaoke CDG DLL

Over the years I have had several requests for a Windows CDG Karaoke player library that can be used as a component in other Windows programs. I tend to use cross-platform development frameworks so I was curious to see how some of the Windows development tools have progressed lately. As a result I have written a DLL / plugin that can be used to add Karaoke playback support to other Windows programs using any programming language (C#, C/C++, VB, VB.NET, Delphi etc).

CDG Player Plugin DLL Screenshot

It supports playback of the common CD+G Karaoke format (MP3+G and WAV+G files), and benefits from the years of CD+G format testing enjoyed through PyKaraoke. It also adds a few features not available in my previous Karaoke projects:

  • Full rewind/fast-forward support (seek to any time position)
  • Window resizing on-the-fly
  • Transparent CDG support (overlays lyrics onto a bitmap image)
  • Very large background bitmaps can be scrolled in all directions to give the impression of moving video
  • Bordered lyrics in transparent mode (optional and non-standard but experience has taught me this improves the appearance)

I have not done much with this yet other than write some simple karaoke player applications in various languages, for example adding CDG playback to a VB application is as simple as this:

Handle = CDGPlayerOpen(“MadWorld.mp3”)
CDGPlayerShow(Handle)
CDGPlayerPlay(Handle)

The DLL exports functions to implement much more than this, with full control of the playback position, querying the song position for progress bars, and other features required to build a fully-featured Karaoke application.

Contact me if you would like more details.

Seeking Developer to Maintain Windows Port

We are currently seeking a developer to look after the Windows port of PyKaraoke. If you are interested in contributing to an open source project (and learning something about Python development along the way) we would love to hear from you.

We have recently written two articles as a quick-start guide to development on the Windows platform:

The simplest way to get involved is to use the pure Python method discussed in the first article. It is not necessary to install any of the C development environment to do this, and you can quickly start editing and running your own PyKaraoke modifications. We are always happy to bring new developers on board and will give assistance in bringing you up to speed with the source code, but you should find that the PyKaraoke source is well commented and easy to follow. According to Ohloh:

Across all Python projects on Ohloh, 24% of all source code lines are comments. For PyKaraoke, this figure is 30%. This high number of comments puts PyKaraoke among the highest one-third of all Python projects on Ohloh. A high number of comments might indicate that the code is well-documented and organized, and could be a sign of a helpful and disciplined development team.

You can hook up with the development team on the PyKaraoke mailing list. Most of the developers work on Linux, but PyKaraoke works just as well on the Windows platform and for that reason we would like to invite anyone passionate about open source development to look after the Windows port. This might be a small contribution like tidying up the GUI on Windows or taking over making Windows releases, or you could contribute brand new features that can be used on Linux, BSD, OSX, GP2X and any other platforms which PyKaraoke runs on. The differences between the platforms are minor, but having a developer keeping a close eye on the Windows platform will assist in keeping PyKaraoke the most portable karaoke player out there.

PyKaraoke Development: Windows Installer

Following on from the previous article about PyKaraoke development for the Windows platform, those of you who are modifying the source and contributing to the project may be interested in these instructions for building your own PyKaraoke installer executable. This allows you to distribute test builds of PyKaraoke which users can install without having to first install any of the underlying applications and libraries such as Python and Pygame.

  • Install NSIS and Py2exe.
  • Follow these instructions for setting up the build environment.
  • Copy the following DLLs to folder “build/lib.win32-2.6/” in the top-level source folder (note that your originating folders may differ). In future this step will be automated within the installer script:
    • c:\Python26\Lib\site-packages\pygame\SDL.dll
    • c:\Windows\WinSxS\x86_Microsoft.VC90.CRT_…\msvc*90.dll
  • Compile PyKaraoke’s C-based optimised CDG interpreter from a command prompt:
    • python setup.py build_ext –sdl-location=C:\proj\SDL
  • Finally build the installer executable (use option –makensis if you installed NSIS to a non-standard location):
    • python setup.py nsis

Your final executable installer will now be sitting in the top level source folder with the filename pykaraoke-ver.exe.

PyKaraoke 0.7.1 Windows Installer Released

We are pleased to announce that a Windows installer for PyKaraoke v0.7.1 is now available. This brings all of the recent features added for Linux to the Windows platform:

  • Many new features useful for pro hosting with PyKaraoke.
  • You can now associate performer names with songs in the playlist.
  • Add Kamikaze button to add a random song to the playlist.
  • Various new playlist features.
  • Time progress indicator during song playback.
  • Add support for pulling artist/title data from song filenames.
  • Add option to display karaoke window without a frame.
  • Many new configuration options and other GUI improvements.

Download the installer here.

PyKaraoke Windows Development

Windows users can install PyKaraoke using the simple installer available here, but those of you interested in modifying it or contributing to the PyKaraoke project may be interested in the following guide.

The Basics

To develop for PyKaraoke on Windows you must download and install the following dependencies:

Next download the PyKaraoke source ZIP from here and unzip.

With these in place you are ready to run PyKaraoke as well as modify the Python sources to your needs. You can launch the PyKaraoke GUI by clicking on pykaraoke.py, or from a command-line using “python pykaraoke.py”.

Faster CDG Implementation

As well as the pure Python version of PyKaraoke there is an optimised version of the CD+G interpreter which is written in C. It is not necessary to build and use the optimised version, but it can improve CD+G playback performance on very old PCs. Setting yourself up for building the C module is a little more involved than just installing the Python libraries, but here we walk you through every step.

First install the tools and libraries necessary to build the C file:

Now unpack the SDL sources somewhere (e.g. c:\proj\sdl) and follow VisualC.html (contained in the SDL sources) for instructions on building the SDL library. We distil the VisualC.html build instructions here:

  • Unzip VisualC.zip contained in the SDL sources
  • Double-click VisualC/SDL.dsw
  • Build->Configuration Manager menu: Change from Debug to Release
  • Build solution
  • The library SDL.lib builds to folder c:\proj\SDL\VisualC\SDL\Release\
  • Create a “lib” folder under the top-level SDL source folder, e.g. c:\proj\SDL\lib
  • Copy the previously-built SDL.lib file to c:\proj\SDL\lib\SDL.lib

You only need to build SDL once. From now on compilation of the PyKaraoke C module is carried out with a single command on the command-line. The C module is built as follows (from the PyKaraoke source folder):

  • python setup.py build_ext –sdl-location=c:\proj\SDL

Before launching, copy the compiled module from “build/lib.win32-2.6/_pycdgAux.pyd” to the top-level PyKaraoke source directory. You can now launch PyKaraoke using “python pykaraoke.py” and set the “Use optimised (C-based) implementation” option in the CDG configuration menu.

Alternatively you can use “python setup.py install” to install all modules including the optimised C module to Python’s site-packages folder.

Getting Help

That’s everything you need to get started with development for the PyKaraoke project on Windows. A little prior Python experience will always be helpful but you should find that PyKaraoke is well commented enough to be able to dive in quickly. Any questions can be posted to the pykaraoke-discuss mailing list, we’re always happy to have another developer on board. And don’t forget to send us your patches!