kylestetz / lissajous

:musical_note: A tool for programmatic audio performance in the browser using Javascript.

Home Page:http://lissajousjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ideas for Midi controller input

kylestetz opened this issue · comments

I wanted to get down some notes I had on a possible midi controller API. I would love some feedback!

It would be cool to have a midi object, instantiated via var controller = new midi() (perhaps with some arguments to select the correct controller), and then use its functions the same way generators are used on tracks.

controller = new midi()
t = new track()
t.notes( controller.keys.notes() )
t.beat( controller.keys.beat() )
t.vol( controller.cc(20).map(0,1) )

So that controller.keys has several methods that return events from the keys, such as:

  • notes(): returns MIDI note values
  • beat(): returns events that trigger notes
  • map(min, max): returns the key values (0-127) mapped to the min & max

And controller.cc(number) has methods that return events from CC controllers:

  • map(min, max): returns controller values (0-127) mapped to the min & max
  • ?

Philosophy

My thought on this is that new CC and key values will only be read when a beat is triggered. This is consistent with how Lissajous currently interprets parameter sequences. There are two details of the implementation worth mentioning:

  1. schedulers will need to accept event handlers so that controller.keys.beat() can trigger a note, which will be more complicated because they already accept callbacks. This means it might have to be an object that inherits a prototype for the purposes of type checking (if typeof === 'MidiEvent etc).

  2. To avoid reading cc values from the midi controller (which would not be possible if you are mapping key values to a parameter) the last value for a given control will need to be cached. This should be really easy to create, simply saving anything that comes in and using that as the data source for the functions passed into parameters.

I have started writing down the controller class during the WAC hackaton. I will take this issue in consideration and come back to you asap!

Sounds great, can't wait to check it out!