loopier / animatron

Animatron for Godot 4.x <
15 stars 1 forks source link

On MIDI #29

Open loopier opened 6 months ago

loopier commented 6 months ago

MIDI implementation on AG3 wasn't very clear or agile. Far from optimal. Giving it some more thought this idea came out: how about using /midi like we do with /routine and /def? We could give it a name and pass variables to it.

First a /midi/def would be defined, then it could be reused with different values using /midi <NAME> [ARGS].

The last 2 arguments of all /midi/[ch|velocity|note|...] commands are always the minimum and maximum values to which the MIDI value will be converted. Here are some ideas of possible MIDI subcommand syntax:

# definition
/midi/def bla actor note
    # set the channel for this midi def
    /midi/ch 0 

    # velocity for any note mapped to a range between 0 - 1920
    /midi/velocity /position/x $actor 0 1920 

    # note value mapped to a range between 0 - 12
    /midi/note /frame $actor 0 12 

    # velocity for note 60 mapped to a range between 0 - 360
    /midi/note/velocity 60 /angle $actor 0 360
    # alternative syntax
    /midi/noteon 60 /angle $actor 0 360
    # same using a variable
    /midi/note/velocity $note /speed $actor 0.5 2

    # oneshot
    /midi/noteoff 60 /stop $actor

    # value of CC mapped to 0.0 - 1.0
    /midi/cc 1 /color/r $actor 0 1

# usage
/create ma default
/create ta somethingelse
/midi bla ma 60
/midi bla ta 59

This might make it inconsistent with /routine which would have to change to /routine/def and then be used with /routine <NAME> <ARGS> but I'm not sure that is desirable. It works well as it is now.

What do you think?

totalgee commented 6 months ago

I don't understand your example. I don't see why we need a /midi/def when it looks to me basically like a /def that sets up a bunch of MIDI subcommands. I think we may need to talk about this in person.

totalgee commented 6 months ago

Also, a /routine call is the definition of the routine. There is no need for a separate call... Or maybe I'm misunderstanding something in what problem(s) you're trying to solve.

loopier commented 6 months ago

I don't understand your example. I don't see why we need a /midi/def when it looks to me basically like a /def that sets up a bunch of MIDI subcommands. I think we may need to talk about this in person.

You are SO right! That kind of solves the problem. We could atomize /midi/* commands for each midi event or use case (noteon using velocity, noteon using note number, noteon as a trigger, ...). It was confusing in AG3, I think it's clear now, but let's talk about it in person.

Also, a /routine call is the definition of the routine. There is no need for a separate call... Or maybe I'm misunderstanding something in what problem(s) you're trying to solve.

This is what I meant by /midi/def not being consistent with /routine. But your previous point avoids this inconsistency, so we should be good.