Oop in jit.gl?
Hi list
I want to build a midi visualizer similar to MIDITrail https://apps.apple.com/de/app/miditrail/id421739418?mt=12 that maps notes to 3d space. I have thought about the possibilities on how to do it but somehow got stuck so I write here.
I want to visualize real-time midi and not midi files like midi trail does. My thought was to use jit.gl.sketch, the only way I can think of doing this is to make a big growing while playing list of gl commands that always starts with reset,…. to redraw the 3d scene. At one stage I would have to delete the oldest commands so the list stays manageable I believe. For my understanding an objectoriented approach would be far better but I can’t think of an oop approach in the jit.gl world of Max where every played note is an instance of an self made note object like in JS. I have been dealing with oop with js and processing but not with a oop approach in Max, so is it possible to do, maybe in lua?
Thanks falk
Rather than dynamically creating and deleting new geometry, I would go with a [jit.gl.gridshape @shape cube] for the base shape of a note, attached to a [jit.gl.multiple] feeded with a [jit.matrix 3 float32 10000] that would go through a [jit.gen] that would calculate the position (depending on time and note pitch) and scale (basically streching a cube in one dimension as long as its corresponding note is pressed.
10000 being the total number of notes you can display at the same time. To be adjusted depending on situation and hardware.
First MIDI note would be represented by the first cell of the 10000x1 matrix, second MIDI note by cell 2x1, and so on. Unused notes/cells/cubes could simply be positionned off camera, like behind it.
You could use the same approach but using js to replace the jit.gen, if you're more comfortable with line coding.
Makes me want to give it a try, actually. Maybe later.
Here it is. Maybe it would have been more straightforward with object oriented programming, but it wors quite well with data flow as well.
Hey TFL,
Wow, thanks a lot! unfortunately I can’t have a look just now but I will later today (it’s morning here in NZ) the approach sounds good I didn’t think about it … I might come up with some further question, hope it’s ok thanks again falk