Skip to content
Snippets Groups Projects
Commit 656a42f2 authored by Micah Elizabeth Scott's avatar Micah Elizabeth Scott
Browse files

Command line args

parent 2a67a788
No related branches found
No related tags found
No related merge requests found
...@@ -4,27 +4,47 @@ ...@@ -4,27 +4,47 @@
# #
# Dependencies: run `npm install` in this directory. # Dependencies: run `npm install` in this directory.
# #
# Assumes the default MIDI input port (0). # Command line options:
# Specify a layout file on the command line, or use the default (grid32x16z) #
# --midiport <int> Use a different MIDI port. Defaults to zero.
# --layout <file> Pick a JSON layout file. Defaults to grid32x16z
# --opchost <hostname> Network host running the OPC server. Defaults to localhost.
# --opcport <port> Network port for the OPC server. Defaults to 7890.
# #
# Controls: # Controls:
# (Tested with Alesis Q49 keyboard controller)
# Left hand -> Low frequency oscillators (wobble) # Left hand -> Low frequency oscillators (wobble)
# Right hand -> Particles, shifting in color and pointiness # Right hand -> Particles, shifting in color and pointiness
# #
# Supported MIDI keyboards:
# - Basic MIDI works for any keyboard
# - Pitch bend / modulation / data knobs on Alesis Q49
# - Data sliders on Oxygen 61
#
# 2014, Micah Elizabeth Scott & Keroserene # 2014, Micah Elizabeth Scott & Keroserene
# #
# Default MIDI input parseArgs = require 'minimist'
midi = require 'midi' midi = require 'midi'
OPC = new require './opc'
argv = parseArgs process.argv.slice(2),
default:
layout: '../layouts/grid32x16z.json'
midiport: 0
opchost: 'localhost'
opcport: 7890
input = new midi.input input = new midi.input
input.openPort 1 if argv.midiport >= input.getPortCount()
input.ignoreTypes false, false, false console.log "MIDI port #{ argv.midiport } isn't available!"
process.exit 1
# Default OPC output console.log "Using MIDI port #{ argv.midiport }: #{ input.getPortName argv.midiport }"
OPC = new require './opc' input.openPort argv.midiport
model = OPC.loadModel process.argv[2] || '../layouts/grid32x16z.json'
client = new OPC 'localhost', 7890 console.log "Using OPC server at #{ argv.opchost }:#{ argv.opcport }"
model = OPC.loadModel argv.layout
client = new OPC argv.opchost, argv.opcport
# Live particles # Live particles
particles = [] particles = []
...@@ -70,6 +90,7 @@ LOWEST_A = 1 ...@@ -70,6 +90,7 @@ LOWEST_A = 1
HIGHEST_C = 124 HIGHEST_C = 124
getKeyName = (key) -> FLAT_NAMES[(key - LOWEST_A) % 12] getKeyName = (key) -> FLAT_NAMES[(key - LOWEST_A) % 12]
input.ignoreTypes false, false, false
input.on 'message', (deltaTime, message) -> input.on 'message', (deltaTime, message) ->
logMsg = message logMsg = message
msgType = Math.floor parseInt(message[0]) / 16 # Examine the 0xF0 byte. msgType = Math.floor parseInt(message[0]) / 16 # Examine the 0xF0 byte.
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
}, },
"dependencies": { "dependencies": {
"flags": "~0.1.1", "flags": "~0.1.1",
"midi": "~0.8.1" "midi": "~0.8.1",
"minimist": "~0.0.8"
}, },
"private": true "private": true
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment