[Closed] 3 dotnet classes
For Processing there’s a library called promidi , it has samples in the zip package.
First I create the objects like
openInput(<inputDeviceNumber>, <midiChannel>)
then the library has its own event when midi in gets detected
void controllerIn(promidi.Controller midiController, int device, int channel)
then i identify the inputs i’m interested in using
midiController.getNumber() and midiController.getValue()
Each slider or knob has a number and sends a value when you move it.
I’ve been searching for ways of getting a midi input using .net in maxscript but i had no success so in the end I have this Processing java applet capturing midi inputs then I intend to send data thru a tcpip socket to max using this method, having the applet as server and max as client.
That would be much more simple and probably faster if anyone finds a way of getting midi inputs directly from mxs. There is a C# midi library here but interfacing that assembly in mxs proved to be hard for me. Just the midi library is here
For the fun some people got midi controllers to work in Lightroom using its Lua script and others want to make Nuke work with them.
Actually all I need is already in Max using its Midi capture controller. You assign it as controller in Track View to any parameter you like. But that controller generates keyframes and is active only when animating. I’d like to have it active all the time but without keyframes or animations, just a link between a midi controller and a numerical value inside max.
Thanks for any suggestions!
hi,
I used that midi library to hook up my TD-4 drumkit to max, i amused myself hugely by making a teapot scale and change colour according to which drum I hit. the crux of using it in max is here - i used a roland UM-1 usb interface to hook to up. Just a bit of silliness really, but may be useful to you as a method of how to set this up in MXS. The bit you probably need is the hook up of the interface at the bottom -
dotnet.loadassembly ((Getdir #scripts) + @"\MIDI\Sanford.Collections")
dotnet.loadassembly ((Getdir #scripts) + @"\MIDI\Sanford.Multimedia")
dotnet.loadassembly ((Getdir #scripts) + @"\MIDI\Sanford.Multimedia.MIDI")
dotnet.loadassembly ((Getdir #scripts) + @"\MIDI\Sanford.Multimedia.Timers")
dotnet.loadassembly ((Getdir #scripts) + @"\MIDI\Sanford.Threading")
fn MIDIEvent sender e =
(
--format "MIDI Command - %
” e.Message.Command.noteon as string
–format “MIDI Channel – %
” e.Message.MidiChannel as string
–format “MIDI Data1 – %
” e.Message.Data1 as string
if e.Message.Command == e.Message.Command.noteon then
(
$'Teapot01'.radius = 20.0*(e.Message.Data2*0.1)
case of
(
($'Teapot01'.radius <= 50):$'Teapot01'.wirecolor = green
($'Teapot01'.radius <= 90):$'Teapot01'.wirecolor = orange
($'Teapot01'.radius <= 120):$'Teapot01'.wirecolor = yellow
($'Teapot01'.radius > 120):$'Teapot01'.wirecolor = red
)
)
else
(
$'Teapot01'.radius = 20.0
$'Teapot01'.wirecolor = (color 88 88 225)
)
--format "MIDI Data2 - %
” e.Message.Data2 as string
)
ClearListener()
-- Set the midi input device
RolandUM1= Dotnetobject "Sanford.Multimedia.Midi.InputDevice" 0
RolandUM1Props = (dotnetclass "Sanford.Multimedia.Midi.InputDevice").GetDeviceCapabilities(0)
RolandUM1Props.name
RolandUM1Props.driverversion
DotNet.addeventhandler RolandUM1 "ChannelMessageReceived" MIDIEvent
RolandUM1.StartRecording()
I had to wait a lot for the post to be approved, since I’m new here. :surprised
Anyway the code works and I had no idea you can interface an assembly that way. This really is a shortcut compared to tcpip sockets Max <-> Processing.
Thank you!!!
Great stuff, I also saw that Stanford Assembly but I guess the idea was to insert something like that in my KClasses without having to provide external dll’s but since there’s already one that works, I think I’ll skip this one and since Pete already supplied a working code you are ready to go!
Cheers!