arirusso / unimidi

Realtime MIDI IO for Ruby
Other
255 stars 27 forks source link

No input devices for my Macbook running OSX 10.5 via SSH #2

Closed robbles closed 13 years ago

robbles commented 13 years ago

I tried listing the MIDI inputs using UniMIDI::Device.all on both my Macbook Pro (running 10.6) and old Macbook (10.5), with the same USB MIDI keyboard connected.

The keyboard and two built-in MIDI sources show up on the Macbook Pro. Reading input works as expected.

Nothing shows up on the Macbook.

Could this be an issue with the older MIDI API of the OS?

arirusso commented 13 years ago

It could certainly be...

Unfortunately, I don't have a 10.5 setup available to me right now. I'll try and walk you through some debugging

The fact that you just received a blank list rather than an exception is interesting...

Just to rule out any other causes-- you've confirmed that your keyboard is being seen by the OS in another program?

Also, what version of Ruby/Gem/RVM are you using? and is your OS 32 or 64 bit?

If by chance you want to take a shot at debugging further on your own, the CoreMIDI binding code is contained in this library: http://github.com/arirusso/ffi-coremidi.

robbles commented 13 years ago

Yes, it shows up in Ableton Live on that machine, and I can play notes as well.

Output of ruby --version:

ruby 1.9.2p180 (2011-02-18 revision 30909) [i386-darwin9.8.0]

gem version is 1.3.7

Not using RVM on this machine.

The OS is 32-bit, it's a Core Duo Macbook if that matters. No problems on my 64-bit Macbook Pro running 10.6.7

On Tue, Jun 28, 2011 at 7:55 AM, arirusso < reply@reply.github.com>wrote:

It could certainly be...

Unfortunately, I don't have a 10.5 setup available to me right now. I'll try and walk you through some debugging

The fact that you just received a blank list rather than an exception is interesting...

Just to rule out any other causes-- you've confirmed that your keyboard is being seen by the OS in another program?

Also, what version of Ruby/Gem/RVM are you using? and is your OS 32 or 64 bit?

If by chance you want to take a shot at debugging further on your own, the CoreMIDI binding code is contained in this library: http://github.com/arirusso/ffi-coremidi.

Reply to this email directly or view it on GitHub: https://github.com/arirusso/unimidi/issues/2#issuecomment-1456047

arirusso commented 13 years ago

OK, everything sounds normal. I have had reports that it's working on 32-bit osx, but that was 10.6 as well. :/

We'll get it working if you can bear with either having me walk you through debugging or diving in and debugging it yourself

The first thing I would recommend is taking unimidi out of the equation and dealing with ffi-coremidi directly

Please confirm that this is also returning an empty array

require 'coremidi'

p CoreMIDI::Device.all.map { |device| device.entities.values }.flatten

robbles commented 13 years ago

Sure, sounds good to me. I've poked around in ffi-coremidi a bit already, but haven't found anything.

Yes, that returns an empty array as well.

I also tried:

CoreMIDI::Map.MIDIGetNumberOfDevices

and that returned 0.

On Thu, Jun 30, 2011 at 7:13 AM, arirusso < reply@reply.github.com>wrote:

OK, everything sounds normal. I have had reports that it's working on 32-bit osx, but that was 10.6 as well. :/

We'll get it working if you can bear with either having me walk you through debugging or diving in and debugging it yourself

The first thing I would recommend is taking unimidi out of the equation and dealing with ffi-coremidi directly

Please confirm that this is also returning an empty array

require 'coremidi'

p CoreMIDI::Device.all.map { |device| device.entities.values }.flatten

Reply to this email directly or view it on GitHub: https://github.com/arirusso/unimidi/issues/2#issuecomment-1475077

arirusso commented 13 years ago

That's odd. That method supposedly works the same way in 10.5

That said, I don't think I actually used that method in the app

I assume Map.MIDIGetDevice(0) gives you nil?

robbles commented 13 years ago

Yeah, I just tried it out because it looked useful.

Map.MIDIGetDevice(0) returns a null pointer type, which returns true for "nil?" if that's what you mean.

On 2011-06-30, at 8:21 AM, arirusso <reply@reply.github.com

wrote:

That's odd. That method supposedly works the same way in 10.5

That said, I don't think I actually used that method in the app

I assume Map.MIDIGetDevice(0) gives you nil?

Reply to this email directly or view it on GitHub: https://github.com/arirusso/unimidi/issues/2#issuecomment-1475522

arirusso commented 13 years ago

try adding this to the Map class

extern MIDIDeviceRef MIDIGetExternalDevice( ItemCount deviceIndex0 );

attach_function :MIDIGetExternalDevice, [:ItemCount], :MIDIDeviceRef

and then doing

Map.MIDIGetExternalDevice(0)

robbles commented 13 years ago

Same result, a null pointer.

On Thu, Jun 30, 2011 at 8:52 AM, arirusso < reply@reply.github.com>wrote:

try adding this to the map class

extern MIDIDeviceRef MIDIGetExternalDevice( ItemCount deviceIndex0 );

attach_function :MIDIGetExternalDevice, [:ItemCount], :MIDIDeviceRef

and then doing

Map.MIDIGetExternalDevice(0)

Reply to this email directly or view it on GitHub: https://github.com/arirusso/unimidi/issues/2#issuecomment-1475736

arirusso commented 13 years ago

OK, thanks.

This is a tough one. I'm going to need to think about it for a day or two. Feel free to message me if you have any ideas/questions in the meantime

robbles commented 13 years ago

Sure - thanks for your help so far!

On Thu, Jun 30, 2011 at 8:20 PM, arirusso < reply@reply.github.com>wrote:

OK, thanks.

This is a tough one. I'm going to need to think about it for a day or two. Feel free to message me if you have any ideas/questions in the meantime

Reply to this email directly or view it on GitHub: https://github.com/arirusso/unimidi/issues/2#issuecomment-1480520

arirusso commented 13 years ago

No problem at all

Maybe try another ffi library to make sure that your configuration is okay?

Here's a big list

http://github.com/ffi/ffi/wiki/Projects-Using-FFI

arirusso commented 13 years ago

Maybe try an older version of ruby-ffi too-- after 1.0 but earlier than 1.0.9 or whatever you're using now

robbles commented 13 years ago

Ok - I just figured it out. Sort of.

It fails when I connect to the machine over SSH and try to access MIDI. When I use UniMIDI directly from a terminal on the machine itself, it works (devices show up, I can read data).

Even connecting to itself locally will cause it to fail and not find the devices (i.e. ssh localhost, run ruby script).

I've just tried out the MIDI interfaces from Java and Python as well, exact same problem. So obviously this isn't an issue with your libraries, but I'm pretty mystified here. Any ideas?

On Thu, Jun 30, 2011 at 8:55 PM, arirusso < reply@reply.github.com>wrote:

Maybe try an older version of ruby-ffi too-- after 1.0 but earlier than 1.0.9 or whatever you're using now

Reply to this email directly or view it on GitHub: https://github.com/arirusso/unimidi/issues/2#issuecomment-1480605

arirusso commented 13 years ago

Oh okay, you didn't mention ssh!! :) Howabout when you ssh into the 10.6 laptop? Does the same thing happen?

If I had to guess... perhaps OSX disallows remote access to some system APIs

robbles commented 13 years ago

Nope, it doesn't happen on the 10.6 laptop.

Surely there must be some way to disable this. I found this post, which seems to be related to the same problem: http://stackoverflow.com/questions/5386109/coremidi-on-the-command-line

But that doesn't explain why it works on my 10.6 laptop... I'm assuming there should be some kind of initialization I can do so that a process can connect to the CoreMidi server?

On Fri, Jul 1, 2011 at 8:13 AM, arirusso < reply@reply.github.com>wrote:

Oh okay, you didn't mention ssh!! :) Howabout when you ssh into the 10.6 laptop? Does the same thing happen?

If I had to guess... perhaps OSX disallows remote access to some system APIs

Reply to this email directly or view it on GitHub: https://github.com/arirusso/unimidi/issues/2#issuecomment-1483460

arirusso commented 13 years ago

Well, maybe the person asking the question is using 10.5 too. But yeah, I'm not sure what to do.

There may be other options depending on what it is you're trying to do... I mean, writing an EventMachine server to accept OSC or shortcuts to MIDI commands would be pretty simple...and probably be simpler in the long-run if you want to allow other people to deploy the app