mist-devel / c64

C64 core
12 stars 13 forks source link

feature request: MIDI for C64 #1

Closed hippi-viking closed 2 years ago

hippi-viking commented 2 years ago

Hey guys (szia @gyurco)! :)

I was thinking Mist with the C64 core would make a fantastic synth - especially with the dual-SID capability! - if the ports on the MIDI add-on card could be utilised. I am just starting out with the FPGA-adventure, though it looks like a perfect candidate for a first more serious project i imagine it's beyond my current skills. Would you be so kind as to guide me to a direction to start or if your time allows help out with this project?

I know the C64 doesn't have built in MIDI support (unlike the Atari ST), but there are a few custom solutions around for which the source code and schematic are available:

At the moment something does get through the MIDI ports of the add-on card to the C64 core (i guess it might be the UART implemented on the user port), but it does not resemble the data being sent.

Could you help out with this? What should be the first step to take? Maybe implement a small CPU core to process and forward MIDI data to the synth software running on the C64 core in the format it can process?

Thank you in advance! :)

hippi-viking commented 2 years ago

Thanks @gyurco I'll have a look! :)

djhardrich commented 2 years ago

@hippi-viking the Dockerfile is probably the easiest (and I’m definitely going to use it on other machines, thanks @gyurco!), I have an Ubuntu machine with the ppa, but this will also get you out of the woods: https://silverdrs.wordpress.com/2020/11/24/running-older-altera-quartus-on-modern-64bit-gnu-linux/

hippi-viking commented 2 years ago

Thanks @djhardrich ! Yeah, i was also thinking about just copying the library to its place without the package manager as a last resort. :) I was afraid that this is only the tip of the iceberg, but it seems this is the only ancient library needed? The packages in the docker repo seem like a great candidate.

[edit] Thanks guys! I can join testing now. :)

gyurco commented 2 years ago

Strange, if I do this: cat /dev/random > /dev/ttyUSB1 Even with the wrong 38400 bps (so received data will not the same what sent, but who cares about random), MIDI Monitor doesn't hang. If I break the command, the values are staying the same, restarting the command starts to show random values.

gyurco commented 2 years ago

I pushed some precaution mechanisms into the receiver to recover after a framing error, might help. For me, flooding the MIDI IN with random data doesn't do any harm (Station64 can produce some strange effects during that...)

djhardrich commented 2 years ago

Just did a day of heavy testing against builds of each commit, I think we’re out of the woods and that this commit (5/19, before 32mhz aica) is definitely the one to release: e4ba5f04ad6eea30356a4320ec687aa4c7b5162c

Story time:

Two “controllers” (Novation Circuit Rhythm and Teenage Engineering OP-Z) were causing lockups when sending CC messages directly, I recorded the messages and played them back via a usb midi interface and they -wouldn’t- lock up (tested with looped cc playback for 8h straight)……. Ok, so I grabbed my Elektron Digitone (Digitakt will also behave the same for reference), set it to midi mode, channel 1, and enabled some knobs for cc’s 1-4……. NO CRASHES, -smooth- and -fast- response in MIDI Monitor!! The last few commits do introduce a bad cc message every 100 or so (basically the extra error correction isn’t necessary/does more harm than good it looks like). Moral of the story: many modern devices don’t have proper serial midi implementations!

THANK YOU AGAIN @gyurco THIS IS INCREDIBLE!!

harbaum commented 2 years ago

Very cool. Is there a SID synth software for the C64? I could then connect that to another MIST running a Atari st core with Cubase.

djhardrich commented 2 years ago

I’d recommend “Station 64,” which is a freeware download from here: http://djindikator.net/

Also if you end up needing to use a midi monitor, here you go: http://data.uni64.com/Midi_Monitor_PRG.prg.zip

Both seem to work best with Datel set in the menu, I’m about to do the exact same thing with Cubase myself, thanks to you and @gyurco !! Cheers to both of you!

hippi-viking commented 2 years ago

Ah, explains then why I couldn't reproduce the overflood(?)-issue with my gear. For me it seems to work great. Thanks guys for the collaboration! ;) \m/

@harbaum : another good synth is supposed to be cynthcart.

gyurco commented 2 years ago

Just for a follow-up: I got the cheap CH345 based USB-MIDI cable. As @djhardrich mentioned, there was no optocoupler on the input, but they replaced it with a weird transistor based switch. No problem, I had a SFH610A-1 in a box, not quite for this job, but worked. Then realized this MIDI-USB chip is a real crap: probably because no buffer inside, anything above 1-2 instruments will drop bytes, and eventually shuts down, so playing .MID files on the SID emulation in Station64 is impossible. This is true for the opposite side, playing a MID in Cubase, then catching it via Fluidsynth or Timidity also a big disappointment. However playing with a virtual piano worked at least :)

hippi-viking commented 2 years ago

Thanks @gyurco! So you mean @djhardrich probably had problems on the other side of the cable with his controller/cable/adapter as well? It would explain things: I used an arduino-based MIDI controller (with a supposedly proper open-source firmware) straight through an old-school DIN-DIN cable, but couldn't overflow the ACIA even using multitouch/expressive (MPE) mode - which assigns a separate MIDI channel to every touch.

btw: I think I have the same shitty DIN-USB cable as you. :D

djhardrich commented 2 years ago

@hippi-viking No, I was just warning him that the really cheap cables are often missing an optoisolator. My tests were all serial midi directly from controllers; when I did a midi playback test from a computer to MiST with recorded cc events I tested with a Roland UM-ONE, CME U2MIDI v2, and an rp2040 flashed with a usb to serial midi firmware with a 3.3v midi breakout with optoisolator. Also, I had time to test against a stock c64c with a Datel cart; it doesn’t lock up/behaves the same as the c64 core -when the core is put into turbo mode-. When using Cynthcart, use the Kerberos PRG with cart set to Datel mode by the way.

I’m going to get Sequential Model 64 running today… Rest In Peace/Polyphony, Dave Smith ❤️

hippi-viking commented 2 years ago

@harbaum Till, have you had any luck connecting up the C64 core to an Atari ST core to play back MIDI on them?

harbaum commented 2 years ago

I realized that i only have one MIDI equipped board left. I'll have to add a MIDI port to one of my early ptotopypes asap ...