EUG PD


The Moscow Demo

 
Published in EUG #70

I decided to start this year (2010) with a brand new 'old skool' music demo for the BBC series, and The Moscow Demo is the final product, released under the banner of The Organ Grinder's Monkey. In its implementation, it did in fact evolve to be both something more than I originally planned, and, in its code, to be a bit of a mess.

This article is therefore by no means an instruction on how to program music demos for the Beeb. However, as someone not musically-minded, the demo did help me to determine just how difficult those Addicts' Anthems and Daniel Pugh masterpieces must have been to put together.

So the original plan was simply to write a music demo for the BBC using all four channels of sound, as a homage to those of the 1980's. With that in mind, I chose a nice 1980's song which I couldn't already find - Moscow by Genghis Khan, a cheesy little Europop number that deserves more recognition than it currently has. I then had a scout around the internet to see if I could find some sheet music for it.

Well, sheet music (which used to be relatively hard to come by back in the days pre-internet) is available out there in its abundance, and utilities such as Notation Composer for your PC are enough to make their way into your wet dreams. A few downloads and clicks of the mouse later and I had a 27-voice orchestra blasting Moscow from the speakers of my PC with visual scrolling sheet music and the individual notes of each section being highlighted in perfect time.

Wow! Well, that's about 75% of the work done for you, as a BBC music demo, writer, done right there...

Except it's not because, surprisingly, there's a bit more to writing a music demo than choosing which sections of the sheet music you're going to port over to the BBC and then writing down each note and each rest then stringing together some ENVELOPE and SOUND statements. Firstly, if you're not a musician then you have the rather arduous task of working out which keys should be played as flats and sharps. Then you have the task of looking up what decimal value each note should be given (in the User Guide). Finally, you have to write a customised program to step through the notes and play the tune. Oh, and I found it impossible to even attempt to code a music demo on an emulated BBC (through BeebEm) - the sound emulation is not accurate enough.

Bearing in mind the limitations of the BBC's memory, it is essential that notes are played as they are read by means of a 'lookup'. Now not all music demos do this; with very short ones it is not necessary. Rather frustratingly, although there are several books dealing with writing music demos on the BBC, none of the ones in my collection had anything more than short example programs in them. The result is that you end up with code which gradually becomes more complex.

For example, you are playing on four separate channels. So you first of all work out the notes you need to play on channel 0 (the drums) for one 'bar'. RUN that. When that sounds fine, you work out the notes for channel 1 (the main melody; useful to put this on channel 1 so that the demo works on the Electron if you turn all other channels off). Enter these. RUN the program again. Now, you add channel 2 (the background theme). RUN. When working, add channel 3 (the orchestra). RUN again.

THE MOSCOW DEMO

Once you've got this working, the code will suggest a number of shortcuts to you. i.e. if you are using SOUND statements, just this tiny bit of music can stretch to 50 lines or so. But if you make an array of note values for each channel and just READ in the 'pitch' and 'duration' then you reduce the program code to just a few lines. If you can make the 'pitch' something more readable than a decimal value (i.e. the letter "c" instead of 132) and write a procedure to let the computer do the interpretation back to a decimal value then you can start to write more human-readable code, which is obviously quicker.

The trouble is, however, that each channel needs its own array, and its own pointer keeping track of where it is. And if you start storing music as strings, they can take up a lot of memory unless you READ them in, play them and then discard them. As all the channels must play together, even getting the duration of a single note 'off' by a fraction of a second results in the whole tune going haywire.

The further trouble is that you have to listen to the early parts of the song whenever you want to test-listen to the later parts, unless you start re-writing your code to pick up in the middle of the song, or start dividing the tune into sections. If you choose to divide the tune, it can have some effects that you didn't intend, such as pauses creeping in as the computer looks for the procedure definition. When you are testing by each section at a time, these pauses can escape your attention until the final 'full runthrough'.

In The Moscow Demo, data is stored in strings which are parsed for pitch and duration of notes. The character of the pitch is referred to a lookup of a note in that 'key', which made the process of copying the notes from a PC much much easier. Unfortunately, I realised too late that odd notes are outside of that key and had no lookup. Answer - I poked these in by creating new notes with different decimal values. This worked - but made the code even more complicated.

Anyway, originally the demo was meant to be a simple Mode 7 number but, after I did get the music sorted, I decided a nice picture and lyrics would 'complete' it. The scrolling message was probably a step too far with retrospect as it takes the demo into Master 128 only territory, which wasn't really my intention. However, it's easily removed by simply going into the program and taking out the CALL to it. After this, the program will run quite happily on all series, including the Electron although of course on the Electron it plays on only one channel.

As a first attempt at music coding, The Moscow Demo is interesting if a little flawed. I hope to build upon what I learned when constructing my next one. In the meantime, here it is for your listening pleasure...!

The Organ Grinder's Monkey