July 01, 2009

Moihang: Part 2

Yesterday, I introduced you to Moihang, our family's version of Hangman a popular word guessing game. Maria and Monica had suggested early on that we use sounds every time you pressed a keystroke. I then suggested to use different sounds for correct and missed guesses. Finally, it only made sense to play some sort of fanfare when winning and some sort of dramatic sound clip if you fail to guess the word.

Since we wanted to support Windows versions that we knew only had .NET Framework 1.1 I decided to make it the minimum Framework version. That left me P/Invoking winmm.dll for wave file sound playback. That was easy enough in Windows and I must admit that I ignorantly assumed that P/Invoking in Linux would be almost identical and just as easy...

About two solid days of Linux audio architectures and libraries research, I ended opting for programming my own shared library using ALSA. I also learned a bit about Pulseaudio, sox and esound.

You can look at how I use afileplay in Moihang here.

The other somewhat interesting thing that I tried to accomplish with the development and release of this application was to create a build system for a WinForms app that can integrate with the menus on the GNOME desktop as well as having an Inno Setup script for building the Windows Installer. Just last week I received an email from a fellow that wanted to support build systems for Linux as well as Windows programmers at his shop. He wanted to better understand the way that MonoDevelop generated Makefiles could help with that goal.

Well, I used the incredibly awesome MonoDevelop myself to create the initial build system (did a bit of manual tweaking but truly minimal) and ended up with something that autotools built quite nicely and maintainable.

I will stop talking about this now and give you the URLs already for download and further information on Moihang and the Afileplay library.

Moihang's product page.

I hope to continue improving Moihang -- time and professional obligations permitting. I want to create a Gtk# version of the UI, maybe a Maemo version as well. I want to change the actual hanging depiction from my initial “easy way out” bitmap file sequencing to a 2D drawing system (GDI+, GDK, etc.).

For now, use it if you like and give me feedback or hack it some. Enjoy!

Posted by martinf at 11:28 PM | Comments (3)

June 30, 2009

Moihang: a word guessing game

I programmed almost exclusively on Microsoft Windows and DOS from 1988 until 1999. I started doing batch files, Quick BASIC, Visual Basic, and soon thereafter C/C++ Windows SDK/MFC/ATL. Along the way I programmed for a few flavors of UNIX and most Mac OS versions (Power Plant/Carbon). There for a while a did quite a bit of Palm OS and other embedded systems.

Around the turn of the century -- I love to sound that old (Logan's Run kind of old!) -- I discovered Linux and Free BSD and above all... C#

As Dewey Cox would say: “It's been a beautiful ride”.

Yet playing a wave sound file on Linux from a desktop application is, in my opinion, somewhat harder than in Windows. Of course, there are obvious reasons for this. Microsoft as well as Apple and other commercial OS providers could always dictate a simple, standard and unified way to give you an API call with just a couple of input parameters (file name and/or path usually). The Bazaar nature of Linux programming with its multiple desktops and various low level audio interfaces give you many choices lost of granularity but with all that, comes a lot of homework for those who just want to have a sound clip play when an event in their application takes place.

My beloved daughter Monica is always asking my wife Maria and I to play 20 questions and other word guessing games from the back seat of the car whenever we go from point A to point B – In Texas that may take a long time since point A usually is at least 30 to 40 miles from any point B. One day, we started playing hangman in the car using a piece of paper and a pencil. Both Maria and Monica liked it, and I decided to make it a cross platform desktop app for all our computers.

Although, my first impulse was to make a Gtk# app -- 90% of our computing at home is done on Linux on top of a GNOME desktop -- I instead decided to use WinForms because I wanted try to create RPMs for openSUSE in hopes that I could virally propagate the good news of .NET and WinForms to billions of .NET/Mono embracers that I always read about in slashdot and OSnews <-- sarcasm alert.

Tomorrow, I will make another blog entry where I will share more about my humble solution to the simple programmatic playback of wave and au files while on Linux. Also, the Martinez-Figueroa family Hangman clone: Moihang

moihang-shot.png

Posted by martinf at 10:14 PM | Comments (0)