Blog Page

More SpecDrum Stuff

Matt 0 Comments

I’ve been playing around with the SpecDrum again and I’ve created another kit for it. You can get 808 sounds any number of ways in 2019 – The TR-8, sample packs, iPhone apps – and now the Cheetah Specdrum.

Unfortunately my real SpecDrum isn’t working so well right now, so I’ve had to emulate it. I think the caps need replacing on it because its output is very distorted and it keeps dropping out.

Links:

Kit TZX
Demo song TZX

Loading your own samples into the Cheetah SpecDrum

Matt 9 Comments

Back in the 1980s in the UK the Sinclair ZX Spectrum reigned supreme as the king of the home micros. Sure, it didn’t have all of the bells and whistles that other micros of the time had, but it was cheap, and required nothing more than a portable TV and a cheap cassette deck to unlock hours and hours of fun.

My Spectrum with its SpecDrum.

It didn’t take long for folks to see the potential in the machine, and before long they were making it do weirder and weirder things. One of my favourite devices to stick on the back of my Speccy is the Cheetah SpecDrum – a little box that turns the Speccy into a drum sequencer. Released in 1985, the SpecDrum cost a mere £29.95 (£89.29 in 2018 money) compared to the cost of a full blown drum machine which could cost 10 times that.

Originally the kit came with a pretty bland sounding set of samples; the sort of thing you’d expect from a LinnDrum or similar. Cheetah then released 3 further cassettes with Afro, Latin and Electo sounds. There was a rudimentary kit editor included in these add-ons, but it only allowed swapping sounds from the same slot, and had no function to add custom sounds.

There’s not much inside the SpecDrum; just a Ferranti DAC, a quad op-amp and a quad NOR gate chip.

I bought my SpecDrum years ago, and played with it for about a week before putting it away and forgetting about it. The problem wasn’t the clunky interface or the lo-fi sound quality – it was that the sounds were all quite dull and dated. Unless you really want to make music that sounds like lost Human League demos then you’re a bit stuffed.

I decided to find a way to solve this problem. It’s quite long-winded and there are a few steps required, but this blog describes how I managed to do what I suspect nobody has done before – loaded their own sample data into the SpecDrum software.

Peeking in the memory

First job was to find out how the thing was storing its samples in memory, and where. Using the FUSE emulator, which very handily emulates the SpecDrum hardware, I loaded up the software and used the memory explorer to look for clues. There was nothing obvious, so I used the debugger to look at the Z80 machine code as it was running. The software doesn’t directly read from memory to the SpecDrum’s DAC – instead it sums each of the active voices, converts them from a signed number to an unsigned one and then spits it out of port 0xDF. I decided to dump the RAM and load the raw data into Audacity, which handily allows the import of raw data. Bringing it in as 8 bit signed samples I was able to actually play the drum samples in Audacity. I tried a few sample rates, but eventually 20 kHz sounded the closest to the output of the SpecDrum. I’ve since learned that the SpecDrum software sends an OUT instruction every 173 T states, which works out at 20.231 kHz – thanks to djnzx48 over at the spectrumcomputing.co.uk forums for that brilliant piece of info.

How the samples are stored

The way the samples are stored is slightly strange. The first oddity is that the drums are stored out of order, but only just. Sample 2 through 8 are in order, and then sample 1 is tacked onto the end. The second oddity is that while the samples are of a fixed length, some samples are 3072 bytes, whereas others are 2048. There doesn’t seem to be any means of adjusting these sample lengths either, as the tapes that contain the additional kits have only contain the sample names and the raw sample data. Sample data starts at 0x8400 (33792 in decimal) and the block is 21504 bytes long.

The SpecDrum software groups the drum channels into three groups. It can play one sound from each group at a time, but not more than one from each group. This poses some limitations on what you can do with the SpecDrum, but the official kits are laid out in such a way that it’s not much of an issue. For example, Open hat and closed hat are in he same group, and you’re not likely to want to use both of those sounds at the same time.

The table below shows how each of the base kit is stored in memory, and which group each drum is part of. I’ve used decimal to show the memory addresses as this is most useful when putting sample data together in Audacity.

Drum NoGroupMem. Offset
(Dec)
Length Standard Kit
11194562048Kick
2203072Snare
3230723072Mid Tom
4261443072Lo Tom
5392162048Cowbell
63112642048Hihat C
73133123072Hihat O
83163843072Claps

Preparing samples in Audacity

Let me be up front about this – Audacity is a pretty terrible audio editor. The interface is awful and it’s not very flexible. One very strong advantage it has though is that it import and export raw PCM samples without the header portion. The other advantage is that you can set the sample rate to any arbitrary value.

The settings I use for bringing in raw sample data

Importing raw sample data is very simple. From the File menu choose Import and then Raw Data. This is useful if you want to grab a copy of any samples from the existing sample tapes. The settings you need are pictured here. Signed 8-bit PCM, Little-endian, Mono and a sample rate of 20231 Hz. This isn’t super important so long as the project sample rate matches the rate you import at, but setting it to 20231 means that what you hear coming out of Audacity should match what you will here coming out of the SpecDrum.

If you’re starting a project from scratch you need to do a few things before you import your own samples. First of all, at the bottom of the window set the project sample rate to 20231 Hz and right click the three position counters and set them to “samples”. This helps when lining up your imported samples.

The next step is importing audio. You can do this by using the Import Audio tool in the File menu. Most samples will either be 44.1 kHz or 48 kHz, and may be in stereo. In order to use them with the SpecDrum you need to either discard one channel or mix the sample down to mono, and then resample the audio to 20231 Hz. Audacity has the functions to do these for you in the Tracks menu.

Once the audio has been resampled it can be trimmed to the right size. I do recommend sticking to the groupings laid out above if assembling a drum kit, as it makes the most sense from a polyphony point of view.

The way I assembled the Toybox kit is I imported each sample onto their own separate tracks and edited them down to size. For some samples a fade-out was required. Then I copied each one to a “master” track, making sure that the sample boundaries lined up with the memory offsets detailed above. The final track should be 21504 samples long.

When exporting the audio it is a good idea to knock the gain down a bit. The SpecDrum uses a relatively simple means of summing the samples together. Rather than clipping the output “wraps around” and can make unpleasant clicking noises. I also added a slight -6db roll off at 7kHz to kill off any high frequency noise that might cause aliasing.

Export the audio using “Other uncompressed files” as the file type, RAW (header-less) as the header type and “Signed 8-bit PCM as the encoding.

Getting the samples back in

The first way I got my own samples into the SpecDrum software was to use the “Import Binary Data” feature in FUSE. This reads the contents of a file and puts them into the memory of the emulated Spectrum. Provided the samples you created were of the right format and length you should just be able to import the file from Audacity to memory address 33792. The drums won’t have custom labels or anything like that, but if all you’re interested in is proving the concept then congratulations – job done. This was the way I first managed.

The real goal was to be able to use the kit load feature of the SpecDrum software – as this would let me load in my own kits on my real Speccy.

The way I did this was to look at the Afro Kit tape and try to understand how the data was stored. To do this I opened a TZX tape image of the Afro Kit tape in a tool called ZX-Blockeditor to view the structure of the tape. The TZX consists of two blocks; a header with some text in it and the raw sample data stored as unsigned 8-bit samples. The header file contains the names of the drums as they appear in the software. The file must begin with a lowercase c, and then each drum must have a seven character label. Any spare characters must be padded with spaces. Strangely, unlike the sample data stored in memory, these labels are in the correct order as they appear in the software.

Below are the header portions of the Afro Kit tape and my Toybox tape.

c TRUNK  BUASH HICONGALOCONGA CLAVE COCONUT GUIRO WHISTLE
cKICK   SNARE  HIPEW  LOPEW  HI BEEPCL HIHTO HIHT LO BEEP

Prepare the header in your text editor of choice and save it as a .bin file.

In ZX-Blockeditor create a new file and under Edit choose “Compose Data Block”. Then choose “Custom Data” from the pull down menu and then use the little folder icon to import your prepared header file.

I’m running ZX-Blockeditor using Wine on a Mac, so it looks pretty rough. On Windows it looks a lot smoother

Repeat the steps above for the raw sound date, but this time use standard data instead of custom data.

Save the TZX and you’re done. Congratulations – you just created a drum kit for the SpecDrum!

Downloads:

SpecDrum Toybox (TZX)
SpecDrum Toybox (raw TZX blocks as templates to work from)

Introducing the RC2014

Matt 0 Comments

Until earlier this year my idea of building my own computer was screwing a bunch of parts into a case and wiring everything together – the most complicated tool required being a crosshead screwdriver. This changed when I found Spencer Owen’s RC2014 project.

The kit is available in a few different forms, but I bought the “full monty” version – an 8-slot backplane with modules for the CPU, clock generator, RAM, ROM and serial interface. Notice that there’s no video interface – more on that later.

The machine is based on a Zilog Z80 CPU; the same processor used by the Sinclair Spectrum, Amstrad CPC, TRS-80, MSX and countless other classic computers. There is a whopping 32 KB of RAM to play with, and the system is clocked at a blistering 7.3728 MHz.

The kit comes with every component you need as well as comprehensive build instructions. The modular nature of the kit means you don’t have to tackle the 400+ solder joints all in one go. Thankfully everything is through-hole mounted, so although there’s a lot of soldering at least it isn’t horrendously small stuff. There’s very little to do in the way of configuration. The instructions tell you which jumpers to set for default operation, so provided you’ve not messed up with the soldering you should be able to switch it on and get started with Microsoft Basic version 4.7.

To use the RC2014 you’ll need a PC or Mac running a terminal emulator program and a USB serial adaptor with a standard FTDI-style 6 pin plug. Make sure your software is configured for 115200 baud, 8 bit data, no parity and 1 stop bit. Flow control should be disabled. Under Windows you can use PuTTY or Tera Term. Linux users can use something like Minicom from within the terminal. The computer doesn’t plug directly into a display, although there is a module available that uses a Raspberry Pi Zero as a terminal emulator. This gives you a HDMI-enabled “video card” along with a keyboard interface.


The base kit is a great way to get started with homebrew computing, and because it uses a backplane there are plenty of options for expansion. Spencer has a range of additional boards on his Tindie store, and there are many third-party modules available online. I’ll be talking about some of my boards in a future post.

Simple Digital Noise Generator

Matt 0 Comments

Here’s a little noise-making circuit I’ve been working on. It has a sound reminiscent of vintage sound chips, such as the AY-3-8910.

It works by using a D flip flop clocked by a 555 timer to sample and hold the signal from a ring oscillator. The high speed and frequency instability of the ring oscillator (close to 4 MHz) makes an ideal noise source, and the variable sampling frequency affects the frequency content of the noise.

This is a good example of the Nyquist theorem in action. As the clock rate of the 555 is lowered the high frequency content of the noise disappears. There is naturally a lot of aliasing, as this is a 1-bit signal, and there is no reconstruction filter on the output, but the frequency roll-off is still clearly audible.

Schematic

Parts list

ICs

CD4070 XOR Gate (IC1)
NE555 Timer (IC2)
CD4013 D Flip Flop (IC3)
LM386 Audio Amplifier (IC4)

Resistors

1 kΩ
1.5 kΩ
10 kΩ
100 kΩ Log. Potentiometer

Capacitors

10 nF (x2)
220 µF

Planning circuit layouts with DIY-LC

Matt 0 Comments

At some point there will be an Arduino project that is just too good to take apart. You can’t leave it on the breadboard forever, but building a circuit on prototyping board can be confusing for beginners.

The best way to make this process easier is to plan the layout of your circuit before you start building. I used to use graph paper to do this, but then I found a great free tool called DIY-LC.
Read More →

Arduino Tip: 7 segment LED display with 4094 shift register

Matt 0 Comments

This is my first Arduino example sketch – hopefully the first of many.

This sketch allows you to control a 7 segment LED display using an Arduino and a 4094 shift register. Only 4 data pins are used on the Arduino, rather than 8 if you were to control the 7 segment display directly. For this example I used a common cathode LED display.

Simply copy the code below into the Arduino IDE, build the circuit explained in the notes and watch the numbers count up.

Arduino 7 Segment Display

Read More →