Thoughts from a learning project

I'm just done with a small learning project. When I want to learn something, I usually decide to do a small project. This is because I have a hard time staying focused with test-this-test-that kind of learing. I usually build something.

This time I wanted to take Win32::GUI out on a test drive. And I started to think about what I was going to build. I've never written any Win32::GUI code (with Perl) before so I wanted to write a small application with just a few controls. Nothing complex, just something simple but working.

I decided on a MP3 player :)

Aimed my browser for CPAN to grab some decoder module since I didn't want to write one, this was a Win32::GUI project, but in the one I found (MPEG::MP3Play) Win32 support was on the TODO list :(

So here I was with a show-stopper before I even started. No decoder - no MP3 player. Time to get creative...

I browsed the dlls of some popular players to see it I could find a useful one to interface with Win32::API, a well known path. But no, none were useful. I am kind of persistant when it comes to learning projects so I really didn't want to build anything else when I had set my mind on a MP3 player.

Aimed my browser for yet unknown places of the web to try to find some new angles of attack and I got lucky. I found Amp11lib, an open source, GNU licenced decoder/player library for Win32. Cool. Now I were on track again. Downloaded the source and a precompiled library and started to write a Win32::API interface to it.

It worked perfectly, except for a small detail; it didn't produce any sound. When I ran a test written in C it worked perfectly, but with Win32::API, alas, no sound. Should this nice beginning turn out to be a dead end? No matter how I tried I couldn't get my Win32::API interface to work.

Then a thougt came into my mind; if I could get it to work from C, wouldn't a XS module work too? Time to brew on another can of coffee and read perlxstut.pod and perlxs.pod...

After some reading, I was pretty sure that I could hack a XS interface to amp11lib, even if I'm no C guru. So I started to work on the first XS module of my life. XS is a beautiful way of writing C code, and I really enjoyed getting a glance of how you extend perl with it.

Now I had a working way to play MP3 files from perl in Win32, and I could start to do my Win32::GUI interface to it. After a few hours I got it to interact with my MPEG::Amp11 module, and it performed quite nicely. Now was the time to get crazy; I added buttons, displays, a playlist, timers, sliders, MP3::Info, storing stuff with Win32::Registry to have persistance between sessions...

Now, my lesson learned from this project, besides a bit Win32::GUI and XS, is this:

The tougher it gets, the more you get a chance to learn.

I named the player MonkAmp, as a tribute to this site, where I continue to learn new stuff all the time. Thanks all!

If you like to play with the code you can download it from my home page at t0mas.netlords.net.
Update: I don't live there any more... /msg me if you want the code.

Perl continues to rock all over the world...


/brother t0mas

In reply to MonkAmp by t0mas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.