aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--desktop/sources/scripts/client.js2
-rw-r--r--desktop/sources/scripts/commander.js9
-rw-r--r--desktop/sources/scripts/core/io/midi.js4
-rw-r--r--desktop/sources/scripts/core/io/udp.js52
-rw-r--r--examples/setups/shift+registers.orca24
-rw-r--r--sw.js2
7 files changed, 46 insertions, 50 deletions
diff --git a/README.md b/README.md
index 2785859..2ba0b1d 100644
--- a/README.md
+++ b/README.md
@@ -146,6 +146,9 @@ All commands have a shorthand equivalent to their first two characters, for exam
- `inject:pattern;12;34` Inject the local file `pattern.orca`, at `12,34`(optional).
- `write:H;12;34` Writes glyph `H`, at `12,34`(optional).
- `time` Prints the time, in minutes seconds, since `0f`.
+- `midi:1;2` Set Midi output device to `#1`, and input device to `#2`.
+- `udp:1234;5678` Set UDP output port to `1234`, and input port to `5678`.
+- `osc:1234` Set OSC output port to `1234`.
## Base36 Table
diff --git a/desktop/sources/scripts/client.js b/desktop/sources/scripts/client.js
index 0fbfc36..f1e4706 100644
--- a/desktop/sources/scripts/client.js
+++ b/desktop/sources/scripts/client.js
@@ -12,7 +12,7 @@
/* global Theme */
function Client () {
- this.version = 175
+ this.version = 176
this.library = library
this.theme = new Theme(this)
diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js
index 9f108e2..71ee1dd 100644
--- a/desktop/sources/scripts/commander.js
+++ b/desktop/sources/scripts/commander.js
@@ -24,7 +24,14 @@ function Commander (client) {
this.actives = {
// Ports
osc: (p) => { client.io.osc.select(p.int) },
- udp: (p) => { client.io.udp.select(p.int) },
+ udp: (p) => {
+ client.io.udp.selectOutput(p.x)
+ if (p.y !== null) { client.io.udp.selectInput(p.y) }
+ },
+ midi: (p) => {
+ client.io.midi.selectOutput(p.x)
+ if (p.y !== null) { client.io.midi.selectInput(p.y) }
+ },
ip: (p) => { client.io.setIp(p.str) },
cc: (p) => { client.io.cc.setOffset(p.int) },
pg: (p) => { client.io.cc.stack.push({ channel: clamp(p.ints[0], 0, 15), bank: p.ints[1], sub: p.ints[2], pgm: clamp(p.ints[3], 0, 127), type: 'pg' }); client.io.cc.run() },
diff --git a/desktop/sources/scripts/core/io/midi.js b/desktop/sources/scripts/core/io/midi.js
index a298237..5fda0ae 100644
--- a/desktop/sources/scripts/core/io/midi.js
+++ b/desktop/sources/scripts/core/io/midi.js
@@ -146,7 +146,7 @@ function Midi (client) {
this.selectOutput = function (id) {
if (id === -1) { this.outputIndex = -1; console.log('MIDI', 'Select Output Device: None'); return }
- if (!this.outputs[id]) { return }
+ if (!this.outputs[id]) { console.warn('MIDI',`Unknown device with id ${id}`); return }
this.outputIndex = parseInt(id)
console.log('MIDI', `Select Output Device: ${this.outputDevice().name}`)
@@ -155,7 +155,7 @@ function Midi (client) {
this.selectInput = function (id) {
if (this.inputDevice()) { this.inputDevice().onmidimessage = null }
if (id === -1) { this.inputIndex = -1; console.log('MIDI', 'Select Input Device: None'); return }
- if (!this.inputs[id]) { return }
+ if (!this.inputs[id]) { console.warn('MIDI',`Unknown device with id ${id}`); return }
this.inputIndex = parseInt(id)
this.inputDevice().onmidimessage = (msg) => { this.receive(msg) }
diff --git a/desktop/sources/scripts/core/io/udp.js b/desktop/sources/scripts/core/io/udp.js
index 3c05055..0fe131a 100644
--- a/desktop/sources/scripts/core/io/udp.js
+++ b/desktop/sources/scripts/core/io/udp.js
@@ -5,31 +5,15 @@ function Udp (client) {
this.stack = []
this.port = null
- this.options = { default: 49161, orca: 49160 }
this.socket = dgram ? dgram.createSocket('udp4') : null
this.listener = dgram ? dgram.createSocket('udp4') : null
this.start = function () {
- if (!this.socket || !this.listener) { console.warn('UDP', 'Could not start.'); return }
+ if (!dgram || !this.socket || !this.listener) { console.warn('UDP', 'Could not start.'); return }
console.info('UDP', 'Starting..')
- this.listener.on('message', (msg, rinfo) => {
- client.commander.trigger(`${msg}`)
- })
-
- this.listener.on('listening', () => {
- const address = this.listener.address()
- console.info('UDP', `Started socket at ${address.address}:${address.port}`)
- })
-
- this.listener.on('error', (err) => {
- console.warn('UDP', `Server error:\n ${err.stack}`)
- this.listener.close()
- })
-
- this.listener.bind(49160)
-
- this.select()
+ this.selectInput()
+ this.selectOutput()
}
this.clear = function () {
@@ -53,10 +37,36 @@ function Udp (client) {
})
}
- this.select = function (port = this.options.default) {
+ this.selectOutput = function (port = 49161) {
+ if (!dgram) { console.warn('UDP', 'Unavailable.'); return }
if (parseInt(port) === this.port) { console.warn('UDP', 'Already selected'); return }
if (isNaN(port) || port < 1000) { console.warn('UDP', 'Unavailable port'); return }
- console.info('UDP', `Selected port: ${port}`)
+
+ console.log('UDP', `Output: ${port}`)
this.port = parseInt(port)
}
+
+ this.selectInput = (port = 49160) => {
+ if (!dgram) { console.warn('UDP', 'Unavailable.'); return }
+ if (this.listener) { this.listener.close() }
+
+ console.log('UDP', `Input: ${port}`)
+ this.listener = dgram.createSocket('udp4')
+
+ this.listener.on('message', (msg, rinfo) => {
+ client.commander.trigger(`${msg}`)
+ })
+
+ this.listener.on('listening', () => {
+ const address = this.listener.address()
+ console.info('UDP', `Started socket at ${address.address}:${address.port}`)
+ })
+
+ this.listener.on('error', (err) => {
+ console.warn('UDP', `Server error:\n ${err.stack}`)
+ this.listener.close()
+ })
+
+ this.listener.bind(port)
+ }
}
diff --git a/examples/setups/shift+registers.orca b/examples/setups/shift+registers.orca
deleted file mode 100644
index f292071..0000000
--- a/examples/setups/shift+registers.orca
+++ /dev/null
@@ -1,24 +0,0 @@
-......................................................................
-.#.SHIFT.REGISTERS.#..................................................
-......................................................................
-...eO.eO............eO.eO............eO.eO............eO.eO...........
-..fV0cV1...........6Vf3VE...........nV5kV2...........vV6sV4...........
-.cO.cO.cO.........cO.cO.cO.........cO.cO.cO.........cO.cO.cO..........
-hV0eV1bV0........8Vc5VE2Vf........pV2mV4jV3........xV2uV0rV3..........
-..aO.aO.aO.........aO.aO.aO.........aO.aO.aO.........aO.aO.aO.........
-.gV0dV1aV0........7VD4Vc1VB........oV4lV3iV5........wV0tVcqV9.........
-......................................................................
-......................................................................
-.....3C8..............3C8..............4C8..............2C8...........
-......28T10000001......28TEfBcDfEc......68T54323524......48T30c96420..
-..D2.43X0..........D3.43XB..........D4.43X2..........D6.43X6..........
-..*.................................*.................................
-..J................J................J................J................
-..*HHHHHHHHH........HHHHHHHHH.......*HHHHHHHHH........HHHHHHHHH.......
-19l001110000.....19lcDfEcEfBB.....19l454323522.....19l2060c4396.......
-......................................................................
-...Va......Vb......Vc......Vd......Ve......Vf......Vg......Vh.........
-.1F0.....1F0.....1F1.....1F1.....1F1.....1F0.....1F0.....1F0..........
-..................*.......*.......*...................................
-..d4Ki1q..d3Kj2r..d4Kk3s..d3Kl4t..d4Km5u..d3Kn6v..d4Ko7w..d3Kp8x......
-...:05B94..:03f34.*:02E44..:03cc4.*:04E04..:05f64..:04D04..:02c24..... \ No newline at end of file
diff --git a/sw.js b/sw.js
index f417dcb..e909eb7 100644
--- a/sw.js
+++ b/sw.js
@@ -1,4 +1,4 @@
-// 175
+// 176
const assets = [
'./',