Rob The Nerd .com Entrail Free!
Home
 
About
 
Projects
 
Amiga
 
Photography
 
Links
 

 

 
You are here: Home > Projects > MP3 Jukebox > Software

 
MP3 Jukebox
About
Current Progress
Construction
Software
Photos

 
 
 
Software
Originally I thought about simply using the software Dirk Conrad wrote himself for the MAS Player as this had very low system requirements (it would run on almost any Amiga from 1985 on!), had a nice fullscreen display for TV, and supported playlists. However this was quickly ruled out as there was no support for external control which meant things like an LCD time/info screen, remote control, automatic import of songs etc. weren't possible. So I looked at using a stand-alone MP3 player application such as Amplifier (supplied with Amiga OS 3.9) as this supported ARexx for intercommunication and control, and the MAS Player driver. However, things like the music library support that it had left a lot to desire, and it took quite a lot of resources to run, even when using the MAS Player for decoding. This would be fine if I was using it on a high-end Amiga as a normal computer, but not with the limited resources available. So I decided to try a basic command-line player. The ones written for the MAS Player worked well, were simple and easily controlled from another application. However, while there was a Play command, and Stop, Fast Forward and Rewind commands, there was no Pause function, and they were written in assembly (which was too much for me to fathom in this case) so I couldn't figure out how they worked to write my own Pause function for them.

My Own Player
So I decided to write my own player. Example C sources were included with the MAS Player drivers showing how to make a basic command-line player. There was also an include file for Blitz Basic, and I'm far more competent with Blitz than C on the Amiga, so off I went and built a basic GUI and file handling loop to load in the MP3s, and used a quick 'n' dirty AmigaDOS command to extract ID3 tag information from the file. Then I added the playing code loop just as it was in the C source example. This seemed to work - sort of. I could choose a file, and the GUI would be populated with the artist, album and other info, and pressing play, pause and stop did what they should. However, every so often the playback would freeze, followed shortly after by the program freezing. This seemed to be to do with Blitz doing weird things with memory allocation, and no matter what I did it wouldn't work. Using proper system calls for MemAlloc() rather than the Blitz system, using long arrays instead of pointer arrays, always ended up crashing. Frustrated, I started again, this time doing an exact port of the C example. Same thing. Couldn't work it out, but put it down to Blitz not handling pointers correctly.
 
spacer
 
 
The Software Model
This major stumbling block forced me to switch to C, at which I'm weaker when it comes to Amiga OS specific parts. So I took the example code and recompiled it, and guess what? Worked properly, no memory leaks, no crashes. "At least that's something," I said. However, my C knowledge wasn't as advanced as Blitz when it came to GUI building, so I decided on a modular software model. It would look something like this:

Software Model

Seeing as Blitz would be easier for me, and I still had faith the GUI could be written with it, I decided to split the MP3 player section from the Control section. This meant that the small MP3 player will basically act as a simple slave, accepting commands from the Control Module and doing the file and I/O necessary to use the MAS Player via the MHIMASPro.library API. This also negates the need for multithreading the main program for the playing/streaming routines, and allows the use of any MP3 player in the place of my simple MHI MAS player should you want to just use the Control Module with Amplifier, for example. The other modules would all also communicate via ARexx with the Command Module, the first one being the InfraRexx software which is capable of decoding IR remote codes received via the joystick port and some custom hardware. Front panel buttons could be handled by the Control Module, or by a simple slave task which runs in the background, waiting for button presses on the Jukebox's front panel buttons. The LCD also could be handled by the Control Module, but I think it's better to have it stand-alone and act on ARexx commands from the Control Module as this will allow its use by other software at the same time without having to have the main module process these messages.
 

spacer
 
 
The Central Control Module
I decided then to create the Central Control Module as a very basic clone of iTunes (my player of choice on the PC and Mac), with the option of using an external MP3 player for decoding. This module took the (rather obvious) name of AmiTunes, seeing as there doesn't seem to be any other software for Amiga OS with that sort of functionality or name. Of course its primary function will be as the heart of operations in the Jukebox, but once it's complete I think it could be put to good use on my main Amiga - or anyone else's for that matter. There are two different versions planned however - functionally the same but aimed at different targets. The first version is to run on the Jukebox, and as such is to have a basic GUI with low requirements and TV suitability. For this, the standard GadTools system will suffice. Once this is finished, I plan to make a modified version using MHI with additional functionality such as drag 'n' drop playlists, move versatile listviews for songs and playlists, and many other features made easier by MUI. This of course will require a more powerful Amiga, but as it's intended for desktop use this shouldn't be a problem.

As I said before, this module is being written in Blitz, mainly because it's the easiest language for me to write a GUI-driven application in. Communications will be handled by the excellent support of the RI Arexx library. This will allow the application to receive incoming commands from any program, such as the InfraRexx module or the software for reading the front panel switches.

The MHI MP3 Player Module
The MP3 player section was based on the MHIPlay C source code, which I made some changes to, allowing it to create an ARexx port for use by the control module, and allowing the random access of files to allow track skipping, fast forwarding and rewinding etc. as required. This module could easily be used with any MHI compatible devices simply by changing an argument, but at the moment the MAS Player is the only one I know of. The player waits for a command to be received via its ARexx port and then acts accordingly. These commands cover loading a new song (with the filename also supplied as an argument), starting, stopping and pausing playback, and seeking within a file (enabling fast forward, rewind and position slider dragging). There will be some lag as these commands are passed betwee tasks, but it shouldn't be too noticeable during normal usage.

The IR Remote Module
Receiving and decoding the IR remote control for the jukebox will be done by an off-the-shelf IR Remote to TTL demodulator, and the resulting serial signal will be processed by InfraRexx, some fantastic free software for doing just that and issuing ARexx commands based on the decoded signal. I came across InfraRexx when it was on the cover floppy of CU Amiga, along with a PCB for building the associated hardware onto. The full hardware also allows the sending of IR signals so the Amiga can control other devices, but we won't be needing that feature. Read more about it here. Yes, the design and software are over 10 years old now! Still works though - was a part of my CR System from the start in 1998...
 
spacer
 
 
A Change of Tack
Since developing this model a little further, I've decided to change my approach a little bit. While the InfraRexx module worked very well by itself, it used quite a bit of CPU power to decode the serial signals in software. Additionally, it also had a transmitter element which I wasn't going to use, but which tied up several of the joystick port I/O pins anyway. I needed to use those pins for the front panel buttons so I started looking for an alternative to InfraRexx. I found one that looked suitable - a self-contained demodulator and decoder module based on a little microcontroller which decodes standard Philips remote signals into a numerical representation. This meant that all the Amiga has to do is listen on the serial port for incoming messages, rather than having to decode the serial stream coming in on the joystick port. This freed up some CPU time which was very useful as decoding MP3s with the MAS player requires most of the 68030's power.

My only issue now was that both the LCD screen and IR remote receiver both required the serial port. Each one could be configured to use it in one direction only, so setting them both to the same baud rate allowed both to be used independently on the same port, provided they were both controlled by the same task. To keep the responsiveness and efficiency as high as possible, I started adding the code for both to the main AmiTunes control module. This did complicate it somewhat since the main loop now needed to look after such matters as scrolling the screen and maintaining progress bars, but the end result worked very well, with good responsiveness and no discernible overhead. This also eliminated the IR Remote and LCD Info Display modules from the original software model in favour of a more monolithic approach. Hopefully there wouldn't be too many changes to it however so this wouldn't be that big a deal.

The front panel button decoding ended up being integrated into the main software as well. Since the main loop already had a hardware polling/caretaking aspect, it made sense to include it here as well. The buttons are arranged in a standard keypad matrix, so to read all the buttons I needed to strobe 3 lines and read 4 inputs for each. This allowed all 12 buttons to be read through the now free joystick port. Speed didn't really matter here, so the strobe lines are quite slow. It still responds far faster than you can repeatedly press a button so this isn't an issue.
 

spacer
 
 
Download The Software
The software for this project (AmiTunes and the various scripts and support applications) can be downloaded from my AmiTunes project section. This is of course always being worked on, and at this early stage isn't up to too much, but it will get better.
 
spacer

Read more:  About  |  Current Progress  |  Construction  |  Photos