Music 5000 in B-Em

want to talk about MESS/model b/beebem/b-em/electrem/elkulator? do it here!
Coeus
Posts: 460
Joined: Mon Jul 25, 2016 11:05 am

Re: Music 5000 in B-Em

Postby Coeus » Sun Dec 03, 2017 12:01 pm

fordp wrote: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.


Yes, they are but a real MIDI keyboard or external sequencer can send other messages too. It looks like finding the start of the message is easy enough as the first byte, the "status" byte has bit 7 set and the data bytes have it clear.

Thinking about M2000 emulation, my guess is that to the 6502 it will appear as some kind serial controller as, on the wire, MIDI is a serial protocol.

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

Re: Music 5000 in B-Em

Postby fordp » Sun Dec 03, 2017 12:39 pm

Coeus wrote:
fordp wrote: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.


Yes, they are but a real MIDI keyboard or external sequencer can send other messages too. It looks like finding the start of the message is easy enough as the first byte, the "status" byte has bit 7 set and the data bytes have it clear.

Thinking about M2000 emulation, my guess is that to the 6502 it will appear as some kind serial controller as, on the wire, MIDI is a serial protocol.

Indeed there are other message in MIdi but we are just interested in Note On and Note Off and we should discard the rest. As you say the first byte of a message has the MSB set which makes life a lot easier. All the Midi interfaces I have seen have been based on the same MC6850 Uart. This is a very simple device that does not even have a baud rate generator. I will hopefully get some time over the Christmas break to play with Midi. My Casio CZ101 is sitting next to me waiting to be switched on ;)
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

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

Re: Music 5000 in B-Em

Postby Coeus » Mon Dec 04, 2017 12:14 pm

fordp wrote:Indeed there are other message in MIdi but we are just interested in Note On and Note Off and we should discard the rest. As you say the first byte of a message has the MSB set which makes life a lot easier. All the Midi interfaces I have seen have been based on the same MC6850 Uart. This is a very simple device that does not even have a baud rate generator. I will hopefully get some time over the Christmas break to play with Midi. My Casio CZ101 is sitting next to me waiting to be switched on ;)


It turns out our speculating is correct as I have found the M2000 documented. On the Retro-Kit Hybrid Music 2000 Interface page is a link to Hybrid 2000 programming info which confirms use of the 6850 - three of them complete with 1Hhz bus addresses. It should be really easy to emulate these in B-Em. So, crj, if you fancy doing a MIDI-in module for AMPLE, writing it to work with the real M2000 and then have B-Em emulate that means the same module could be used both ways.

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

Re: Music 5000 in B-Em

Postby Coeus » Mon Dec 04, 2017 8:46 pm

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


Thanks. Are you running B-Em on Linux or are you awaiting the Windows MIDI implementation for it?

Anyway the latest commit finishes, I think, the Linux MIDI implementation in that it can now do all three: JACK, ALSA Sequencer and ALSA Raw MIDI. It is also possible to turn these on/off a run-time via a [midi] section of the b-em.cfg file. The defaults built-in correspond to:

[midi]
jack_enabled=0
alsa_seq_enabled=1
alsa_raw_enabled=1
alsa_raw_device=default

The last of these lets you choose another MIDI interface rather than the first hardware port it can find (which is what "default" does). With the ALSA Sequencer or JACK implementations you'd normally connect B-Em to another application with a suitable patchbay application or with the controls built into the other application (as B-Em does have a GUI for managing MID connections).

I will now check that what I have so far still compiles on Windows.

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

Re: Music 5000 in B-Em

Postby pixelblip » Mon Dec 04, 2017 9:19 pm

Gosh you all are making so much progress :)

At the moment I have a windows pc and use OS X (on a very old white 2006 mac _ I love old stuff people throw out) - but I switch between computers whatever takes my fancy! I also have a Raspberry Pi 3 as well running Raspbian....I wonder if that would be fast enough.....hmmmm
I messed around with Linux for quite a while.....Alsa and jack.......and wineasio.....I've got an Ubuntu box here next to all my other old pcs!

I didn't really think my post would bear much fruit but there we are.....it's great to read you all working it out together.
Like I said - I still think Music 5000 has some interesting life in it yet.....like I have found with the Mode 2 pictures, second time around after 30 years it's exciting to approach it again and try push it in new directions.....oh and Fordp - your Casio CZ101....I have fond memories of owning that little synth :)

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

Re: Music 5000 in B-Em

Postby Coeus » Mon Dec 04, 2017 11:58 pm

pixelblip wrote:Gosh you all are making so much progress :)


I have implemented MIDI on Windows now and there is a release on GitHub. As I don't, at least at the moment, have any MIDI hardware on any Windows machines I have not been able to do any testing on it, other than that it compiles and starts and complains about the lack of MIDI interfaces. You're welcome to try it, though, and report back.

I am hoping to get a USB MIDI interface in a week or two (I think it must be coming from HK).

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

Re: Music 5000 in B-Em

Postby fordp » Tue Dec 05, 2017 8:17 am

I just looked at the code and it looks good to me. I am also waiting on my interface. I will try and give it a whirl when it arrives. I have no idea how to use ample / M500/M5000 however.
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

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

Re: Music 5000 in B-Em

Postby pixelblip » Tue Dec 05, 2017 9:23 am

Oh I can't wait to get home to try this. Thanks so much everyone :D

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

Re: Music 5000 in B-Em

Postby fordp » Tue Dec 05, 2017 9:47 am

Coeus will be a much better software engineer than me if he can get some code working first time without any way of testing it ;)
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

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

Re: Music 5000 in B-Em

Postby pixelblip » Tue Dec 05, 2017 9:52 am

I know of a way of testing it here without any midi gear...........a loopback midi driver should do the job .......I'll have a go when I get time today.

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

Re: Music 5000 in B-Em

Postby pixelblip » Tue Dec 05, 2017 8:05 pm

Oh wow OMG just heard 'Simpleins' coming out from the keyboard! Midi works! Well done!!!!!! =D> =D> =D> =D>

It's the Eureka moment I never thought would happen!

It is like getting into a time machine and suddenly there I am in 1987 with my state of the art setup! :lol:

To me, in my little corner of the world - you are all *Very Clever* to get this working. My hats off to you all! - and *thank you* :D
Last edited by pixelblip on Tue Dec 05, 2017 8:56 pm, edited 1 time in total.

User avatar
danielj
Posts: 5334
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester

Re: Music 5000 in B-Em

Postby danielj » Tue Dec 05, 2017 8:31 pm

If your music's anything like your artwork, I'm very excited :D

d.

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

Re: Music 5000 in B-Em

Postby pixelblip » Tue Dec 05, 2017 9:27 pm

Thanks Daniel! You can be sure I will try my best. :D

I am really rusty on it but to hear some sounds like "Wah" is very nostalgic! I am slowly learning my way around again after all this time.

To everyone who wants to try it out.......you need to take off Write Protection on your Music 5000 ssd.

It's ace people also preserved all the manuals for this system. Thank you whoever did that!

There is some latency with the sound when playing keys but that is to be expected.....I will see if I can do a tune with it......you can always play notes into Notepad on the keyboard and then edit later.

I just wonder how on earth you all got this working..........

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

Re: Music 5000 in B-Em

Postby pixelblip » Wed Dec 06, 2017 10:32 am

I will try to compile the latest Beeb em tonight and see what the latency is like with Alsa and Jack (it should be better)..........to be honest it's ok to use but if it can be improved a bit that would be nice....I've got a little netbook that has Ubuntu on it which will be perfect

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

Re: Music 5000 in B-Em

Postby Coeus » Wed Dec 06, 2017 9:12 pm

pixelblip wrote:I will try to compile the latest Beeb em tonight and see what the latency is like with Alsa and Jack (it should be better)..........to be honest it's ok to use but if it can be improved a bit that would be nice....I've got a little netbook that has Ubuntu on it which will be perfect


I am trying to work out where this latency is. Here is a screenshot of a MIDI file imported into ardour where ardour has then fed MIDI to B-Em running AMPLE and the recorded the resulting audio on another track.

Screenshot from 2017-12-06 21-03-40.png
Ardour screenshot.


The yellow bars on the piano roll display of the red track are when the note is supposed to sound. The audio is on the blue track. And it sounds like the attached MP3 which has ardour's built-in synth panned left, and AMPLE on B-Em panned right.
Attachments
M4000 Test.mp3
Sleigh Bells Ardour/AMPLE
(1.56 MiB) Downloaded 6 times

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

Re: Music 5000 in B-Em

Postby Coeus » Wed Dec 06, 2017 10:24 pm

I have pushed a commit to the sf/m4000 branch that enables MIDI running status on the ASLA RAW midi driver (Linux).

I have also got to the bottom where the latency is coming from. It's actually in the B-Em sound code after the samples have been generated by the emulated Music 5000 as this accumulates 3,000 samples before handing the buffer off to OpenAL which then sends them to the host's sound system. As the Music 5000's sample rate is 46875Hz that is 3,000/46875 = 64ms. I think this is also multiplied by the number of buffers so that then becomes 256ms.

I have tried reducing the buffer size and there does seem to be a minium under which the sound breaks up so it seems OpenAl + the sound card drivers have a minimum latency but I tried reducing it from 3000 to 750 and it makes a noticable difference. Visually:
Screenshot from 2017-12-06 23-04-11.png
Ardour Screenshot - Smaller Buffers

So here the bottom audio track with the yellow waveform is with the buffer size set to 750. The red line (the "playhead") is lined up with the start of the first note in this audio and shows that it is slightly delayed from the start of the note in the MIDI track, the piano-roll track with the keyboard to the left, but still a lot earlier than in the audio track above which is when B-Em's Music 5000 buffer size is set to 3000. Once again I attach an MP3 for what this sounds like, same arrangement with B-Em/AMPLE on the right channel.

I am not sure if you might get different results on different systems so I might just make these tunable via the config file.
Attachments
M4000 Test-buf750.mp3
(1.54 MiB) Downloaded 4 times

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

Re: Music 5000 in B-Em

Postby pixelblip » Thu Dec 07, 2017 9:16 am

Wow Coeus you are very thorough indeed.......really amazing. Thanks so much for all this effort.
I will try the Linux commit later....
Last edited by pixelblip on Thu Dec 07, 2017 12:19 pm, edited 2 times in total.

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

Re: Music 5000 in B-Em

Postby pixelblip » Thu Dec 07, 2017 11:52 am

I just re-read your post again ....thank you so much for getting that latency down. It will be fine just doing that......

I am so excited to start using this again after years and let's hope we can get some more M5000 musos on board!

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

Re: Music 5000 in B-Em

Postby fordp » Thu Dec 07, 2017 1:19 pm

How does the latency compare to a pro midi synth?
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

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

Re: Music 5000 in B-Em

Postby Coeus » Thu Dec 07, 2017 1:29 pm

pixelblip wrote:I downloaded the source file from your earlier link and installed the libaries (like Allegro and Zlip) but when I ran the instructions to compile ( on the git hub instructions ) it said can't find the folder ( when you run ./configure make && make ./b-em )................sorry I might have been doing this all wrong as I very rarely compile!


I have just pushed another commit to that branch to include the reduced buffer size as this was previously just on my local copy.

When cloned from git, the source directory won't have the configure script - you need to run ./autogen.sh first to create it.

If you want to experiment with different buffer sizes the value to edit is BUFLEN_M5 towards the top of the soundopenal.h file, then just 'make' to re-compile, then test it.

I did look at making the buffer size configurable at run time, and I think it is still possible, but there are too many places that assume it is set at compile time for it to be a "five minute job" so it will have to wait until I have more time.

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

Re: Music 5000 in B-Em

Postby pixelblip » Thu Dec 07, 2017 4:35 pm

Thank you so much Coeus
Fordp: with the lower latency it would be comparable to a hardware instrument for sure.

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

Re: Music 5000 in B-Em

Postby crj » Thu Dec 07, 2017 7:02 pm

fordp wrote:How does the latency compare to a pro midi synth?

Synths will vary, and I can't speak specifically to the issue of MIDI, but back when I was helping to develop realtime pro audio kit, our target was around 5ms from the user touching the control surface to audible result.

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

Re: Music 5000 in B-Em

Postby fordp » Thu Dec 07, 2017 9:38 pm

Thanks.

Each Midi byte take 320us so 3 bytes is 960us of latency as a minimum. This is for Midi from a keyboard over a traditional midi cable.
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

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

Re: Music 5000 in B-Em

Postby pixelblip » Thu Dec 07, 2017 9:50 pm

Hi Coeus
Excuse the newb question.....
When I try to compile the software running the command below it says

/autogen.sh && ./configure && make
./autogen.sh: 17: ./autogen.sh: aclocal: not found
aclocal failed


I have installed the libraries to my knowledge.
Am I missing something really basic here? Sorry to ask this ......I just got my Ubuntu box up and ready so thought I'd give it a go this weekend :)
Thank you

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

Re: Music 5000 in B-Em

Postby pixelblip » Thu Dec 07, 2017 9:53 pm

Ahh I think it's because I didn't install automake

sudo apt-get install automake

Linux can be a challenge at times but that's what google is for eh

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

Re: Music 5000 in B-Em

Postby pixelblip » Thu Dec 07, 2017 10:10 pm

Sadly I can't compile it in Linux - it's a bit beyond me ( I installed all the libraries to my knowledge ) - I get this at the end
/usr/bin/ld: cannot find -lasound
collect2: error: ld returned 1 exit status
Makefile:551: recipe for target 'b-em' failed
make[1]: *** [b-em] Error 1
make[1]: Leaving directory '/home/m/Documents/b/src'
Makefile:353: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

If there's any chance sometime you could post a binary it would be most appreciated ( sorry if it's time consuming don't worry ) - it's just I really struggle at these sort of error messages. I'm surprised :lol: I got as far as I did!

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

Re: Music 5000 in B-Em

Postby Coeus » Thu Dec 07, 2017 11:16 pm

pixelblip wrote:If there's any chance sometime you could post a binary it would be most appreciated ( sorry if it's time consuming don't worry ) - it's just I really struggle at these sort of error messages. I'm surprised :lol: I got as far as I did!


I attach a binary but there is no guarantee it will work as different distributions sometimes have different version of things or put them in a different place.

The missing asound library is the library for ALSA. Debian-based distributions usually have "runtime" and "development" versions of each package so sometimes you think, for example, "I have installed ALSA" but it is only the runtime package and to compile software you usually need the development versions of packages too. I don't remember what the current alsa development package for ALSA is on Ubuntu but if you can find their package search feature that may help. The package you want will have -dev in the name somewhere.

It has been raised before that it would be good to have pre-packaged Linux packages and if we could produce a .deb and .rpm we would have addressed much of the market. At the moment, though, the way B-Em searches for resource files (roms, disc etc.) doesn't lend itself to the way Linux packages usually work. We should probably put solving that on the list of things to do.
Attachments
b-em-m4000.zip
Zipped Linux executable with smaller M5000 buffer
(822.12 KiB) Downloaded 5 times

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

Re: Music 5000 in B-Em

Postby pixelblip » Fri Dec 08, 2017 7:30 am

Ahh thank you for posting that.........that has cleared something up I always wondered ( i.e do you have to install dev packages in the repositories
when you need libraries).

I had a feeling it was alsa from hunting on the Internet but wasn't sure.
How odd it reports I don't have alsa libraries when running Ubuntu Studio.........there must be some reason there......perhaps because I don't have the development libraries.

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

Re: Music 5000 in B-Em

Postby pixelblip » Fri Dec 08, 2017 7:42 am

That's what it was Coeus :D - it was because I didn't install alsadev the development library. I installed the package manager synaptic ( sudo apt-get install synaptic for people who have no clue!) I am using (on this pc ) Ubuntu Studio 16. It's odd Ubuntu Studio doesn't come with synaptic pre-installed......it's the one thing you often need.........go figure........

It has just compiled without errors! Hoorah! I am so excited!

Thank you for taking the time out to help here. I always wondered about the development libraries - I've learnt something really useful from this post as always struggled compiling things in the past. So there we are.

I keep switching from OSX to windows to Linux as I play around with computers and I think for now my car is parked for a few months in Linux Street :lol:
Ok on to Music 5000!

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

Re: Music 5000 in B-Em

Postby pixelblip » Fri Dec 08, 2017 7:48 am

One more thing (a la Columbo ) .........
It's all working now and midi keyboard is connected. How do you route the midi keyboard into Beeb Em? Are you using Alsa Connect for this?


Return to “emulators”

Who is online

Users browsing this forum: No registered users and 1 guest