ravelox / pimidi

Raspberry Pi RTP MIDI
164 stars 38 forks source link

Possible to build as a dynamic library? #34

Open qzic opened 5 years ago

qzic commented 5 years ago

I would like to interface your code to a Java application (a PI sample player interfaced to an old set of Hammond Organ pedals. I want to be able to send out midi via rtp/WIFI as pedals are pressed. To do this, I can write a Java JNI interface to a C/C++ dynamic library. Receive midi would also be useful of course. Your code does all of this so I just need it to exist as a library instead of a daemon.

Is there an easy way to configure the build process to do this? If not, could you give me some pointers to where I could educate myself?

ravelox commented 5 years ago

I have thought for a while about a library. What functions would you be looking to use from raveloxmidi?

Thanks

Dave

qzic commented 5 years ago

Just sending and receiving MIDI notes and I guess program change would be useful too.
After asking this question, I searched around and it seems I may be able to write some Java/JNI code that attaches to a running C/C++ process. I've never done anything like this but I found some Java code that connects to Skype (a C process). Anyway, I'll investigate and see if I can make this work. I do have some Java test code that knows how to I/F to a C library and run as a daemon.

qzic commented 5 years ago

My "Skype" direction turned out to be a dead-end so a RevoloxMidi library does seem to be the best solution.

qzic commented 5 years ago

OK, so looks like Tobias already did this. https://www.tobias-erichsen.de/software/librtpmidi.html not open source though.

jpcima commented 5 years ago

Hi. I think, it would be nice if the program separates the pure networking functionality in a core library.

I would like a design where I am able to have: a midi writer function, and a reader callback. Then, it's my responsability to redirect messages to platform specific MIDI.

An end goal is to permit a library which runs the desktop program and Android app. (btw, if I may ask, why has ALSA rawmidi been preferred over a normal client?)

Thanks for making raveloxmidi.

ravelox commented 5 years ago

Hi. I think, it would be nice if the program separates the pure networking functionality in a core library.

I would like a design where I am able to have: a midi writer function, and a reader callback. Then, it's my responsability to redirect messages to platform specific MIDI.

An end goal is to permit a library which runs the desktop program and Android app. (btw, if I may ask, why has ALSA rawmidi been preferred over a normal client?)

Thanks for making raveloxmidi.

I'm kind of working towards that in some changes I made a couple of months ago. I move the MIDI distribution to its own function to remove some duplication. I could add a callback interface in that routine.

I'll give this some thought over the weekend.

Regarding the choice of rawmidi, this was a deliberate choice because it provides multiple MIDI events in a single read that requires no conversion to send downstream. Other options, like the sequencer interface only provides a single MIDI event in each call and then that has to be converted from the ALSA structure holding it into binary data.

Thanks

Dave

tschiemer commented 5 years ago

Yes, many thanks for making raveloxmidi!

To have the networking functionality separate would indeed be quite nice.

I would also add a command line utility reading/writing a midi binary stream from either stdin/out or possibly named pipes which would feel like a useful addition. In this regard, I would think named pipes might also be an alternative to using a socket for input (outgoing messages) and a file for output (incoming messages). I could have a go at that if there is a library..