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.

8 January 2013

Risc OS vs Trolls

It seems hard to beleive how something so old can be recycled into something so wonderful. Twenty-five years ago the UK home computing market was dominated by two machines; the Sinclair ZX Spectrum and the Commodore 64. Both had vast games collections and everybody I knew back then belonged to one camp or the other.

There was of course another alternative as schools favoured the BBC model B and the company that made them (Acorn electronics) also released a home computer known as the Acorn Electron. Nobody I knew back then had either of these machines, as none of us could afford the Model B or really wanted an Electron to do homework on when we could be playing Manic Miner or Jet-Set Willy. Looking back, there wasn't much encouragement to learn to program as our secondary school had one computer room full of Link Research computers (480Z's) which was something too specialised to have at home (and we wanted games). At some point I figured out the hexadecimal numbering system by myself (it was never taught in our maths classes) and learned to do a few simple programs in machine code.

Now some people will try to tell you that nobody programmed in machine code and that you used a higher-level language known as assembler but some of us didn't have an assembler so we picked the intructions decimal values from the Z80 reference book (a small paperback) and created a basic program to put those values into memory. Where we usually got stuck was trying to interact with the computers ROM routines which did all the interesting stuff (like print a character on the screen) but we just didn't have access to how that worked. Well the internet didn't really take off for us average folks until 1996 - over a decade after we got our first home computers.

As we entered the 90's we finally ditched our old 8-bit machines for something new and more powereful. Sinclair sold out to Amstrad and the Spectrum died by not keeping up with changing technologies. Instead we witnessed two new challengers for the title of best home computer. There was the Commodore Amiga (500) and the Atari ST (STE/STFM). Now everyone I knew was a member of the Commodore group as it was a graphically impressive machine and had 4-channel stereo sound. The Atari ST became the machine of choice for musical types, mainly because of its built in midi interface. We weren't convinced though as it had the AY-39something sound chip which was the same chip Amstrad had fitted to the Sinclair Spectrum 128K models a few years earlier. There was also a third contender in the group which was the Acorn Archimedes and I only remember knowing one person (friend of a friend) who was excited about this. I could never understand why.

Fast forward to the present and it seems like the Archimedes was something of a Schwarzeneger. The CPU (the computer bit that does most of the work) of the Archimedes was an early version of the chip which is now powering the Raspberry Pi. Why is this significant? Well at the time these chips used a technology called RISC (Reduced Instruction Set Chip?). The idea was that if you kept the number of instructions the processor knew to a minimum, it would run faster. Of course this would mean more work for programmers because they would need to write simple programs to do things that CISC (Complete/Complex Instruction Set Chips) could do in a single instruction. But the Archimedes was a 16 bit machine with a graphical interface - an early competitor to the rising behemoth of Microsoft Windows which would eventually do to the Amiga & ST what those machines had done to the Spectrum and C64.

We thought the Archimedes and it's operating system (called RISC OS) would ultimately go the way of the Enterprise (a relatively unknown machine with a built in joystick which was advertised on the TV as having obsolecense built-out but failed to convince any of us about that and became... well... obsolete). Yet here we are in 2013 and old RISC OS is back in a big way (or should that be a small way). It's now available as a free download for the Raspberry Pi and I recommend all of you Pi owners get yourself a 2GB SD card and have a look.

How much credibility should techie-types give to an OS which has practically died once already? Well my answer is lots. Microsoft went the way of lets code it and the next round of technology will run faster so everything will run better. The trouble is that keeping up in this way means that to run their stuff well you pretty much need to buy a new system every year or two to get decent performance. This puts people off trying to keep up and keeps technology out of the hands of those hoodied groups who've actually got enough spare time to dedicate towards becoming the future of computing but can't afford the premium prices. People now seem to want tablets or phones with enough power to do basic computing. My own nephew got a tablet computer this Christmas - not the latest Nintendo game system or desktop to run power-hungry games, but something portable. I find it interesting to see youngsters opting for less power but greater portability.

I can't help wondering if there will be a point where the computers internals and form-factor will become even more seperated. Not so long ago you bought a case and then chose your motherboard, processor, memory, graphics card, hard-drive and then Linux also brought us more choice of operating system too. Maybe soon we will see people choosing their processor board, memory board, solid-state storage card and then sliding those into a tablet case or a netbook case or even a portable media-player case. Maybe those modules will slide into bigger desktop cases to create multi-processor power systems. Who knows?

Initiatives like the $100 laptop have paved the way for small inexpensive project boards like the Pi & Beagle-board etc. to find their way into the hands of hobbyists and a push to get the Pi used more in education is having the effect of putting computing back into the grasp of youngsters. Throw RISC OS into the mix and you get something which is quite unique. RISC OS runs incredibly well on the Pi - rightly so given the heritage. It's quick to start up, seems to have an industrial level of stability and has the old BBC model B basic programming language built-in. Not only that, but it seems from basic you can turn assembler language into runnable code quite easily without a third party application. Within a day I manged to pick up enough BBC basic and use the GPIO package to program a simple traffic-light system. The hobbyists are going to love this speed and simplicity as it is what this platform does well.

Sadly to use the Schwarzeneger simile from before, he's back but it's obvious he's a robot now. RISC OS isn't perfect. At the moment it has the Netsurf browser which provides a very fast and very good browsing experience (I use it almost daily) but it lacks certain features like javascript. I'm all in favour of being able to turn javascript off (reduces malware/viruses y'know) but it seems I couldn't write this blog-post without it. Also, not having flash has made for a browsing experience that reminds me of early days of the internet. It's a bit like being back in the mid-late nineties when we started to see advertising images appearing everywhere on web-pages, but before they started to launch pop-ups or use up your bandwidth by downloading streaming video adverts which you never really wanted anyway. It's a great browsing experience - less annoying and much faster. Will it appeal to todays generation who feel the need to upload everything they do to Youtube though?

Well the internet trolls seem to think not. That's what gave me the title for this post after spending some time over at the RISC OS forum on the Pi foundations website. The trolls wasted no time in posting links along the lines of "have a look at this" and then linking to sites which couldn't be viewed due to the lack of javascript. While some of us are impressed at a tiny, speedy OS which turns the Pi into something useful, there is sadly a minority who take pleasure in pointing out flaws. Some of the criticisms are quite justified as these days I think we have an expectation to be able to do a certain amount with a computer without spending a fortune on third-party software to do basic things.

The essential features of an operating system have gone way beyond what they were when RISC OS was originally developed. Nowadays we expect as minimum the ability to browse the internet, open a PDF or MS Office document, print something out, connect to a network drive (or cloud storage of some sort), transfer files from one device to another (between USB flash drives for example) or view a streaming video file. All of these are valid requirements and at the moment RISC OS can only do a few of these tasks well without buying extra software.

Sites like Youtube and Video Jug provide tutorials as well as videos of peoples pranks. At the moment you can't just browse their site and view content as you can on Windows (or Linux variants with a suitable flash plug-in). Would such a plug-in reduce the speed of browsing in Netsurf to the point where you might as well go back to using a Windows/Linux system? If so that would be too high a price in my opinion. A statement which also raises another point. RISC OS has a desktop link to it's very own Pling-Store. At the moment, many of the packages on there seem over-priced and there don't seem to be demo or lite versions to find out if they work or do anything useful.

So it seems while RISC OS definitely will appeal to us techs, anyone who remembers using a BBC model B and all the hobbyists out there in the world, I can't see it being the saviour of hoodies everywhere just yet. For that to happen, it will need to address its short-comings. Also lets hope that the internet can help todays interested youth overcome the obstacles to programming which we had back then - a lack of good information about how to program what you wanted. Most importantly of all though, give the kids what we wanted back then which is some decent games that don't cost an ARM and a leg (apologies for the pun!).