MIDI/OSC?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
kmorton
Posts: 6
Joined: Fri Nov 04, 2016 8:55 pm

MIDI/OSC?

Post by kmorton »

Is it possible to handle MIDI or OSC input with Moho's scripting? I'd really love to integrate control surfaces with Moho.

Thanks
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: MIDI/OSC?

Post by hayasidist »

That really depends, IMO, on what you want to achieve.

If you're asking about taking a .midi file and using that to control the animation then it's perfectly feasible to write a program that will read the midi file and interpret it according to rules (that you hard code or otherwise define) to draw or select and animate objects. (That's in effect how lipsync works - read a sound file and create commands that moho understands to change things -- lipsync usually works with pre-drawn mouth shapes, but you could have anything - dancing elephants if you wanted to - instead of lips moving.)

But (because you've said OSC) I'm guessing you mean "in real time" -- to have the animation respond in real time to the sounds? I don't think that will work because of the workflow - creating the final video output is not a real time affair... it can takes a long time to render one frame.
kmorton
Posts: 6
Joined: Fri Nov 04, 2016 8:55 pm

Re: MIDI/OSC?

Post by kmorton »

Yeah, I'm not interested in real-time puppetting for final animation or anything like that. Just controlling multiple bone rotations, etc. using incoming messages to set poses for keyframing. Turn physical dials to adjust a head turn, eyebrows, etc. I have a Surface Dial but I'd like to control multiple things at once with something like a MIDI Fighter Twister.
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: MIDI/OSC?

Post by hayasidist »

Interesting concept. there is an "OnInputDeviceEvent" function available for scripting, and there are routines to access the message that a device sends (http://mohoscripting.com/index.php?show ... eviceEvent)

but I simply don't know if it's possible (I've never tried) to get Moho to recognise an input device other than mouse, keyboard or tablet. The standard Moho tools such as LM_TransformPoints have example code for (e.g.) multitouch tablets, but it looks as though there's been some pre-processing on the deviceEvent.inputData -- IOW what is made available to the script does not look as though it's "raw" from the device.

So, on balance, I'd say that Moho as is can't interface to such as fighter twister as an input device - but it would be great if it could and I'd **LOVE** someone to tell me I'm wrong.
kmorton
Posts: 6
Joined: Fri Nov 04, 2016 8:55 pm

Re: MIDI/OSC?

Post by kmorton »

That function looks very promising! Hopefully I'll find some way to make use of it in the future.

In the meantime I did get a MIDI Fighter Twister working with Moho, sending keypresses and using a tool script to rotate bones. Very much a kludge but it works.
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: MIDI/OSC?

Post by hayasidist »

Well done -- If you're prepared to share (privately or publicly) I'd love to see that script!
Post Reply