rhargreaves / mega-drive-midi-interface

Control the Sega Mega Drive's Yamaha YM2612 and PSG with MIDI
GNU General Public License v3.0
92 stars 8 forks source link

Connection troubles #24

Closed vandoeselaar closed 2 years ago

vandoeselaar commented 3 years ago

First I would like to thank you so much for creating this!

I am using your latest build with an Everdrive MD and a FTDL to controller port cable. (I have not tried burning the binary to a rom yet)

I have verified if the FTDL to controller port cable is working with your Mega Drive Serial Port Diagnostic Tool. I do receive "0123456789\n" correctly and I am able to send characters to the SEGA. So far so good.

On first boot the "mega-drive-midi-interface" shows "Unknown Status 75 X7 USB" in the lower left corner of the screen.

If I reset the SEGA this message disappears and If I reset again it will show "Waiting" in the lower left corner and after a few seconds "PRO SUB"

So I setup Hairless MIDI<->Serial Bridge and "IAC Device Bus" to send MIDI messages from Logic Pro but the SEGA is not receiving any signals.

Then I tried your "mega-midi-ping-pong" which outputs: In: IAC-besturingsbestand Bus 1 Out: IAC-besturingsbestand Bus 1 20.431µs: Ping? Mismatch! f000227701f70000 21.192749ms: Ping? Mismatch! f000227701f70000 43.507758ms: Ping? Mismatch! f000227701f70000 67.299257ms: Ping? Mismatch! f000227701f70000

EDIT

I now have programmed an 27C322 with the latest release ( I know, that's a lot of wasted space). When I power on the SEGA it shows "serial 4800bps" :) So it seems there is a problem when running this from the Everdrive MD.

But when I run "mega-midi-ping-pong" I still get a mismatch. So now I am wondering what is the problem?

rhargreaves commented 3 years ago

Which model EverDrive are you using? And just to confirm - you're using some sort of serial to controller port device?

vandoeselaar commented 3 years ago

Thanks for your reply,

Previously I tried with: -MegaDrive I & II -Everdrive MD as described here: https://segaretro.org/Everdrive_MD -A USB serial cable connected to port 2 as described here: https://github.com/rhargreaves/mega-drive-serial-port#hardware

In my latest attempt I have used: -MegaDrive II -A MegaDrive cartridge PCB with a programmed 27c322 -A USB serial cable connected to port 2 as described here: https://github.com/rhargreaves/mega-drive-serial-port#hardware

The latest attempt was the most promising because it showed "serial 4800bps", but also an error when I run "mega-midi-ping-pong"

I tried several usb2serial adapters. They all worked flawlessly with your mega-drive-serial-port diagnostic tool. When I send a string of text to the MegaDrive it displays just fine.

vandoeselaar commented 3 years ago

To clarify myself further I have attached photo's of the error message and the ttl-usb-serial devices IMG_9678 IMG_9679 IMG_9680 IMG_9681

rhargreaves commented 3 years ago

Interesting...

Can I ask what MIDI data you're sending to the device when it came up with "unknown status" of FD and FF? Was it just what came up when you tried running the ping pong tool?

It's possible there might have been a regression in the later versions of the interface (probably when I was adding support for the EverDrive PRO). Could you try an older version, perhaps as far as this one? https://github.com/rhargreaves/mega-drive-midi-interface/releases/tag/v0.4.4

I'll see if I can reproduce it on my side.

rhargreaves commented 3 years ago

You could also try and setting a lower baud rate by changing this line of code and re-compiling. https://github.com/rhargreaves/mega-drive-midi-interface/blob/87339387a0a369d775fcf2b90f3ef1ba252a6d82/src/comm_serial.c#L40 Unfortunately there's no way to modify this at runtime.

rhargreaves commented 3 years ago

I've just tested the v0.6.6 version with a serial cable and it's working OK for me. I am using a PAL Mega Drive Model 1 VA6.

"Unknown status" just means "I've read this byte but I don't know what to do with it." So 0xFD 0xFF got sent to the Mega Drive over the serial cable, telling you that at least it's receiving data, even if it isn't able to interpret the data into MIDI that it supports. (Technically 0xFF according to MIDI 1.0 is "Reset", but it doesn't implement it)

vandoeselaar commented 3 years ago

Ok after reading it worked for you I gave it another go. I found a way to make it sort of work :)

-start the Midi Interface (it will show "Waiting") -start Hairless serial midi bridge -the Midi Interface (it will show "Serial 4800bps") -started MidiKeys to send some notes -at this point the Sega Midi Interface will just respond with Unknown status FF or FE -Start the Arduino IDE and open a Serial window @ 4800bps -The Interface now responds on input from MidiKeys and SendMidi from command line

When I start the Arduino IDE and open a Serial window the Sega comes to live ???

I then used SendMidi from the command line to change to Dynamic mode and also changing the instruments is no problem.

If I try to send notes from Logic Pro. the Sega just hangs on one note and crashes.

So I'm not sure what is happening here, but I'm happy to see it works. Now I do need to find why it is not working from Logic Pro as this is my main DAW

vandoeselaar commented 3 years ago

As I had a hunch the problem was with Hairless or OsX IAC converting the midi to serial. I wrote a small program today for Arduino to simply forward the midi input at 4800bps. I also added a few shortcut buttons to quickly switch between Dynamic/Static mode and some instruments. This works really nice :) Again thanks for developing this project!

rhargreaves commented 3 years ago

Glad you got it working - at least some way! I'm curious as to why Logic Pro crashes it. Are you able to log the MIDI data sent to the interface somehow? Hairless has a debug option where it prints the events sent. I wonder if it's sending some SysEx and the interface is getting stuck on it.

vandoeselaar commented 3 years ago

I have tried it again, but the log Hairless keeps is to short so I used MidiMonitor.

The setup is the same as before. -MegaDrive II -start Hairless -send midi command from terminal to see if there is a connection -> results in error -start Arduino interface (I guess to set the right speed 4800bps) -send midi command from terminal to see if there is a connection -> and now it works. -start Logic Pro -start new project -add new External Instrument, selecting IAC Bus -create new midi region -press a random note

now it's stuck and from what I see the note off command is not send. I have not seen any SysEx command in the log.

edit I have tested this on 2 different Mac's both running Catalina both act the same.

here is the log:

//sendmidi command to switch to Dynamic mode to IAC Bus, but result is error 12:00:33.537 From Bus 1 Control 1 General Purpose 5 127 //arduino started, now the MegaDrive switches to dynamic mode. 12:00:50.344 From Bus 1 Control 1 General Purpose 5 127 //sending one note from Logic 12:01:41.660 From Bus 1 Note On 1 C3 80 12:01:41.677 From Bus 1 Note On 1 C3 80 12:01:41.677 From Bus 1 Note On 1 C3 80 12:01:41.677 From Bus 1 Note On 1 C3 80 12:01:41.677 From Bus 1 Note On 1 C3 80 12:01:41.677 From Bus 1 Note On 1 C3 80 12:01:41.677 From Bus 1 Note On 1 C3 80 12:01:41.677 From Bus 1 Note On 1 C3 80 12:01:41.677 From Bus 1 Note On 1 C3 80

and this keeps going until I switch of the MegaDrive

rhargreaves commented 3 years ago

Without note offs, continual note ons will cause the interface to run out of channels to play the note! Is it actually making any sound when logic sends those events?

Logic not sending note offs is a bit strange. The interface can either handle note off events, or note on events with velocity of zero, so if you can get Logic to do either of those things then it shouldn't run out of channels!

vandoeselaar commented 3 years ago

Well the MegaDrive is overloaded for sure. It plays some notes but then just halts.

I'm really thinking this must be some problem with the software converting midi to serial. I have never had any problems with other synths.

So I will just use the little device I build for this.

IMG_0012 IMG_0011 IMG_0010

RomaRogov commented 3 years ago

Hello!

I've had the same issue when I tried to connect with my genesis via USB to TTL cable. At the end I wrote program for Teensy too and now it works well! Teensy behaves as USB-MIDI device and I found it more useful than additional software. I want to leave code for teensy here, so anybody who has suffered from this issue may fix it easily; code is pretty simple though. https://github.com/rhargreaves/mega-drive-midi-interface/files/6278704/teensy_midi.zip

And thanks for your work, open-sourced alternative for genMDM is a great thing! I'm learning so much just from looking into the code!

robbennet commented 2 years ago

@vandoeselaar would you be open sharing your schematic/design for the device you build that uses 5 pin Midi din instead of usb midi? Am I right in assuming that you got this working without routing through a DAW and instead just use straight midi from a keyboard? Would love to have any info on this you're willing to share!