ut-proj / undermidi

An Erlang/LFE MIDI soft real time server for live play of MIDI devices
BSD 2-Clause "Simplified" License
4 stars 1 forks source link

Support playing programmed music upon demand #64

Closed oubiwann closed 1 month ago

oubiwann commented 1 month ago

Upon demand from an external source ...

Target workflow:

  1. Start up Raspberry Pi (w/touch screen)
  2. When desktop displays, touch icon to start undermidi
  3. After undermidi starts, touch icon for a particular MIDI sequence
  4. Ensure that clicking the icon executes the sequence associated with desktop icon
  5. When finished, the original undermidi terminal + REPL is unaffected (stays open)
  6. Provide function for listing all sequences on desktop (icons)
  7. Provide function for selecting and playing one of the sequences
  8. Provide function show showing the current songs in the playlist

Dev tasks:

oubiwann commented 1 month ago

There are many ways to support a workflow like this, but there's one solution that intrigues me most:

oubiwann commented 1 month ago

Right, I forgot: when using rebar, erl and lfe are not called; rather, the shells are invoked in code, so there is not passing of args directly to either. Will have to explore the ENV route ...

oubiwann commented 1 month ago

Well, I guess we don't have to use the ENV route, since we do have rebar3 lfe run ...

oubiwann commented 1 month ago

Okay, I've created a main script in priv/scripts/playlist-add.lfe that takes kv pairs as args on the CLI and turns them into a map.

rebar.config profile section:

{profiles, [
    ...
    {'playlist-add', [
        {lfe, [{main, "priv/scripts/playlist-add.lfe"}]}
    ]}
]}.

Using this profile:

rebar3 as playlist-add lfe run -- name seq1 file priv/seqs/basic.lfe

Output of the script after a couple of rpc ~calls~ casts:

Playlist state: #M(opts #M(repeat f)
                   queue
                     (#M(name "seq1" file "priv/seqs/basic.lfe")
                      #M(name "seq1" file "priv/seqs/basic.lfe"))
                   played ())
oubiwann commented 1 month ago

That's basic infrastructure experiments done; next is the hard part of determining the best short-term solution for actually playing these files (a longer term solution can't be worked on until this epic work is nearing completion).

oubiwann commented 1 month ago

Key required behaviours:

oubiwann commented 1 month ago

Phew! That's the most involved OTP I've done in a while ...