Rock your computer with AMPlayer: Justin Fletcher discusses the RISC OS MP3 playerBy Chris Williams. Published: 28th Mar 22:47:06 | Permalink | Printable
This article was originally intended to be a news article but due to its size, quality and in-depth nature we have upgraded it to a full RISC OS feature article. Thanks go to Justin Fletcher for his help in writing the article.
Earlier this month, Justin Fletcher announced the release of AMPlayer 1.29. Originally written by Thomas Olsson and recently further developed by Justin and Robin Watts, AMPlayer is a module capable of playing Audio MPEG files, or MP3s as they are commonly known as. Audio MPEG files are ideally music stored in a digitally compressed format that modules like AMPlayer decode and playback on the fly.
According to Justin's announcement major changes from the previous version 1.26 are listed below. The full gory details of AMPlayer's development can be found in the Changes files that comes with the AMPlayer distribution.
- Full support for VBR (Variable Bitrate) files generated by Xing compatible encoders. This means that the total time of the track is now understood from the headers it uses.
- Support for ID3v1.1 track numbers.
- Support for ID3v2 (version 2-4) tags. These are now correctly decoded and passed to interested clients. ID tags, by the way, are little pieces of information within an MP3 file that describe details like the Author, Album and Track name of the music contained in the file. An external client could be set up to, for example, load applications based on tracks you decide to play. How about using OvationPro to Primal Scream?
"ID3v1 was invented by someone because they wanted to 'tag' their files so that they knew what they were more sensibly than just using a filename", Justin explained to me in an email. "It consists of sticking 128 bytes on the end of the file containing artist name, album name, track name, a comment, a year and a 'genre'. Initially they started out with about 20 genres, but this has increased massively to include many different types of music."
- 'Filter plugins' can control and destroy the DCTs in interesting and not so interesting ways (an example filter is available). A typical filter could act as a graphic equaliser such as reducing or increasing the bass on a track.
- MPEG 2.5 frequencies 8kHz and 12kHz are now supported.
- Updating the dynamic area size no longer stalls or stutters playback. AMPlayer uses this dynamic area as an 'anti-shock' so playback doesn't suffer when the computer is busy doing something else.
- AMPlayer_FileInfo SWI call allows other applications to read information on files without needing to play them.
- The system variable AMPlayer$Volume allows you to set the music volume even if AMPlayer has been removed. This was handy during development as each time a new incarnation of AMPlayer was tested, you could keep the volume at the same level from a previous test. Very useful at 4am.
There have also been numerous bug fixes, one particular fix being that stereo output is now the right way around.
It is safe to say that Justin Fletcher is a prolific software writer, working for sometime at RISC OS Ltd. to develop, along with Robin Watts and others, the RISC OS 4 most of us are using now. "The reason", writes Justin, "you have commas and the ability to count things > 4G in the Filer_Action Count window is because otherwise I couldn't see how much space was used in my MP3 collection. Sorry :-)"
Justin's involvement with AMPlayer started back when Thomas Olsson released version 1.06. At the time you needed 16bit sound hardware to playback MP3s and unfortunately Justin didn't have this. About the same time, Justin was working on Doom for RISC OS and he had written a 16bit sound emulator for 8bit sound hardware to check the game's MIDI music player worked. The emulator allowed AMPlayer to work on 8bit sound and incidentally, a copy was also passed to a friend of Justin's who used it to queue up music at his birthday party. Justin is also responsible for IRCMP3, an internet utility that allows others to find out what you're listening to while online in an IRC channel.
A utility by the name of ControlAMPlayer was written to allow music playback to be easily controlled from the keyboard; Justin admits he can't leave a room now without instinctively pressing the '*' key on a computer to pause the music. After receiving the source code to the player front end from Thomas Olsson, Justin has added a track progress bar and a playlist to queue music. The front end is the application that allows the user to tell the AMPlayer module what to play, very much like the control panel on your CD player. Much of recent development however has gone into the back end, or the 'under the bonnet' side of AMPlayer. AMPlayer is, by the way, compiled on Justin's StrongARM RISC OS 4 RPC with Norcroft C and Objasm along with some pre-processing stuff thrown in. Justin was able to fully assist with AMPlayer development when Thomas Olsson installed CVSWeb on his computer, allowing both programmers to work on the same source code that was stored in Thomas' machine. Unfortunately, Thomas found himself unable to find the time to contribute to AMPlayer, so Justin got to work with the module.
"Basically, Thomas was too busy with work to be able to get anything done
sensibly with AMPlayer", writes Justin. "The first thing I looked at was making it support variable bit rate MPEG data."
I asked Justin about this variable bit rate effect, or VBR. The bit rate is the level of detail in which a piece of music is encoded into digital format: a high bit rate ensures good quality but a longer file since more data needs to be stored. As Justin understands and explains, certain parts of music don't need a high bit rate so the bit rate for that particular section is reduced usually to save on file size.
"If you're streaming data along some fixed rate path, eg internet, or with a video feed (MPEG video) then you want to keep this data rate constant. VBR is the colloquial term used when each frame can be a different size. This is useful because it means you can encode the 'dull' bits in less bits, and the sections that require a lot more range can be encoded in a larger frame. For example, if the start of a track is quiet, it can probably be encoded at a rate like 64kbit/s. After a moment or two, you might have a lot of high violins come in. They wouldn't need too much more encoding, because they're quite pure sounds, so you'd probably go up to 80 or 96kbit/s. If you then put a voice over that you've got a larger range of frequencies used. Some of the higher frequencies would be masked by the voice itself, so there might not be a great degree of gain, but it will still have an effect. So, to encode enough resolution over this greater frequency range you'd use, say 128 or 160kbit/s. A bass line might start up, and you'd have to deal with that. Now, the bass line probably masks a lot of the voice and higher frequencies, so your clever psychoachoustic model (that basically means 'your idea of what the human ear hears compared to what frequencies are present') doesn't need to work as hard - it probably uses a very similar rate for that extra sound, 160kbits."
According to MP3 format documention, Justin found that MPEG data can change its characteristics, such as the music bit rate, as it sees fit. After consulting the code to other MP3 players, Justin enabled AMPlayer to handle VBR. On a side note, whilst working at Pace Micro, a particular music track was causing AMPlayer to crash. Eventually Matthew Bullock found the problem and it related to the buffer, or the area of memory, that AMPlayer fills with processed data to be played. This buffer is a of fixed size that is a direct multiple of the data processed from a frame of music. If the frame size of a track were to change, AMPlayer would trip up as it relies on the buffer to contain a whole number of frames.
"The problem came when the layer and or MPEG version [of the track] changed whilst playing", explains Justin. "Because of the output data size changing, the last sample output into the buffer might have been part way through the buffer. This meant that when we got to the end of the buffer we'd overwrite the end of it. Not a nice thing to happen."
Fixing this problem gave Justin further insight into the workings of AMPlayer's buffer. Changing the buffer size during playback doesn't distrupt the music anymore as only last segment of audio in the buffer is removed and replaced with new audio data rather than clearing and re-filling the entire buffer.
"It's not technically seamless, because we can have errors of up to 1651 samples (I *think*, it might be less than that) but to the human ear, that's not usually perceptible - there'll be a phase change, too, which might show up as a small 'click', but you're a better man than I if you can hear it."
The new filter system to AMPlayer allows 'plugins' to alter, modify or display what the user gets to hear. Justin has used the plugin interface to create echo and reverb effects as well as a little analyser, AMSpectre, that visually displays what you are listening to as a frequency bars. The effects are made possible by Thomas' plugin interface which offers the decoded music to other programs for them to fiddle with before the user gets to hear it.
Justin has also written MP3Info to reveal information about a MP3 track without having to play it and MP3ID3 to ID all his music.
"It [MP3ID3] was, originally very simple", comments Justin. "Since then it's had a lot of changes, most of which have come from suggestions of other people :-) I set about tagging all the music I had by tagging things 'when I had time'". On the subject of tagging MP3 files, Justin revealed the latest in the music tagging format:
"Recently there's been a lot of work on moving to ID3v2. This is a more extensive tagging format that allows you to include much more information, in a generic way and is (in theory) safe to place anywhere in the file (so long as it's on a frame boundary). ID3v2 includes many, many fields, including user defined ones. As well as the ID3v1 fields, there are other more bizarre fields, like copies of the CD TOC (allows you to identify the CD pretty much uniquely), pictures of the album, or time synchronised lyrics."
You might be forgiven for thinking MP3 files are moving away from just holding audio data. "Certainly I'd prefer internet radio stations to provide more and more relevant meta data than they currently do. The shoutcase and icecast protocols are quite simple (even if they're not documented) and provide a lot of scope for providing interactive content." Meta data is information related to whatever you are reading, watching or listening to and usually transparent to the user although other applications can use meta data to, for example, provide extra services to the user. Meta data handling is expected in a later release that both Justin and Robin Watts are working on.
Another feature developed by Justin for a later version of AMPlayer is the ability to accept audio data from other sources besides files on hard discs or CDs. The act of delivering a constant source of audio data to AMPlayer, (or any media player for that matter), is usually refered to as 'streaming' and Robin Watts had been looking for such a streaming interface while he had been doing some work on the player.
"It's still being beta-tested but the results are really impressive. Coupled with his changes to the internals of the engine to make it run much faster, it's really quite cool now", enthuses Justin. Now when I think streaming, I think listening to music over the internet although Justin believes streaming can be used for more than just that.
"..Basically what we have is a set of buffers in a ring that we go around giving data to and telling AMPlayer where they are. When it's finished with one of the buffers it marks it as being free for filling and the streamer can fill it.
Consequently, you don't actually /have/ to stream data off the 'net; it could be coming from a file (as we do at the moment) or from another input source. Say a flash movie :-)
"...I'd like someone to release a decent Shoutcast plugin. There's many fun things happening here. Flash MP3 samples ? Should be a doddle with the streaming interface."
AMPlayer development is expected to continue at a quick pace before we see version 1.33, which will use SharedSound. SharedSound is what it suggests, you can have many SharedSound-aware music or sample players running together mixing seamlessly. Justin also is happy to admit that the work behind the 'to-be-released' 1.33 is Robin Watt's doing. "It's very cool... 1.33 is his work and although I've been there to ensure that we all get the best from it, Robin's really the one who's done the clever work there :-)"
Justin has written numerous utilities to go with AMPlayer, all of which will be released together at a later date. One I haven't mentioned yet is MP3Encode, a front end to RISC OS music encoders cmpa and shine. Justin also thanks in his announcement all the beta testers for their support and help. A developer mailing list has been setup for those wishing to contribute to the AMPlayer effort; the link is given below.
After getting in contact with Justin, I was intrigued by his great love for music. He has a huge collection of MP3s, encoded on a PC from CDs using CDCopy. CDCopy apparently takes a CD, looks up the track names from the online CDDB, encodes them into digital MP3 format and stores them on your hard disc in an very organised manner. While working at RISC OS Ltd., Justin encoded on the PCs and got to know fellow AMPlayer developer Robin Watts. "If you'd seen us at the shows, you'd have noticed one machine sitting playing music for most of the time - that's my fault", writes Justin. "The music obsession gets me all the time :-)"
Having a massive music collection provides an excellent choice for selecting tracks to test AMPlayer's MP3 playing abilities. MP3.com is great for finding tracks that contain music encoded in different styles and methods. "..I'm quite taken with a group called Ghost in the Machine, by the way, which is not my usual sort of music, but it's great for background music :-)" comments Justin. "The audio MPEGs that were created by the original group as reference streams are very useful for spotting problems. But the major way to do it is to encode something you know and can spot problems with.
"Since I enjoy listening to The Corrs, I chose a short instrumental - something that was reasonably 'pure' sounding and that I wouldn't mind hearing again and again - Erin Shore, the first track on Forgiven Not Forgotten."
The aim is to get the same track, but encoded by as many different encoders as possible, playing without any noticeable difference; Justin has 62 different encoding formats covered. With a combined hard disc space of 44Gb, the total count is about 9000 tracks and numerous textfiles with some lyrics, mainly album listings and JPEG images of album front covers. The test files are kept well away from the main music store, as Justin explains, "..Those files don't include the test files, because those stay well away on another disc so that I don't hear Erin Shore 20 times in a row (oh, you don't know how much I hate testing that track now - once is fine - on the fifth you think your head'll explode and after that it gets easier and you become numb and just listen for the anomalies)."
Listening to his music isn't difficult, it's just a case of queuing up whole directories since everything is structured to:
The largest music hard disc, by the way, is aptly named after the God of music, Apollo -something Justin's brother unearthed. It's taken about 8 months to ID all the tracks and when Justin goes out to buy more music, he takes along his Psion palmtop -which details the entire track database- to help with the choosing on what to add next. When Justin tells people about his collection and the size of, a lot of people assume it's all taken from the internet. Justin does have his own views on Riscster which is the RISC OS client of Napster -the service that allows the free swapping of MP3 music files regardless of the copyright status of the traded music.
"I've used Riscster; mostly to get things I already have on tape or album - or just can't get hold of in other ways. That doesn't make it right. I don't like Napster in general because I see it as a organised crime designed to defraud the music industry. Just as a pirate software site defrauds a developer, so Napster defrauds the artists and music companies. People counter this with arguments about the industry charging too much, and that it's just data and such like. If people don't like the price, they don't pay it. That doesn't mean that you break into the store and steal the album off the shelf. Ok, maybe that's a poor analogy, but it's true to my mind.
"Napster's handy; it's useful; that doesn't make it any less wrong. It can be used sensibly, but there's really no way to tell. Some artists are being quite clever with their marketing - I think that MP3 can be a great gain for the music industry if handled correctly. Low budget distribution using medium-low quality MP3s on websites are great as 'tasters'. Many artists do this - MP3.com is going further than that and I applaud them for it; you listen to an artists and if you like them, you can buy the album. Plus the artist gets kickbacks for plays. It's a nice way of working. Internet radio stations - if they can get their act together and provide decent meta content - can lead the way if they're well organised in the future; there's a lot of good stuff out there, but it just has to be tied together (q.v. MedioDome)."
Many thanks indeed go to Justin Fletcher for his invaluable help in writing this article.
AMPlayer 1.29: www.armware.dk/files/
AMPlayer Developer Mailing list: www.smartgroups.tv/groups/riscos-mp3-developer/
Previous: From the BBC Micro, little Acorns grew : The Guardian reports
Next: Let's publicise RISC OS in the Open Directory Project - follow our step by step guide of how you can help!
DiscussionViewing threaded comments | View comments unthreaded, listed by date | Skip to the end
Please login before posting a comment. Use the form on the right to do so or create a free account.
Search the archives
Today's featured article
Internationalising RISC OS
Unicode, i18n and more explained
30 comments, latest by caliston2 on 16/7/03 8:57PM. Published: 10 Jul 2003
Wakefield 2004 show guide
Show 'news' and what else to expect this weekend
5 comments, latest by JWCR on 14/5/04 1:13PM. Published: 14 May 2004
News and media:
RISCOS Ltd •
RISC OS Open •
MW Software •
Advantage Six •
CJE Micros •
Liquid Silicon •
Chris Why's Acorn/RISC OS collection •
The Register •
The Inquirer •
Apple Insider •
BBC News •
Sky News •
Google News •