Usual disclaimers: I'm not a doctor, legal professional or financial advisor. This article is for information/education only and reflects my own opinions. It should not be taken as financial, legal or medical advice. Do your own research and never invest anything you cannot afford to lose (including your time).

9 January 2013

Raspberry Pi, Risc OS and playing MP3 files from BASIC

I am currently really enjoying a quiet spell in which I can finally perform a few experiments with my Raspberry Pi. I'm sticking with Risc OS for now because it seems like a very useful hobbyist platform. Today I have figured out how to play MP3 files using the included version of BBC basic.

I should point out straight away that this uses a third-party application which fortunately is freeware. So to start, use the !packman icon on the desktop and download the application which is called Madplay. I found it easily by entering Mp3 into the search filter. Once downloaded, just double click it (it should be in your Apps/Audio directory). It appears this survives a restart so you only need to do it once.

The next bit is to download an mp3 file (I'll leave that to you but suggest you keep it legal). I set up a folder called Mp3 in the root folder for this. Then you just need a single line of code from within Basic to activate the sound. This is:

*madplay "/SDFS::RISCOSpi.$/Mp3/filename"

Notice the asterisk at the start is important. The player does not seem to multi-task at present but if you need to get control back before your mp3 ends, just press escape. I may well use this as a starting point for my ultimate alarm-clock project at some point. I quite like the idea of a random wake-up alarm instead of the standard electronic bleeps which cuts short my blissful rest every morning. Not sure how the other half will react to the sound of Robin Williams shouting "GOOOODDD MORNNNINNNG VIEEEEETNAMMMMM!!" but it's one of those projects you know will be memorable.