Raspberry Pi Chiptune Player
I have been staring at a blank screen for whole minutes. There are no words for just how much I love this project. I’ve already been on eBay to find a General Instrument AY-3-8910 series sound chip so I can play with one myself. Before we get into details, feast your ears.
What’s going on here? The Raspberry Pi is playing chiptunes by serving the files directly on to a AY-3-8910 (brought direct to you from the 1980s), while doing some rather jolly LED visualisation too.
The AY-3-8910 is no longer made: it was a piece of kit you’d find in most arcade machines, games consoles and home computers in the 1980s (if you had a ZX Spectrum, an Amstrad CPC or an Apple II, you’ll be familiar with its gorgeously grungy bleeps and bloops). Nowadays there’s dwindling stock that goes to service old machines, or to make entirely new things that’ll play chiptunes – like this beast.
Vince Weaver, the maker, says:
The AY-3-8910 is fairly straightforward. Three channels of square waves plus various noise and envelope effects. Provide a clock (1MHz in our case) and there are 16 (well, 14) on-chip registers you write to. Just put the address then the 8 bit value on the bus, toggle the 3 bus control pins, and you are set. You’ll want to do this fairly fast. A typical YM music file wants you to write all 14 registers every 50Hz.
I use the Pi’s GPIOs to shift an 8 bit value into a shift register. Then I use a few more to drive the control bus.
Visualization is done with some i2c LED displays.
The amplifier is an LM386 design from the AY-3-8910 datasheet.
Vince has plans to make some improvements (adding stereo, printing a PCB, swapping out for a better amplifier, using SPI to drive the shift register instead of GPIO and refining the software), but even in this prototype version, this is a piece of kit I’d love to have on my desk. Fortunately, we can replicate the project: everything you need is on Vince’s website and on GitHub. Thanks Vince!
40 comments
Mark
I can’t help thinking this is one of those “got to be done” projects which could be achieved a lot easier with, say software emulation, but still, I love it! Now can we do this with the C64 SID? :)
David bock
Two years ago I did this with the 6581 out of a Commodore 64. There is even a Sid file player that can either emulate, or send instructions to a device. Wiring up the chip was pretty straightforward… The hardest part was writing a device driver that worked. I found some prior art, but it wouldn’t compile and took some work to get it working on a raspi with a current kernel. I’ve been meaning to revive the project enough to document it. I didn’t have all the cool blinks lights though… Gonna give that some thought.
AndrewS
For something a bit less DIY, you can also use https://shop.pimoroni.com/products/propeller-hat to play SID chiptunes :)
Darrell
Great suggestion, I’ve got one of those Pimoroni Propeller Hats – need to give that a try!
Joakim L. Gilje
I’ve got a working project with schematics up at https://github.com/jgilje/reveller for playing SID files on a 6581.
James Carroll
Thanks for that. I just picked up a working C64 with disk drive for 25 bucks. Been playing around with it but I have 2 fried ones that might have good SIDs in them. Going to find out.
alister
this chip was Not used in the spectrum,
the processor in the speck had to manualy drive the speaker wire on an io port, that is why basic program,s halted whilst beeping.
it was used in the BBC which gave it sound that was only rivalled by the C64
Liz Upton
Interesting – Wikipedia has it in the Speccy. Where’s your info from?
mahjongg
The AY-3-8912 was used in the later models like the Spectrum 128 and plus models, The original spectrum 16K and 48K had a single bit beeper only.
Ivan Roulson
I think there was an edge-connector add on for the 48K. I built a similar one for my Jupiter Ace on stripboard. Worked a treat.
JPW
Yup original speccy had only piezo-style audio only – that’s why I got an Oric ! ( and then experienced games-envy and bitter resentment towards all my speccy/bbc/c64 owning friends !) ah but could they type PING , SHOOT , ZAP and EXPLODE on their machines ???!! :-) great project well done – SID chip next please !!!
Pete
No, the BBC B had a TI SN76489 as a sound chip.
Peter Ryan
Yep, I was reading that and thinking (in a Yorkshire accent), “Sound chip? On a Spectrum? Luxury! Pure luxury!”.
Mike Cook
“it was used in the BBC ”
No it wasn’t. I know every inch of that circuit. I did incorporate one into my home brew TRS80 extension box back in 1978.
Liz Upton
*Points up* If there is anyone who comments here who knows more about the BBC Micro than Mike does, I’d be astounded. He’s a walking schematic diagram.
Jeff Haddow
I have a RPi 3 which I use for Desktop Computing and have a Firefox browser. The Video on this page does not play the sound. It just gives a Lot of White noise with a repetitive sound in the back ground. The Video plays OK, and the sound on other UTube videos is OK. Anyone else have this problem?
mahjongg
The video plays fine on a Windows PC with Firefox, so its not the video itself.
How about other blogs here with video?
Jeff Haddow
Yes I know it plays ok on other platforms, But I am using a RPi3 with the latest updated OS, so it should play ok on it too. I used to be able to play all videos, but now just lots of noise. Other sound sourcees like SonicPi play ok.
Liz Upton
Use Epiphany. It works there. Firefox on the Pi basically works for everything except video. (I’m quoting directly from JDB, who’s sitting opposite me.)
Jeff Haddow
Thanks, But On Epiphany all but I get are Big Black rectangles where the videos should be. Do I need to deinstall the Firefox for it to work?
Liz Upton
What’s your GPUmem set to? It definitely works out of the box – but if you’ve changed any settings, it’s anyone’s guess what’s going on!
Jeff Haddow
My GPU Memory is set to 128. what’s the out of the box figure?
Liz Upton
64. Give that a swing. (Although I’d expect problems with a lower rather than higher number.) If that doesn’t fix it, try a fresh install on another SD card – my strong suspicion is that you’ve changed a setting somewhere that it doesn’t like.
Jeff Haddow
Thanks for the helpful suggestion, after much faffing about with creating a new SD card that wasn’t corrupt and held a working OS — I have found that with a new setup the sound on the Epiphany Browser is now working. :)
Oh well — Now to reload all the stuff on the old one…….. :(
Jeff Haddow
Thanks for your helpful suggestion. After much faffing around getting an uncorrupted SD card with a working OS – I sucessfully got the Epiphany to produce a video sound without the white noise. :)
Still don’t know what caused the problem in the first place. Oh well now to reload all the stuff on the old card …. :(
Thanks again
Jeff Haddow
The sound on this video plays as white noise. I have a RPi3 and am using the Firefox Brouser. Some Utube videos’ sound play OK. All the Blog videos seem to have this problem. Anyone else experiencing this problem?
mahjongg
duplicate post. (sorry have my moderation hat on)…
Dave
Just ordered one from eBay, can’t wait :)
Tony
I had one connected to my UK101, cica 1980.
Sabrina
Nostalgic and hipnotical sound.
James Williams
I’m pretty sure I have one of these chips in a box somewhere. Now I know what to do with it. Brilliant!
Michael Hill
Hook up a POKEY IC (Atari 8-bits’ sound chip) and I’d be in nostalgia heaven!
JBeale
Nice! I remember buying one of those chips when I was first getting started in electronics and poring over the datasheet, but I don’t remember getting much done with it. Programming the registers was a lot of work. There was another sound chip that could generate phonemes, which you could string together with some trial and error into awkward mechanical speech sounds. Now text-to-speech on a Pi is only a “sudo apt-get install espeak” away and infinitely easier to use.
Pete Stevens
Oh wow. My 128k Speccy had one of these in and I was convinced it was just the most amazing thing ever.
I once had a game that played Axel-F as a sound track which I thought was brilliant, so I did the only sensible thing as a piano playing computer geek, hacked into the piece of software, disassembled the code that played the music and reverse engineered it back into sheet music so I could play it on the piano.
Oh wow, it’s on youtube.
https://www.youtube.com/watch?v=qKQnNGHWQcE
Liz Upton
I got my Grandma to buy me the same sheet music. MUCH easier.
mahjongg
I have designed and built my own ZX-81 clone, the ZX81+35, and I’m in the process of designing an AY-3-8912 sound expansion board for it, a clone of the venerable ZON-X81 PSG. There is actually ZX81 software that uses it. One example is dancing demon, but there are also ZX81 chip tune players.
https://revspace.nl/ZX81%2B34_ZX81_clone
mahjongg
Schematics etc, for The ZON-X81 and my own board:
https://revspace.nl/Zon_X-81_Programmable_Sound_Generator_expansion_for_ZX81%2B35
JPW
Talking of the original Spectrum’s ‘beeper’: check out the original “Spectrum Basic Programming Manual” from the 80s, in particular chapter 25, Page 128 [ here : http://www.worldofspectrum.org/ZXBasicManual/zxmanchap25.html ]. The manual seems to have predicted (albeit in a slightly garbled way – but that never stopped a good prophecy ;-) ) “a computer that is to come after me” ….. (Hint: look at mnemonics for system variables 23608 and 23609 – which happen to relate to the sound generation routines)…
Andrew Waite
Superb project. Thank you for sharing.
Ghan Patel
Raspberry Pi 3 hardware manual to interface GPIO .
Signals information for 40 pin header connector.
How can I find this information.
Comments are closed