BeebOPL: an FM Synthesiser for the BBC Micro

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
User avatar
lazarusr
Posts: 599
Joined: Thu Sep 10, 2015 8:56 pm
Location: London

BeebOPL: an FM Synthesiser for the BBC Micro

Postby lazarusr » Tue Jul 05, 2016 8:32 pm

I have finally found some time to do a little more work on my OPL synth project.

No sooner had I suggested (here) that I would use a couple of addresses previously reserved for the Teletext Adapter on the basis that such a device was 'obviously' redundant, I came across no less than 3 people working on projects to use this adapter. So in the end, I opted to use &FC04 and &FC05. As far as I can tell from Jonathan's excellent Fred Address list, these don't seem to have been used for anything.

I have started putting together a schematic in Eagle with a view to making a PCB in due course:

BeebOPL.png

My next task is to see whether any improvement can be made to the audio stage. There seem to be two problems. First, there is a fair amount of background hiss and other noise. The difficulty here is I don't really know whether this is a problem with the design per se or it is just a reflection of the current Frankensteined breadboard arrangement.

The second problem is that when music is routed back into the Beeb via the 1MHz Bus, it is awfully quiet (and has even more noise and hiss). Again, there might be several reasons for the noise, not least that my Beeb's speaker really does have an awful lot of buzzing and hissing in any event. As for the music being quite, it does seem to be possible to play a fairly loud tone through the speaker. The problem may be caused by the fact that the OPL files I have found to work with are actually encoded at quite low levels and don't make full use of the headroom available from the chip.

This all has to be combined with the fact that I know pretty much next to nothing about amps, so I am not sure what I am likely to achieve.

Anyway, come what may, I do hope to have some kind of decent prototype board by the time of ABug South in Cambridge.

User avatar
lazarusr
Posts: 599
Joined: Thu Sep 10, 2015 8:56 pm
Location: London

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby lazarusr » Tue Jul 12, 2016 8:59 am

Here is the latest update.

I have revised the address decoding logic and managed to reduced the chip count by one. There may be a more efficient logic circuit in terms of number of gates, but I doubt I can reduce the chip count further.

BeebOPL.png

I have tried improving the analogue circuit. I have tried a different (supposedly more modern) op-amp and used the recommended circuit in the DAC's datasheet. But everything I did made matters worse. I have re-made the circuit on my breadboard using the shortest cable runs possible. The output into external powered speakers seems pretty good with only a little noise.

DS1Z_QuickPrint2.png

In terms of the 1MHz bus the music files I have found are still pretty quiet. I think this is just the way they have been coded because a single tone at max volume from the OPL chip when routed through the Beeb's speaker sounds quite a bit louder than a similar tone played with the Beeb's internal 76489. However, the 1MHz Bus Application Note does say that, to reach saturation, any audio input through the 1MHz bus connector should reach +/-3V RMS. However, as can be seen from the above trace, I am only reaching just over 3V P-P; so just over 1V RMS.

Part of the difficulty with the way audio sound when routed over the 1MHz bus seems to be because I have an awful lot of noise on the 1MHz Bus audio line.

DS1Z_QuickPrint3.png

Anyway, I think I have really gone as far as I can with this on a breadboard. I recently received a voucher for some free PCBs from PCBWay. So I have gone ahead and ordered some boards. :-D

User avatar
sydney
Posts: 1967
Joined: Wed May 18, 2005 9:09 am
Location: Newcastle upon Tyne

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby sydney » Tue Jul 12, 2016 11:08 am

Great work Robert! Looking forward to seeing (and hearing!) Your progress with this at the next ABug.

User avatar
lazarusr
Posts: 599
Joined: Thu Sep 10, 2015 8:56 pm
Location: London

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby lazarusr » Tue Jul 12, 2016 12:01 pm

sydney wrote:Great work Robert! Looking forward to seeing (and hearing!) Your progress with this at the next ABug.

Thanks. :D

Whilst I am waiting for the board to arrive, I am now turning my attention to software. Unfortunately, to use a technical term, this thing is a bitch to program. :evil:

For example, defining the note played on a channel requires programming two different registers. This involves setting the octave and something referred to as the 'F-number' (which appears to be the frequency multiplied by a correction factor of 1.31). The octave and the two most-significant bits of the F-number are in one register with the eight least-significant bits in another. The registers are arranged in the most baffling order, sometimes, they are in number order and sometimes they jump with a gap between offsets of &02 and &08. :?

Just trying to write a program to adjust the main functions of the chip is proving quite a headache.

EDIT: I have now discovered that the F-number is calculated by using the formula: Music Frequency * 2^(20 - Octave Number) / 49716. So that should be a doddle to code in assembler.

User avatar
tricky
Posts: 1816
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby tricky » Tue Jul 12, 2016 12:40 pm

So, pretty much the same calculation (but scaled) as the internal; chip!

User avatar
lazarusr
Posts: 599
Joined: Thu Sep 10, 2015 8:56 pm
Location: London

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby lazarusr » Tue Jul 12, 2016 1:02 pm

tricky wrote:So, pretty much the same calculation (but scaled) as the internal; chip!

My ignorance revealed :oops:

But I suppose that is encouraging.

User avatar
lazarusr
Posts: 599
Joined: Thu Sep 10, 2015 8:56 pm
Location: London

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby lazarusr » Tue Jul 12, 2016 1:23 pm

Actually, I am being exceptionally dense. Frequencies double as one goes up an octave. By having a factor that is expressed in diminishing powers of 2, the factor halves as one goes up an octave. So the end result is that the F-number for any particular note is the same in every octave. It is, in fact, a very sensible system indeed.

SarahWalker
Posts: 1038
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby SarahWalker » Tue Jul 12, 2016 4:47 pm

Interesting! I did consider a while ago doing something like this, but never got round to doing any hardware though. I did write a player for IMF files (as used in several PC shareware games). Would this be of any interest?

User avatar
lazarusr
Posts: 599
Joined: Thu Sep 10, 2015 8:56 pm
Location: London

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby lazarusr » Tue Jul 12, 2016 4:54 pm

SarahWalker wrote:I did write a player for IMF files (as used in several PC shareware games). Would this be of any interest?

Oh good grief, yes! If you have a look here you will see my hopeless attempt in Halifax to implement an IMF player in BASIC. The timing is all over the place. :oops:

I gather you are coming to Cambridge. I should have a proper working board by then and will be focussing on the software side of things. Your help would be greatly appreciated. \:D/

SarahWalker
Posts: 1038
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby SarahWalker » Tue Jul 12, 2016 7:53 pm

Okay, see attached. Player is IMFPLAY, source is in IMFSRC, rest of the files are tunes. *LOAD a tune to 1400, then *IMFPLAY and everything should work...
Attachments
imfplay.zip
(48.34 KiB) Downloaded 39 times

User avatar
lazarusr
Posts: 599
Joined: Thu Sep 10, 2015 8:56 pm
Location: London

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby lazarusr » Tue Jul 12, 2016 9:44 pm

SarahWalker wrote:Okay, see attached. Player is IMFPLAY, source is in IMFSRC, rest of the files are tunes. *LOAD a tune to 1400, then *IMFPLAY and everything should work...

Brilliant! =D>

As a result we now have this and this. :D

User avatar
sydney
Posts: 1967
Joined: Wed May 18, 2005 9:09 am
Location: Newcastle upon Tyne

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby sydney » Wed Jul 13, 2016 7:34 am

lazarusr wrote:
SarahWalker wrote:Okay, see attached. Player is IMFPLAY, source is in IMFSRC, rest of the files are tunes. *LOAD a tune to 1400, then *IMFPLAY and everything should work...

Brilliant! =D>

As a result we now have this and this. :D



=D> =D> =D> =D> =D>

User avatar
hoglet
Posts: 6364
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby hoglet » Wed Jul 13, 2016 8:52 am

lazarusr wrote:Brilliant! =D>

As a result we now have this and this. :D

Wow! That's come along way since that first squeak it made in Halifax!

What's the huge glossy speaker it's playing through?

There's a pretyy good Verilog implementation of the OPL chipset:
https://www.youtube.com/watch?v=i9vEKyJScYw
It might be fun to add this into BeebFPGA. Edit: It's far too big unfortunately :(

Dave

User avatar
lazarusr
Posts: 599
Joined: Thu Sep 10, 2015 8:56 pm
Location: London

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby lazarusr » Wed Jul 13, 2016 9:31 am

hoglet wrote:What's the huge glossy speaker it's playing through?

That's part of my home HiFi setup. They are B&W speakers. Bit of an overkill for the board, but sounds impressive. I wanted to directly connect my laptop to the output and record it natively. However, I have a Mac and, consequently, everything that should be straightforward is weird.

hoglet wrote:There's a pretyy good Verilog implementation of the OPL chipset:
https://www.youtube.com/watch?v=i9vEKyJScYw
It might be fun to add this into BeebFPGA. Edit: It's far too big unfortunately :(

That's implementing OPL3 (presumably a YMF262). That has twice the number of voices as the YM3812 and requires a stereo DAC. Presumably, there would be getting on for half the number of gates in implementing the YM3812.

User avatar
oss003
Posts: 2516
Joined: Tue Jul 14, 2009 11:57 am
Location: Netherlands
Contact:

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby oss003 » Wed Jul 13, 2016 4:19 pm

Nice tune for an Atomic IMF player ....... :lol: :lol:

https://youtu.be/nppO7MZPszo

The trick I use is Wouters Atom emulator. This emulator can access the I/O addresses off the PC. This way you can address the Soundblaster directly.

Greetings
Kees

User avatar
oss003
Posts: 2516
Joined: Tue Jul 14, 2009 11:57 am
Location: Netherlands
Contact:

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby oss003 » Wed Jul 13, 2016 7:09 pm

Hi guys,

I found an interesting site how to connect your Adlib/Soundblaster board to a parallel port.
The only disadvantage is that you need +12V, -12V, +5V and -5V and a 14,38 mHz crystal..... :?

http://www.raphnet.net/electronique/adlib/adlib_en.php

In the past I did some testing with my homemade ISA bus which mapped the PC I/O addresses &h0000-&h03FF to the Atom addresses #BC00-#BFFF. A serial-, modem- and ethernet board were working but I couldn't get the Soundblaster board working, probably because it needs the 14,38 mHz signal.

http://www.retrosoftware.co.uk/wiki/ind ... 12#ISA-BUS

Greetings
Kees

User avatar
lazarusr
Posts: 599
Joined: Thu Sep 10, 2015 8:56 pm
Location: London

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby lazarusr » Sun Jul 17, 2016 8:24 am

Thanks to the help of SarahWalker I now have a program which will convert any IMF file into a standalone executable. :D In the process, I have learnt quite a bit more about coding. Not least that, having coded solidly from 8am to 2am, I am probably not in the best condition to spot that I have typed a ";" instead of a ":". :oops:

I am now going to move on to look at the similar, but ever so slightly more complex, RAW and DRO files. The plan is to have that complete by Cambridge so that I can then focus on the real challenge of RAD files (for which I suspect I may need quite a bit of assistance). I really want to be able to handle this format. All the other formats are primarily for games music (although, it is possible and fairly straightforward (ish) to convert any format, including RAD, to DRO). However, RAD and related file formats were (and still are) popular amongst the demoscene crowd and their are lots of really impressive tracks in this format. (Sadly, a lot are in OPL3 which the YM3812 cannot support.)

The only other challenge is to win my war with the Chinese internet vendors and actually get hold of the DAC chip (as the one I am using is still the one I desoldered from an existing device). :twisted:

User avatar
lazarusr
Posts: 599
Joined: Thu Sep 10, 2015 8:56 pm
Location: London

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby lazarusr » Mon Jul 18, 2016 7:13 pm

Here is the fully populated prototype board hooked up to my Beeb. (You can listen to the audio output here.)

BeebOPL - 3.JPG
BeebOPL - 2.JPG
BeebOPL - 1.JPG

It's fair to say I am pretty pleased with the results. :D

User avatar
paulv
Posts: 3546
Joined: Tue Jan 25, 2011 6:37 pm
Location: Leicestershire
Contact:

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby paulv » Mon Jul 18, 2016 7:31 pm

=D> =D> =D>

So when are you going into production?

Paul

User avatar
oss003
Posts: 2516
Joined: Tue Jul 14, 2009 11:57 am
Location: Netherlands
Contact:

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby oss003 » Mon Jul 18, 2016 7:36 pm

Sounds great and the PCB looks very professional ...... =D> =D>
Great job!!!

Greetings
Kees

User avatar
lazarusr
Posts: 599
Joined: Thu Sep 10, 2015 8:56 pm
Location: London

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby lazarusr » Mon Jul 18, 2016 7:39 pm

paulv wrote:So when are you going into production?

The possibility of anyone else having one of these is, currently, very much at the mercy of Chinese internet DAC vendors. :evil:

User avatar
leenew
Posts: 3330
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby leenew » Mon Jul 18, 2016 7:59 pm

Wow!
That's cooool.
The audio quality is much better than expected :D =D>

Lee.

sbadger
Posts: 203
Joined: Mon Mar 25, 2013 1:12 pm
Location: Farnham, Surrey

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby sbadger » Tue Jul 19, 2016 9:15 am

again, excellect work from you Robert.
I dare day that needs some Monkey Island music to go with it.
A3020 | BBC B x2 | Electrn | Master | RPi x3
A600 | C64 "breadbox"| C64 C | XB360 | GB | GBC | GBA | GBASP | DS | 3DS XL & new | MD | MS
Atari 7600 | PS1-2-3-4 | PSP | Vita | SNES | GC | N64 | Wii & U | Switch | Jamma Cab | Sony PVMx2

User avatar
1024MAK
Posts: 6676
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby 1024MAK » Tue Jul 19, 2016 1:39 pm

Excellent, well done 8) =D> =D> =D>

If the specific DAC chip is hard to get, are there any suitable alternatives?

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

Zarchos
Posts: 2355
Joined: Sun May 19, 2013 8:19 am
Location: FRANCE

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby Zarchos » Tue Jul 19, 2016 2:02 pm

1024MAK wrote:Excellent, well done 8) =D> =D> =D>

If the specific DAC chip is hard to get, are there any suitable alternatives?

Mark


Buy second hand tested known-to-have-this-chip PC Soundblaster and compatable cards and desolder the chip ?
If that's the same DAC (YM3014B), and yes it should be according to what I can read after a Google search, a few hundreds millions must have been sold worldwide (1st generation of Soundblaster and I believe AdLib cards and all the compatable cards), I don't think it should be either hard to find or expensive to buy, most of the time you'll find them in lots from professionals (recycling companies).

User avatar
lazarusr
Posts: 599
Joined: Thu Sep 10, 2015 8:56 pm
Location: London

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby lazarusr » Tue Jul 19, 2016 2:32 pm

1024MAK wrote:If the specific DAC chip is hard to get, are there any suitable alternatives?

As you can imagine, I have done quite a bit of research into this. The YM3812 (the main synthesiser) and the YM3014B (the DAC) were very much designed and manufactured as a pair. I have never seen any design using the YM3812 using any other DAC. Equally, I have never seen the YM3014B used for anything other than to decode the output of the YM3812. Subsequent upgrades to the main chip required a different DAC (again, bespoke designed by Yamaha).

I did find a related chip (the YM3012) which is used for stereo applications. I think there may be some troubling differences (not just the presence of two channels), but it may be possible to get it to work. It would mean spinning a new board, apart from anything else.

Neither of these DACs appear comparable to regular off the shelf DACs.

Bizarrely, one of the eBay vendors describes the chip thus: "YM3014B YM3014 Cyclone II FPGA 8K FBGA-256 DIP-8". I am utterly baffled as to how there can be a connection between an obscure 1980s DAC and a modern 21st Century FPGA.

The position is currently as follows:

  • £itt£e Diode can supply the YM3014B, but only a £itt£e Diode LOL prices.
  • There is a UK eBay vendor who can supply the YM3012, which may or may not work with a redesign. Even then, it is about 10 times what I could pay for the correct chip from a Chinese vendor
  • I ordered five YM3014Bs for next to nothing from a Chinese vendor on eBay. They never turned up and I got a refund
  • I ordered five YM3014Bs for next to nothing from another Chinese vendor on eBay. They have not arrived yet. They may still arrive, but it is getting to the point where I doubt they will.
  • I have five of the YM3812s that I ordered from yet another Chinese vendor on eBay. (This one didn't do the YM3014B.) I want to keep at least 2 of these for myself. Unless there are only three people who are interested in this board (more than this have said they are already), I am going to have to find some more of these chips too. I am not confident that these are guaranteed to arrive if I order them in the same way as before.
  • I have delved into the murky (and somewhat bizarre) world of AlliExpress. If the information they display is to be believed, there are tens of thousands of these chips stockpiled in China.
  • I have ordered 20 of each of the two chips from two separate vendors. Again, paying next to nothing. Given that the base cost was even cheaper than eBay, I have paid extra for (again, two different kinds of) tracked shipping.
  • Unfortunately, AliExpress seem to take slow delivery from Chine to hitherto uncharted depths.
  • Also, these are economy tracked services. So the package is tracked to the airport in China. It then will disappear until it is received by Royal Mail in London. Unlike expensive services, like DHL, it doesn't track through airport clearance, the very place where it is most likely to go missing.

It is all very frustrating because ultimately, this project should work out very cheap indeed. If everything that is still outstanding turns up, I should be able to pass on the Yamaha chips to others at about £1.70 per pair. All the other components are very mundane. Many people will probably have quite of few of them lying around anyway.

In any event, I think patience is currently required. I am sure I will get these chips at a sensible price and without having to find and desolder other boards.

User avatar
1024MAK
Posts: 6676
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby 1024MAK » Tue Jul 19, 2016 3:20 pm

Thanks for that :D

If you do get your hands on some more YM3812 and YM3014B chips, I would like one set and a board.

If you are going to do another revision of the board, you can use a 74HCT688 8-bit magnitude comparator to do the A1 to A7 address decoding reducing the chip count. 74HC688/74HCT688 data sheet.

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
paulv
Posts: 3546
Joined: Tue Jan 25, 2011 6:37 pm
Location: Leicestershire
Contact:

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby paulv » Tue Jul 19, 2016 4:52 pm

so I just started looking at the Y3014 and found this...

Image

Pretty sure that says BBC in the bottom left quardant.... It was clearly written in the stars!

On a more serious note, is it just that the suppliers are all charging LOL prices as it looks like stocks of them are reasonably high amongst vendors...

https://www.digchip.com/datasheets/quote.php?action=search&pn=Y3014

Paul

User avatar
lazarusr
Posts: 599
Joined: Thu Sep 10, 2015 8:56 pm
Location: London

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby lazarusr » Tue Jul 19, 2016 5:58 pm

paulv wrote:"Pretty sure that says BBC in the bottom left quardantl
:lol:

paulv wrote:On a more serious note, is it just that the suppliers are all charging LOL prices as it looks like stocks of them are reasonably high amongst vendors...

The only supplier I can identify as being in the UK who can supply them is £itt£e Diode. With VAT and shipping, buying ten of them would work out at £14.12 each. :!:

There is no doubt there are lots of vendors with them in China with prices staring as low as 40p each. The problem is actually getting them delivered in the UK as opposed to their disappearing into some black hole between Shenzhen and Heathrow. At present, I have orders outstanding from three suppliers. We will just have to see what turns up.

BTW, I am not going down the 'ask for quotes' route. I did that once before and it ended up resembling the plot of Fatal Attraction. :shock:

User avatar
paulv
Posts: 3546
Joined: Tue Jan 25, 2011 6:37 pm
Location: Leicestershire
Contact:

Re: BeebOPL: an FM Synthesiser for the BBC Micro

Postby paulv » Tue Jul 19, 2016 6:17 pm

OK, that's cool. Yes, the quote thing is a bit of a nightmare. I did it once for VGA oscillators and eventually found a uk manufacturer that could make new for not a lot less than NOS from China so I went for the new.

Definitely interested in a board though if supplies become more abundant.

Paul


Return to “hardware”

Who is online

Users browsing this forum: BigEd, ssgoodwin, vanekp and 8 guests