Music 5000 in B-Em

want to talk about MESS/model b/beebem/b-em/electrem/elkulator? do it here!
User avatar
fordp
Posts: 965
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England
Contact:

Re: Music 5000 in B-Em

Post by fordp » Fri Dec 01, 2017 7:52 am

I would be up for adding Midi in on BeebFPGA does anybody have a Circuit Diagram?
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

Coeus
Posts: 1118
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Music 5000 in B-Em

Post by Coeus » Fri Dec 01, 2017 7:23 pm

fordp wrote:I would be up for adding Midi in on BeebFPGA does anybody have a Circuit Diagram?
Does that mean you have some documentation as to how a MIDI port appears as viewed from the BBC?

User avatar
fordp
Posts: 965
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England
Contact:

Re: Music 5000 in B-Em

Post by fordp » Fri Dec 01, 2017 7:43 pm

Sorry I have no information about this particular Midi Interface. I know a lot about Midi and I have a real BBC Midi Interface which I have owned since the 80's. I also have tons of midi gear in my loft.
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

User avatar
fordp
Posts: 965
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England
Contact:

Re: Music 5000 in B-Em

Post by fordp » Fri Dec 01, 2017 7:47 pm

Looks like emulating the 4000 keyboard (https://www.retro-kit.co.uk/page.cfm/co ... -Keyboard/) from Midi in messages would be a better option.

P.S.
Here is the circuit diagram : http://www.colinfraser.com/m5000/m2000sch.pdf
Last edited by fordp on Fri Dec 01, 2017 8:20 pm, edited 1 time in total.
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

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

Re: Music 5000 in B-Em

Post by paulv » Fri Dec 01, 2017 8:05 pm

pixelblip wrote:Hi there.
I was wondering do you think it's possible or within the realms of possibility to add midi input to the emulation of Music 5000? I guess you would need the source code?

Music 4000s are hard to come by now. It would be great to see some new music coming out and I'd love to have a bash but the thought of programming a tune in Ample again is a bit much! :) It would be great to be able to hook up a cheap midi keyboard to Beeb em and keep Music 5000 alive for years to come. Eventually the hardware will fail.

Making music with the keyboard was so much easier.

I've got a feeling this isn't so easy. Maybe someone who designed it could chip in please?
What is interesting is that it supported midi with Music 2000. So midi is there somewhere.
I've got a letter on my site which basically says the Hybrid Music System can only be used as a MIDI controller and although the 2000 has MIDI in, using it to control the 5000 (and 3000) as slave devices wasn't supported.

https://www.retro-kit.co.uk/user/custom ... -Nov92.pdf

Paul

User avatar
pixelblip
Posts: 881
Joined: Wed Feb 04, 2015 7:19 pm
Contact:

Re: Music 5000 in B-Em

Post by pixelblip » Fri Dec 01, 2017 8:14 pm

Wow you have a scanned letter from back then!

Well thanks for trying to help everyone. I think there's a lot of life yet in Music 5000 ......it's just the fly in the ointment.

It's amazing everyone got Music 5000 working in the emulators.

Coeus
Posts: 1118
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Music 5000 in B-Em

Post by Coeus » Fri Dec 01, 2017 8:16 pm

fordp wrote:Looks like emulating the 4000 keyboard (https://www.retro-kit.co.uk/page.cfm/co ... -Keyboard/) from Midi in messages would be a better option.
Ok, so having had a very quick look at that the schematic at https://www.retro-kit.co.uk/user/custom ... ematic.pdf am I right in thinking this is actually just like a non-musical keyboard in the sense that it has key switches arranged in a matrix with rows and columns with one being driven by a counter and the other read by a parallel port, in this case the user port?

User avatar
fordp
Posts: 965
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England
Contact:

Re: Music 5000 in B-Em

Post by fordp » Fri Dec 01, 2017 8:25 pm

We could make a Midi Keyboard emulate that :D

(https://gist.github.com/yoggy/1485181)
Last edited by fordp on Fri Dec 01, 2017 8:41 pm, edited 1 time in total.
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

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

Re: Music 5000 in B-Em

Post by paulv » Fri Dec 01, 2017 8:35 pm

fordp wrote:We could make a Midi Keyboard emulate that :D
Definitely the way to go I think. Trying to get MIDI in working would require a lot of work to build a ROM to monitor the 1MHz bus for MIDI in traffic and convert it to signals to control the 5000. There'd be a lot of work to deal with voice selection too.

Writing a MIDI to user port emulator/converter won't be as flexible as a true slave implementation but it'll at least open up music input options for those that don't have a 4000.

Paul

Coeus
Posts: 1118
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Music 5000 in B-Em

Post by Coeus » Fri Dec 01, 2017 8:36 pm

fordp wrote:We could make a Midi Keyboard emulate that :D
Indeed, so it is just a case of working out the exact details of how it is scanned. So the 74HC164 is a serial in, parallel out shift register with CB1 from the user port connected to its clock input and CB2 connected to one of the data inputs. So, at a guess, this keyboard is scanned by shifting a single 1 (or 0) into that shift register and clocking it through while reading the PB lines of the user port. This scans through the "blocks" as this schematic calls them.

One possibility would be to see what the software does when you try to get it to use the keyboard.

So from a emulator module POV what would required would be to maintain the sate of each key on the virtual keyboard, setting the key as up/down in response to the MIDI messages, and then respond to the keyboard scanning with the correct status for those keys.

There will be a bit of complexity, though, in getting MIDI events from the OS.

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

Re: Music 5000 in B-Em

Post by hoglet » Fri Dec 01, 2017 8:42 pm

You might want to chat with Simon Inns:
I'm actually working on a project at the moment that allows the use of a standard MIDI keyboard in place of the M4000. Basically it is a microcontroller based board that accepts MIDI IN via a 5 pin DIN and then uses a MT8808 crosspoint switch IC to emulate the M4000 towards the BBC's userport (The M4000 is basically a 8x8 scanned matrix keyboard).
http://www.stardot.org.uk/forums/viewto ... 41#p172141

He's talking, of course, about doing it for real hardware, rather than B-Em. But still very interesting (esp. for BeebFPGA)

Dave

Coeus
Posts: 1118
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Music 5000 in B-Em

Post by Coeus » Fri Dec 01, 2017 10:59 pm

I am not completely sure which software modules are which but assuming the Ample module M4 is for the M4000 (as there is an M2 and an M5 module too), upon loading this module things go awry. Ample stops responding to the (B-Em emulated computer) keyboard and this is not even fixed by a Break.

Looking a bit closer it looks like Ample is writing &58 into the user Via ACR and then writing &7F to the SR. If I have read the documentation correctly this should have the effect of shifting this out under control of the 1Mhz clock, i.e. with CB1 acting as an output clock at half the 1Mhz clock rate and CB2 carrying the data. It then looks as if the module gets stuck polling the IFR for the "8 bit shifted" interrupt which never occurs because B-Em's VIA emulation doesn't seem to do anything with the shift register.

Apart from B-Em not emulating the shift register logic this does seem to make sense in that, looking at the schematic for a compatible keyboard, it looks like this would clock the "walking zero" from the VIA's shift register through the 74HC164 shift register in the keyboard to scan through the blocks.

Coeus
Posts: 1118
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Music 5000 in B-Em

Post by Coeus » Fri Dec 01, 2017 11:36 pm

So emulating the shift register just enough to generate the flag in the IFR after counting clock cycles stops the crash upon loading M.M4

Coeus
Posts: 1118
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Music 5000 in B-Em

Post by Coeus » Sat Dec 02, 2017 2:03 am

Ok, so I have pushed a branch sf/m4000 to the Stardot B-Em repository that have the via emulation emulating the particular mode the M4 module seems to be using and also includes an almost empty m4000 module which defines two functions: m4000_shift which receives the CB2 values being shifted out of the 6522 shift register into the shift register in the emulated M4000 keyboard, i.e. to set which row (block) and m4000_read which is called when user via port B is read and needs to return the columns for that row, i.e. the keys pressed in that block.

I'll see what more I can do later.

Coeus
Posts: 1118
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Music 5000 in B-Em

Post by Coeus » Sat Dec 02, 2017 2:19 am

Ok, I had another idea for a proof of concept - the latest commit to the sf/m4000 branch allows the keys on the numeric keypad to pay 8 notes in one block. All that's needed now is to interface to the OS MIDI layer which will be a bit OS-specific, I suspect.

crj
Posts: 835
Joined: Thu May 02, 2013 4:58 pm
Contact:

Re: Music 5000 in B-Em

Post by crj » Sat Dec 02, 2017 4:07 am

Back in the day, I took Ample apart.

Unless the relevant floppies have bitrotted, I know how modules interface to the Nucleus, etc. I wrote a utility to turn an Ample program into a module and how to embed 6502 machine code in Ample words.

While emulating a Music 4000 does look like the path of least resistance, writing a module to take input from a MIDI port isn't out of the question. I wonder how close Hybrid Technology ever got to doing it for the M2, and whether there were any obsctacles I'm not aware of.

User avatar
pixelblip
Posts: 881
Joined: Wed Feb 04, 2015 7:19 pm
Contact:

Re: Music 5000 in B-Em

Post by pixelblip » Sat Dec 02, 2017 4:46 am

Thank you every one for being so helpful......fingers crossed you can crack it together.

User avatar
fordp
Posts: 965
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England
Contact:

Re: Music 5000 in B-Em

Post by fordp » Sat Dec 02, 2017 8:35 am

Coeus wrote: All that's needed now is to interface to the OS MIDI layer which will be a bit OS-specific, I suspect.
(https://gist.github.com/yoggy/1485181)
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

Coeus
Posts: 1118
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Music 5000 in B-Em

Post by Coeus » Sat Dec 02, 2017 9:09 am

crj wrote:...While emulating a Music 4000 does look like the path of least resistance, writing a module to take input from a MIDI port isn't out of the question. I wonder how close Hybrid Technology ever got to doing it for the M2, and whether there were any obsctacles I'm not aware of.
There is not reason we can't do both. In the filing system space we have 8271/1770 emulation to enable the original filing system code to run unmodified, complete with sound effects etc., and we have VDFS which works at a higher level and provides access to the host files as files.

On that basis, as soon as get time, I'll continue with the M4000 but the module idea is still interesting and, once we have B-Em talking to its OS's MIDI drivers, some of that can almost certainly be re-used to talk to an AMPLE module. Any thoughts on how the interface between the module and the emulator would work? A virtual port from which MIDI events can be read and maybe an interrupt to signal when one is available? Or did the M2000 (is that the MIDI out interface?) have MIDI in at the hardware level, just no software support?

Coeus
Posts: 1118
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Music 5000 in B-Em

Post by Coeus » Sat Dec 02, 2017 9:13 am

That looks interesting. I did also look to see if Allegro 4 provides any MIDI capability, which it does but then says it only works on DOS and Windows so I also started to look at ALSA on Linux which doesn't look too hard either.

What I can't do, though, is test this on Windows as I don't have any Windows machines with MIDI hardware.. I have a Virtualbox VM but I don't think that does MIDI pass-through, none of the laptops have MIDI interfaces and the only keyboard I have with a MIDI out is real MIDI, not MIDI over USB.

It might be better if I provide note_on and note_off functions that manipulate the emulated key matrix and someone else does the Windows-specific MIDI implementation.

User avatar
fordp
Posts: 965
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England
Contact:

Re: Music 5000 in B-Em

Post by fordp » Sat Dec 02, 2017 10:24 am

I ordered a USB Midi Interface from Ali Express last night for a less that $3. It will be easier than digging out my 20 year old sound blaster midi interface.
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

User avatar
pixelblip
Posts: 881
Joined: Wed Feb 04, 2015 7:19 pm
Contact:

Re: Music 5000 in B-Em

Post by pixelblip » Sat Dec 02, 2017 2:27 pm

Thanks for your efforts everyone!
I hope I can re-pay you with some tunes.

K.D.
Posts: 4
Joined: Fri Jun 08, 2012 5:08 pm
Contact:

Re: Music 5000 in B-Em

Post by K.D. » Sat Dec 02, 2017 4:33 pm

Coeus wrote:
crj wrote:...While emulating a Music 4000 does look like the path of least resistance, writing a module to take input from a MIDI port isn't out of the question. I wonder how close Hybrid Technology ever got to doing it for the M2, and whether there were any obsctacles I'm not aware of.
There is not reason we can't do both. In the filing system space we have 8271/1770 emulation to enable the original filing system code to run unmodified, complete with sound effects etc., and we have VDFS which works at a higher level and provides access to the host files as files.

On that basis, as soon as get time, I'll continue with the M4000 but the module idea is still interesting and, once we have B-Em talking to its OS's MIDI drivers, some of that can almost certainly be re-used to talk to an AMPLE module. Any thoughts on how the interface between the module and the emulator would work? A virtual port from which MIDI events can be read and maybe an interrupt to signal when one is available? Or did the M2000 (is that the MIDI out interface?) have MIDI in at the hardware level, just no software support?
I have a Music 2000 interface and can confirm that it has 3 MIDI OUT ports and 1 MIDI IN port at the rear. However, there is no support for the MIDI IN port in the software.

User avatar
fordp
Posts: 965
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England
Contact:

Re: Music 5000 in B-Em

Post by fordp » Sat Dec 02, 2017 9:01 pm

Coeus wrote:
That looks interesting. I did also look to see if Allegro 4 provides any MIDI capability, which it does but then says it only works on DOS and Windows so I also started to look at ALSA on Linux which doesn't look too hard either.

What I can't do, though, is test this on Windows as I don't have any Windows machines with MIDI hardware.. I have a Virtualbox VM but I don't think that does MIDI pass-through, none of the laptops have MIDI interfaces and the only keyboard I have with a MIDI out is real MIDI, not MIDI over USB.

It might be better if I provide note_on and note_off functions that manipulate the emulated key matrix and someone else does the Windows-specific MIDI implementation.
https://ccrma.stanford.edu/~craig/artic ... io/eecho.c
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

crj
Posts: 835
Joined: Thu May 02, 2013 4:58 pm
Contact:

Re: Music 5000 in B-Em

Post by crj » Sun Dec 03, 2017 12:29 am

Coeus wrote:Any thoughts on how the interface between the module and the emulator would work? A virtual port from which MIDI events can be read and maybe an interrupt to signal when one is available?
My memory on this aspect of the system is really hazy. In essence, there's just a hook for dropping in note events at an early enough stage that they can be parsed by the staff/text editors as well as coming out the sound action path. After all these years I can't even remember if it's interrupt-driven or polled.

After all the scare stories, I'm going to replace the capacitors before I turn that system on again, otherwise I'd just look and see. Maybe in a few days'/weeks' time.

Coeus
Posts: 1118
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Music 5000 in B-Em

Post by Coeus » Sun Dec 03, 2017 1:03 am

Here is B-Em, emulating a Music 5000+Music 4000 driven my MIDI. Ok, I wasn't actually playing a keyboard - it is being driven by external (to B-Em) MIDI sequencer but it works!
Attachments
ding-dong-m5000.mp3
(547.5 KiB) Downloaded 27 times

Coeus
Posts: 1118
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Music 5000 in B-Em

Post by Coeus » Sun Dec 03, 2017 1:30 am

So the previous recording was made on the version of B-Em I have just pushed to the sf/m4000 branch on https://github.com/stardot/b-em.

This was using a JACK driver on Linux. I have also implemented an ALSA sequencer driver which I thought should work but for some reason never seems to receive any events. There is a space to plug in a Windows driver too.

I have fixed a bug in the 6522 shift register emulation and the code behind the music4000_note_on and music4000_note_off functions applies the right offset to key the keys to sound the correct note names in the correct octave. If my MIDI cable turns up I may have a go at an ALSA raw driver (instead of the sequencer one).

Coeus
Posts: 1118
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: Music 5000 in B-Em

Post by Coeus » Sun Dec 03, 2017 1:32 am

crj wrote:
Coeus wrote:Any thoughts on how the interface between the module and the emulator would work? A virtual port from which MIDI events can be read and maybe an interrupt to signal when one is available?
My memory on this aspect of the system is really hazy. In essence, there's just a hook for dropping in note events at an early enough stage that they can be parsed by the staff/text editors as well as coming out the sound action path. After all these years I can't even remember if it's interrupt-driven or polled.
Ok, I was just thinking about what could be the boundary between one message and the next as they are variable length. As the M2000 has a MIDI it it might be an idea to see if anyone knows how that would be seen by the BBC when receiving MIDI events as that would mean the new module would work with real hardware too.

User avatar
pixelblip
Posts: 881
Joined: Wed Feb 04, 2015 7:19 pm
Contact:

Re: Music 5000 in B-Em

Post by pixelblip » Sun Dec 03, 2017 7:25 am

You lot are amazing.......working this out.......well done so far......thank you.....

User avatar
fordp
Posts: 965
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England
Contact:

Re: Music 5000 in B-Em

Post by fordp » Sun Dec 03, 2017 8:53 am

Coeus wrote:
crj wrote:
Coeus wrote:Any thoughts on how the interface between the module and the emulator would work? A virtual port from which MIDI events can be read and maybe an interrupt to signal when one is available?
My memory on this aspect of the system is really hazy. In essence, there's just a hook for dropping in note events at an early enough stage that they can be parsed by the staff/text editors as well as coming out the sound action path. After all these years I can't even remember if it's interrupt-driven or polled.
Ok, I was just thinking about what could be the boundary between one message and the next as they are variable length. As the M2000 has a MIDI it it might be an idea to see if anyone knows how that would be seen by the BBC when receiving MIDI events as that would mean the new module would work with real hardware too.
Midi is very simple and has a note on message followed (hopefully) by a note off message when the key is released. These messages are three bytes long.
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

Post Reply