38
E R N I E T H E E L E C T R O N O R G A N I S T I C Or - How to make a BBC Micro play a pipe organ

Ernie The Electronic Organist

Embed Size (px)

DESCRIPTION

My presentation on a hardware hack project which has been undertaken by my Dad, Geoff King.Done for BarCampBlackpool initially, and also presented at BarCampLondon7.

Citation preview

Page 1: Ernie The Electronic Organist

E R N I E

T H E

E L E C T R O N

O R G A N I S T

I C

Or -

How to make a BBC Micro play a pipe organ

Page 2: Ernie The Electronic Organist

ERNIE the Electronic Organist

BarCamp London

Presentationby

Caz Mockett

Page 3: Ernie The Electronic Organist

ERNIE the Electronic Organist – About The Project Engineer

I am presenting a hardware hack project which has been undertaken by my Dad, Geoff KingHe is a closet geek/engineer/tinkerer with many years’ experience under hisbeltHe spent most of his career before retirement in the Physics Department of the University of EssexHe taught the students how to interface lab experiments with KIMs, then BBCs, and later PCsWhen the BBC Model B arrived, he had an idea to use one to play the organ in his local church, where he has been organist since the mid-1960’s

Page 4: Ernie The Electronic Organist

But in the early 1980’s they were expensive state-of-the-art machines – as you may have seen recently on the excellent BBC4 series Electric Dreams!So the idea was put on hold for a while. But you know a geek. An idea never really goes away...Some 20 years later, with his retirement looming, he was able to “acquire” several Beebs, by then regarded as redundant and heading for the scrap heapThe idea was dusted down, and Ernie the Electronic Organist was born

ERNIE the Electronic Organist – About The Project Engineer

Page 5: Ernie The Electronic Organist

The church organ is a modest affair of 6 speaking stops on a single 54-note manual keyboard, with a single stop on an independent 30-note pedal organ

ERNIE the Electronic Organist – The Organ

Page 6: Ernie The Electronic Organist

As small organs go, the instrument is unusual in having electro-pneumatic action This is in contrast to the traditional system of rods and levers, known as trackers, linking the keyboard to the pallet valves which supply air to the pipes Switches beneath the keys supply current to a series of solenoids which operate small valves controlling the air supply to the pneumatic motors attached to the pallet valves

ERNIE the Electronic Organist – The Organ

Page 7: Ernie The Electronic Organist

Here is a part of the wind chest showing the solenoids in action whilst the organ is played:

http://cazm.eu/ernie1

ERNIE the Electronic Organist – Hardware In Action

Page 8: Ernie The Electronic Organist

An unregulated PSU provides up to 10 amps of current at a nominal 14 volts DC to power the action One side of each magnet is connected to the 0 volt rail, with the keyboard switches on the +14 volt sideThe aim of the project is to simulate a series of computer-controlled switches in parallel with the keyboard switches

ERNIE the Electronic Organist – The Organ Electro-Pneumatic Action

Page 9: Ernie The Electronic Organist

ERNIE the Electronic Organist – The Switching Circuit in Parallel

The analogue switching circuit for each note lookslike this

Page 10: Ernie The Electronic Organist

ERNIE the Electronic Organist – The Switching Circuit in Parallel

A 1-bit data latchstores the state of eachnote, ON or OFF

Page 11: Ernie The Electronic Organist

The LEDs were originally provided to facilitate trouble-shooting at the development stage, but now provide entertainment for interested spectators!

ERNIE the Electronic Organist – The Manual Switching Circuit Hardware

Page 12: Ernie The Electronic Organist

It will be noted that the components are grouped to correspond to the layout of keys on the keyboard

ERNIE the Electronic Organist – The Pedal Organ Switching Circuit

Page 13: Ernie The Electronic Organist

Here is a short video showing the switching boards whilst the organ plays a familiar tune…

ERNIE the Electronic Organist – A Quick Demontration!

Page 14: Ernie The Electronic Organist

The diagram of a sample latching circuit is shown below - there are 4 latches per chip, but there are

only two clock lines, eachone clocking two latches

ERNIE the Electronic Organist – Addressing The Latches

So each latching operation requires two bits distributed via a network of 74LS04 inverting buffers

to provide the necessary fan-out

Page 15: Ernie The Electronic Organist

A single 1-0-1 clock pulse is then routed to one latch pair only, using a 2-to-4 74LS139 decoder and a series of 1-to-16 74L154 demux chips, as shown ->

ERNIE the Electronic Organist – Addressing The Latches

This arrangement requires 5 address bits as well as the two data bits and one clock bit

Page 16: Ernie The Electronic Organist

Each of the 32 5-bit addresses points to a pair of latches, so giving access to a maximum of 64 individual latches

ERNIE the Electronic Organist – Addressing The Latches

There are only 54 notes on the manual organ, but some of the spare latches are used for auxiliary functions, including the operation of the master switching transistors in the 14V supply to upper and lower halves of theanalogue switching board

Page 17: Ernie The Electronic Organist

This is the addressrouting circuit board

ERNIE the Electronic Organist – Opto-Isolators, Decoders and Buffers

Page 18: Ernie The Electronic Organist

This is the latch circuitMuch of the above hardware is duplicated to provide independent operation of the 30-note pedal organ, but this needs only one additional address line to distinguish between the two sectionsThus: Note address bits PB0-4 Manual/Pedal select PB5 Data output bits PB6-7

ERNIE the Electronic Organist – Latch & Buffer Circuit Board

Page 19: Ernie The Electronic Organist

Operation of the above hardware is controlled by a machine code program running on the BBC MicroA user interface in BBC BASIC, normally running in MODE 6, controls the display, selection and loading of items from the music menuPrior to the transfer of control to the machine code there is provision for setting a number of playing parameters, whose values are passed via the Resident Integer Variables

ERNIE the Electronic Organist – Machine Control

Page 20: Ernie The Electronic Organist

The system can play music in up to 8-part harmony, equivalent to 8 separate parts or voices in a choir, and keeps track of the current status of each part The numerical data for each piece of music are arranged in groups to represent events at successive points in time Each event usually involves changing the note being played by any one or more of the parts, including muting any of the partsFollowing are some examples of three typical events

ERNIE the Electronic Organist – Data Format

Page 21: Ernie The Electronic Organist

ERNIE the Electronic Organist – Data Format

Data Group starting at Address 193 199 200

Duration 21 03 00

Control Byte &B4 (180) &83 (131) 08

Notes SXATYBPQ

bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0

A3 (34)--

F#3 (31)C3 (25)

--D2 (15)

----

Significance Voice 4-note chord

Mute Bar No. 8

Starting at address 193 is the Data Group for a chord, duration 21 time unitsThe Control Byte at 194 has value 180 = &B4, which has 4 bits set (7, 5, 4, 2)The voices corresponding to bits (6, 3, 1, 0) will remain unchanged, whatever their previous statesAddress 199 holds value 131=&83 which representsa mute of all voices, duration 3 time unitsAddress 200, 201 hold the sequence 00, 08 whichrepresents the bar line at the start of bar 8

Page 22: Ernie The Electronic Organist

The data group for each event begins with a Duration Parameter, D, a 6-bit number in the range 1 to 63 which defines the length of time that the note or chord in question is to be sustainedThe default value of D is 24 units for a crotchet, 12 for a quaver, etc., although these values are arbitrary – but the inclusion of a factor of 3 facilitates the rendering of triplet rhythms when required Next comes an 8-bit Control Byte which acts as a mask defining which part or parts are to be changedThis is followed by a list of N numbers, each in the range 0 to 54, representing the notes to be played

ERNIE the Electronic Organist – Data Format

Page 23: Ernie The Electronic Organist

N is the number of set bits in the mask and the sequence of note-numbers defines to which parts they are allocatedThe note value zero indicates that the relevant voice is to be silencedA Duration Parameter in the range (1 to 63) + &40 indicates that the previous chord is to be maintained unchanged for a further period of time (a tie) A parameter in the range (1 to 63) + &80 heralds a mute, a period in which all parts are to be silenced

ERNIE the Electronic Organist – Data Format

Page 24: Ernie The Electronic Organist

A Duration Parameter of zero represents an Escape Code which is followed by at least one further byteIf this next byte is a number in the range 0 to 240 (&F0) it indicates a bar number in the music - this is ignored by the playing program but is an invaluable aid to editing the dataValues from &F1 to &FF invoke various special functions and may be followed by additional bytesThese functions include setting the Tempo Parameters, marking the beginning and end of repeated passages, implementing octave- and pedal-coupling facilities and marking the end of the piece

ERNIE the Electronic Organist – Data Format

Page 25: Ernie The Electronic Organist

In the early days, the data lists were compiled and entered into memory manually, which was extremely tedious even for short and simple melodiesAround the same time, Dad was writing a PC-based program originally designed merely to print music in a legible form, and it occurred that it might be possible to combine these two problemsNow, generation of the data begins with a Project in Visual Basic running on a PC under Windows 98Please stop laughing, there are good reasons for using this ancient machine!

ERNIE the Electronic Organist – Generating The Data

Page 26: Ernie The Electronic Organist

The programme initially displays a pair of blank staves, plus, in the case of organ music, an additional stave to show the pedal part

ERNIE the Electronic Organist – Generating The Data

Page 27: Ernie The Electronic Organist

Notes are inserted by a series of mouse-clicks to build up a single line of music

ERNIE the Electronic Organist – Generating The Data

The information displayed is stored in memory merely as the note-values and their co-ordinates on the staves, and each line of music can be saved as a .DAT fileNo bit-image files are involved

It is important to note that all the notes in a given chord must be vertically aligned at the same X-co-ordinate else they will not be rendered as a single event when played

Page 28: Ernie The Electronic Organist

The N lines of music required for a given work can be printed out for future reference

ERNIE the Electronic Organist – Generating The Data

The filename for each line of music is constructed from the file-stem, Bday in the example shownPlus the bar number at the start of that line, thus Bday1.DAT and Bday5.DAT

Page 29: Ernie The Electronic Organist

The treble clef (normally played by the right hand) contains the Soprano part (tails up)Alto (tails down) and an extra intermediate part (X, with no tails)

ERNIE the Electronic Organist – About The Voices

Similarly the next stave down (bass clef, normally played by the left hand) supports Tenor (tails up)Bass (tails down) and an additional part (Y, no tails)

The lower bass clef, where used, is played by the pedals and can contain two parts, tails up (P) and down (Q)

When the music has been compiled the order of parts as shown in the Control Byte is from most to significant bit to least: S, X, A, T, Y, B, P, Q

Page 30: Ernie The Electronic Organist

Visual Basic and Windows can now be closed and a compilation program loaded in GWBASIC under MS-DOSDetails of the file-stem (Bday), bar numbers (1, 5) and Folder (Happy) are entered, together with an estimate of the required metronome value in crotchet beats per minuteThe compiler then reads each if the .DAT files in turn and processes them into the format required by the BBC programThe complete data list is saved as a .BIN file, e.g. 8HBDAY1.BIN , indicating 8 parts (and 7+ext file name)

ERNIE the Electronic Organist – Compiling The Data

Page 31: Ernie The Electronic Organist

Control is now passed to a second program in GWBASIC

ERNIE the Electronic Organist – Generating The Data

This enables the data to be edited and any errors and omissions correctedIn this 8-part PC editor two lines of data, comprising 32 columns or events, can be displayed Note that a line of displayed data does not as a rule correspond to a line of the printed music

Page 32: Ernie The Electronic Organist

Various features of the data are indicated by their colours: green (decimal) numerals indicate memory addresses at which the data for each event begins

ERNIE the Electronic Organist – Generating The Data

Red (decimal) numerals are the Duration ParametersPale blue (hexadecimal) numbers are the Control Bytes, and the white characters define the note letters and the octaves in which they are situated

The usual range of organ music is from two octaves below middle C (C1-B1, and C2-B2) to two and a half or three octaves above (C3-B3, C4-B4, and C5-F5 in this case)

Page 33: Ernie The Electronic Organist

Phrasing in organ music is achieved solely by small adjustments to the duration of selected chords and by short gaps inserted between them

ERNIE the Electronic Organist – Editing The Data

Pressing any key at this stage of the display causes the lower line of 16 columns to be erased and replaced by cuesand spacefor inputstatementsto makeany changes

The data as initially compiled will often sound rather bland and boring but can be made to sound more realistic by careful editing atthis stage

In particular it is the custom to increase the length of the first note in each bar by one unit, a process carried out automatic-ally by the compiler

Page 34: Ernie The Electronic Organist

A further GWBASIC program is then invoked to transfer the file over a parallel cable to a BBC where it is received and saved by another program

ERNIE the Electronic Organist – Transferring The Data

After the data has been edited it is wise to save it to a different filename, e.g. 8HBDAY2.BINThere is also a BBC data editing program but due to memory space constraints it is very limited in scope compared to the PC version & can display only 10 cols or events at a time

The data, now on a BBC floppy disc, can be taken to the church to be tested on the organIf necessary, final adjustments can be made there using the BBC editor

Page 35: Ernie The Electronic Organist

In typical geek fashion, the project was originally undertaken to test an idea and see if it could be done After a few teething troubles were ironed out it has proved extremely versatile and reliable and appears to be capable of playing almost any organ music that can be rendered on a single-manual instrumentIt just requires sufficient time and patience in setting up and editing the data

ERNIE the Electronic Organist – So Why Bother?

Page 36: Ernie The Electronic Organist

It now plays most of the voluntaries in the weekly service and has even been used for an evening’s organ recital, raising money for charityWith the aid of a computer-literate assistant, it has occasionally been used to accompany the hymn singing when no organist has been available However, setting up the files for 5 hymns is no trivial task since each verse may need to be differently edited for correct phrasing due to different words

ERNIE the Electronic Organist – What He Can Do

Page 37: Ernie The Electronic Organist

And now for a short recital…

ERNIE the Electronic Organist – Ernie Performs!

Page 38: Ernie The Electronic Organist

I have often wondered if, instead of spending so much time designing hardware, software and inputting data to the system, Dad had spent the time practicing the organ tunes in the first place, he would be able to play them himself!But that would not have been half the fun ;-) So, any questions?

ERNIE the Electronic Organist – Final Thoughts