Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

MonkAmp

by t0mas (Priest)
on Nov 02, 2000 at 18:24 UTC ( [id://39633]=perlmeditation: print w/replies, xml ) Need Help??

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

Replies are listed 'Best First'.
RE: MonkAmp
by neophyte (Curate) on Nov 02, 2000 at 19:11 UTC
    Cool project th0mas, I hope I'll have the time for learning projects over xmas. And I know I will hit on the same mysterium: you start with a strict outline and then one thing comes to the other. You always end up learning more than you planned. While this is good for you knowledge of Perl it has it's downsides in time consumption.

    neophyte

RE: MonkAmp
by Adam (Vicar) on Nov 03, 2000 at 03:17 UTC
    I tried using this on my NT4 machine, and I was quite impressed... at first. Then I opened an MP3 file and played it and the codec seemed to be having problems. The music was very scratchy and such. I wasn't sure if this was the codec or the source, so I tried opening another file... and the program ceased to function. It quickly crashed with a "failed to read hex location" type message.
      Hi Adam.

      Nice of you to try it out, I really didn't think that anyone would... :)

      I guess all limitations from amp11lib is inherited to the player. It's hard to say where your problems are. The binary is compiled with Win2k so maybe we've got problems there. Did you try the "source" version or the binary?

      I've set amp11lib to play to the "default audio output device" (whatever that is) and if you try the source version, you can try to change that.

      I don't think that amp11lib can handle variable bit rates, so maybe that's your problem.

      This was a "private" project of mine, so I have made no attempts to make the player work on any other configuration than mine. The MPEG::Amp11 lib should on the other hand work well (with its limitations) on any Win32 Perl. Maybe you can download and compile it on your system and run the examples, and see (listen) if the playback is ok.

      Update: perl2exe is bad... My compiled version crashes all the time. I've removed it.

      /brother t0mas

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://39633]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-20 01:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found