Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
neauoire committed Nov 19, 2019
1 parent ca8bcf5 commit 9c7e9a5
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 58 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ npm start
- `?` **pb**(channel value): Sends MIDI pitch bench.
- `;` **udp**: Sends UDP message.
- `=` **osc**(*path*): Sends OSC message.
- `$` **self**: Sends a [command](#Commands) to itself.
- `$` **self**: Sends [ORCA command](#Commands).

## MIDI

Expand Down
2 changes: 1 addition & 1 deletion desktop/sources/scripts/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/* global Theme */

function Client () {
this.version = 151
this.version = 152
this.library = library

this.theme = new Theme(this)
Expand Down
107 changes: 54 additions & 53 deletions desktop/sources/scripts/core/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ library.$ = function OperatorSelf (orca, x, y, passive) {
Operator.call(this, orca, x, y, '*', true)

this.name = 'self'
this.info = 'Send command to itself'
this.info = 'Sends ORCA command'

this.run = function (force = false) {
let msg = ''
Expand All @@ -537,12 +537,47 @@ library.$ = function OperatorSelf (orca, x, y, passive) {
}
}

library[':'] = function OperatorMidi (orca, x, y, passive) {
Operator.call(this, orca, x, y, ':', true)

this.name = 'midi'
this.info = 'Sends MIDI note'
this.ports.channel = { x: 1, y: 0 }
this.ports.octave = { x: 2, y: 0, clamp: { min: 0, max: 8 } }
this.ports.note = { x: 3, y: 0 }
this.ports.velocity = { x: 4, y: 0, default: 'f', clamp: { min: 0, max: 16 } }
this.ports.length = { x: 5, y: 0, default: '1', clamp: { min: 0, max: 16 } }

this.operation = function (force = false) {
if (!this.hasNeighbor('*') && force === false) { return }
if (this.listen(this.ports.channel) === '.') { return }
if (this.listen(this.ports.octave) === '.') { return }
if (this.listen(this.ports.note) === '.') { return }
if (!isNaN(this.listen(this.ports.note))) { return }

const channel = this.listen(this.ports.channel, true)
if (channel > 15) { return }
const octave = this.listen(this.ports.octave, true)
const note = this.listen(this.ports.note)
const velocity = this.listen(this.ports.velocity, true)
const length = this.listen(this.ports.length, true)

client.io.midi.push(channel, octave, note, velocity, length)

if (force === true) {
client.io.midi.run()
}

this.draw = false
}
}

library['!'] = function OperatorCC (orca, x, y) {
Operator.call(this, orca, x, y, '!', true)

this.name = 'cc'
this.info = 'Sends MIDI control change'
this.ports.channel = { x: 1, y: 0, clamp: { min: 0, max: 15 } }
this.ports.channel = { x: 1, y: 0 }
this.ports.knob = { x: 2, y: 0, clamp: { min: 0 } }
this.ports.value = { x: 3, y: 0, clamp: { min: 0 } }

Expand All @@ -552,6 +587,7 @@ library['!'] = function OperatorCC (orca, x, y) {
if (this.listen(this.ports.knob) === '.') { return }

const channel = this.listen(this.ports.channel, true)
if (channel > 15) { return }
const knob = this.listen(this.ports.knob, true)
const rawValue = this.listen(this.ports.value, true)
const value = Math.ceil((127 * rawValue) / 35)
Expand All @@ -566,38 +602,33 @@ library['!'] = function OperatorCC (orca, x, y) {
}
}

library[':'] = function OperatorMidi (orca, x, y, passive) {
Operator.call(this, orca, x, y, ':', true)
library['?'] = function OperatorPB (orca, x, y) {
Operator.call(this, orca, x, y, '?', true)

this.name = 'midi'
this.info = 'Sends MIDI note'
this.ports.channel = { x: 1, y: 0 }
this.ports.octave = { x: 2, y: 0, clamp: { min: 0, max: 8 } }
this.ports.note = { x: 3, y: 0 }
this.ports.velocity = { x: 4, y: 0, default: 'f', clamp: { min: 0, max: 16 } }
this.ports.length = { x: 5, y: 0, default: '1', clamp: { min: 0, max: 16 } }
this.name = 'pb'
this.info = 'Sends MIDI pitch bend'
this.ports.channel = { x: 1, y: 0, clamp: { min: 0, max: 15 } }
this.ports.lsb = { x: 2, y: 0, clamp: { min: 0 } }
this.ports.msb = { x: 3, y: 0, clamp: { min: 0 } }

this.operation = function (force = false) {
if (!this.hasNeighbor('*') && force === false) { return }
if (this.listen(this.ports.channel) === '.') { return }
if (this.listen(this.ports.octave) === '.') { return }
if (this.listen(this.ports.note) === '.') { return }
if (!isNaN(this.listen(this.ports.note))) { return }
if (this.listen(this.ports.lsb) === '.') { return }

const channel = this.listen(this.ports.channel, true)
if (channel > 15) { return }
const octave = this.listen(this.ports.octave, true)
const note = this.listen(this.ports.note)
const velocity = this.listen(this.ports.velocity, true)
const length = this.listen(this.ports.length, true)
const rawlsb = this.listen(this.ports.lsb, true)
const lsb = Math.ceil((127 * rawlsb) / 35)
const rawmsb = this.listen(this.ports.msb, true)
const msb = Math.ceil((127 * rawmsb) / 35)

client.io.midi.push(channel, octave, note, velocity, length)
client.io.cc.stack.push({ channel, lsb, msb, type: 'pb' })

this.draw = false

if (force === true) {
client.io.midi.run()
client.io.cc.run()
}

this.draw = false
}
}

Expand Down Expand Up @@ -669,36 +700,6 @@ library['='] = function OperatorOsc (orca, x, y, passive) {
}
}

library['?'] = function OperatorPB (orca, x, y) {
Operator.call(this, orca, x, y, '?', true)

this.name = 'cc'
this.info = 'Sends MIDI pitch bend'
this.ports.channel = { x: 1, y: 0, clamp: { min: 0, max: 15 } }
this.ports.lsb = { x: 2, y: 0, clamp: { min: 0 } }
this.ports.msb = { x: 3, y: 0, clamp: { min: 0 } }

this.operation = function (force = false) {
if (!this.hasNeighbor('*') && force === false) { return }
if (this.listen(this.ports.channel) === '.') { return }
if (this.listen(this.ports.lsb) === '.') { return }

const channel = this.listen(this.ports.channel, true)
const rawlsb = this.listen(this.ports.lsb, true)
const lsb = Math.ceil((127 * rawlsb) / 35)
const rawmsb = this.listen(this.ports.msb, true)
const msb = Math.ceil((127 * rawmsb) / 35)

client.io.cc.stack.push({ channel, lsb, msb, type: 'pb' })

this.draw = false

if (force === true) {
client.io.cc.run()
}
}
}

library[';'] = function OperatorUdp (orca, x, y, passive) {
Operator.call(this, orca, x, y, ';', true)

Expand Down
Binary file added favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<head>
<meta charset='utf-8'>
<link rel="stylesheet" type="text/css" href="desktop/sources/links/style.css"/>
<link rel="icon" href="data:">
<link rel="manifest" href="manifest.json">
<link rel="icon" href="favicon.ico">

<script type="text/javascript">function require(name){ console.warn('Failed to require '+name) }</script>

Expand Down
4 changes: 2 additions & 2 deletions sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ self.addEventListener('install', async function () {
const cache = await caches.open('Orca')
assets.forEach(function (asset) {
cache.add(asset).catch(function () {
console.error('[SW] Cound\'t cache:', asset)
console.error('serviceWorker','Cound not cache:', asset)
})
})
})
Expand All @@ -46,7 +46,7 @@ self.addEventListener('fetch', async function (event) {
async function cacheFirst (request) {
const cachedResponse = await caches.match(request)
if (cachedResponse === undefined) {
console.error('[SW] Not cached:', request.url)
console.error('serviceWorker','Not cached:', request.url)
return fetch(request)
}
return cachedResponse
Expand Down

0 comments on commit 9c7e9a5

Please sign in to comment.