template.esl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. (lambda (data)
  2. (var state (/state))
  3. (var midi-ins (array))
  4. (var midi-outs (array))
  5. (state.jack.clients.for-each get-midi-ports)
  6. (function get-midi-ports (client)
  7. (var ports (get client 2))
  8. (.for-each (ports.filter is-midi-port) add-midi-port))
  9. (function is-midi-port (port)
  10. (return (=== 1 (get port 3))))
  11. (function add-midi-port (port)
  12. (if (=== 22 (get port 2)) (midi-ins.push port))
  13. (if (=== 21 (get port 2)) (midi-outs.push port)))
  14. (var info (array
  15. (array "text" "Type" "Controller")
  16. (array "text" "ID" data.id)))
  17. (function select (label options)
  18. (return (/h "div" (/h "label" (array label " " (/h "select"
  19. (.concat (array (/h "option" "(none)")) options)))))))
  20. (function option-port (port)
  21. (return (/h "option" (object "value" (get port 0)) (get port 1))))
  22. (function option-script (script i)
  23. (return (/h "option" (object "value" i) script)))
  24. (return (/h ".device.controller" (array
  25. (/h ".device-header" (array
  26. (./device/label data.label (+ "Controller " data.id))))
  27. (select "Script" (state.controller-scripts.map option-script))
  28. (select "Input" (midi-ins.map option-port))
  29. (select "Output" (midi-outs.map option-port))))))