nukeykt / Nuked-SC55

Roland SC-55 series emulation
Other
435 stars 48 forks source link

Add MIDI port listing #97

Open graysonguarino opened 1 month ago

graysonguarino commented 1 month ago

Adds an option -pl to list MIDI ports.

When testing this emulator, I was struggling to tell what my MIDI ports were as I have multiple MIDI devices plugged in, some with multiple ports. This helped me determine the one I wished to use.

mckuhei commented 1 month ago

Did you forgot change midi_win32.cpp?

graysonguarino commented 1 month ago

Did you forgot change midi_win32.cpp?

I sure did. I’ll get that revised when I get a chance.

graysonguarino commented 1 month ago

I have not tested the previous commit as I'm struggling to build this on Windows (I've never done Windows C++ development before and cannot figure out how to install SDL2.)

Can you either test that for me, or give me some help on how to install SDL2?

Gerwin2k commented 1 month ago

I had a look at the windows code. There are some issues.

include needs to be lowercase (pre-existing issue)

midiInGetID(midi_handle, puDeviceId); there I changed a case error at ID, and removed the '&' twice in the arguments. Otherwise it won't compile.

printf("Port[%u]: %s\n", i, puDeviceId); Here you are trying to print an integer puDeviceId as if it is a string.

Gerwin2k commented 1 month ago

Maybe a helpful reference: https://stackoverflow.com/questions/4384092/cannot-convert-int-to-lpunit

graysonguarino commented 1 month ago

I had a look at the windows code. There are some issues.

include needs to be lowercase (pre-existing issue)

midiInGetID(midi_handle, puDeviceId); there I changed a case error at ID, and removed the '&' twice in the arguments. Otherwise it won't compile.

printf("Port[%u]: %s\n", i, puDeviceId); Here you are trying to print an integer puDeviceId as if it is a string.

Thank you for looking into this! That means that I didn’t do what I had intended. I’m trying to print a named descriptor of the MIDI device (see the rtmidi implementation in this PR) to print out. All of Microsoft’s types are throwing me for a loop as someone unfamiliar with the win32 API.

graysonguarino commented 1 month ago

It seems like to get a device name, I should have used this: https://learn.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-midiingetdevcaps

@Gerwin2k can you give me a tip on how to install SDL2? I’m using Visual Studio 2022 to build because I don’t know anything about the C++ build process on Windows (I’m only familiar with *nix systems). If you can point me to a better resource, I can use that instead.

Gerwin2k commented 1 month ago

I don't use any recent MSVC. Instead I use MinGW with Code::Blocks IDE. if you do a web search "sdl2 msvc 2022" there are several setup guides.

Note that Nuked-SC55 already reports the Midi port description string in the console, but only for the single port that it is using.

graysonguarino commented 1 month ago

Note that Nuked-SC55 already reports the Midi port description string in the console, but only for the single port that it is using.

I just committed a fix for my previous commit that copies the behavior of what you described. I'm still struggling to get MinGW running and won't have time to check this tonight, but since it's a copy/paste job, I imagine there shouldn't be an issue.

If nobody is free to check this today, I can get back to creating a Windows build environment tomorrow to check my work.

Thank you again for all your help!

Gerwin2k commented 1 month ago

With your recent change it works well. See attached screenshot. listmidi

graysonguarino commented 1 month ago

With your recent change it works well. See attached screenshot.

That’s the behavior I expect! Thanks again for all of your help.

Kappa971 commented 1 month ago

@graysonguarino a guide to compiling on Windows with Visual Studio: https://github.com/nukeykt/Nuked-SC55/pull/44#issuecomment-2070281797