Skip to content

Commit 1f8a10e

Browse files
authored
Introduces Sibelius macros (#8)
* Support for using shorthand `plugin:` and `command:` for sending commands to sibelius * new /SibeliusConnect script for creating macros of arbitrary commands/plugins * Correctly parse leftover args in a plugin string command (/SibeliusConnect/plugin PluginName,Method,true,"string") and refactor Sibelius keypad and commands/plugins into separate tabs * Added macro examples from Bob Zawalich's docs: https://bobzawalich.com/wp-content/uploads/2021/08/Some-Current-Sibelius-Command-Macros.pdf * renaming variable widgets * renaming linkId and default osc paths
1 parent cd04bff commit 1f8a10e

File tree

3 files changed

+1201
-47
lines changed

3 files changed

+1201
-47
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ Enjoy!
3131
- (Dorico) a Dorico JSON message or an array of Dorico JSON messages
3232
- `osc`
3333
- `address`: enter one of:
34-
- `/SibeliusConnect/command` to send Command IDs
35-
- `/SibeliusConnect/plugin` to invoke a plugin **
36-
- `/SibeliusConnect` to send a raw Sibelius Connect message (per the [Sibelius Manuscript Reference Documentation](https://resources.avid.com/SupportFiles/Sibelius/2024.10/ManuScript_Language_Guide.pdf])) ***
37-
- `/DoricoRemote` to send a request to Dorico
34+
- `/SibeliusConnect/command` if sending Command IDs
35+
- `/SibeliusConnect/plugin` if invoking a plugin **
36+
- `/SibeliusConnect` if sending a raw Sibelius Connect JSON message (per the [Sibelius Manuscript Reference Documentation](https://resources.avid.com/SupportFiles/Sibelius/2024.10/ManuScript_Language_Guide.pdf])) ***
37+
- `/DoricoRemote` if sending a request to Dorico
3838
- `send`: `localhost:8080`
3939

4040
_** NOTE: if executing Sibelius plugins, the plugin name **MUST** be added to the SibeliusConnect websocket instance in `customModule.js` BEFORE starting OpenStageControl, i.e.:_

customModule.js

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const DoricoRemote = require('DoricoRemote.js')
77
module.exports = {
88

99
init: function() {
10-
global.SibeliusConnect = new SibeliusConnect()
10+
global.SibeliusConnect = new SibeliusConnect({ plugins: ['cmdutils'] })
1111
// global.SibeliusConnect.connect()
1212

1313
global.DoricoRemote = new DoricoRemote()
@@ -23,41 +23,46 @@ module.exports = {
2323
// passthru "off"/0 messages
2424
return data
2525
}
26-
27-
if (address === '/SibeliusConnect') {
28-
args.forEach(arg => {
29-
const msg = JSON.parse(arg.value)
30-
global.SibeliusConnect.send(msg)
31-
})
32-
}
33-
else if (path.dirname(address) === '/SibeliusConnect') {
34-
if (path.basename(address) === 'command') {
35-
const commands = args
36-
.reduce((acc, cur) => [...acc, ...cur.value.split(',')], [])
37-
.map(value => value.trim())
38-
global.SibeliusConnect.send({
39-
'message': 'invokeCommands',
40-
'commands': commands
41-
});
42-
}
43-
else if (path.basename(address) === 'plugin') {
44-
args.forEach(arg => {
45-
const plugin = arg.value[0] === '{' ? JSON.parse(arg.value) : { name: arg.value }
46-
const msg = {
47-
'message' : 'invokePlugin',
48-
'name': plugin.name
49-
}
50-
if (plugin.method) {
51-
msg.method = plugin.method
52-
}
53-
if (plugin.args) {
54-
msg.args = plugin.args
26+
27+
if (address === '/sibelius' || path.dirname(address) === '/sibelius') {
28+
args.map(arg => {
29+
let addr = address
30+
arg = arg.value
31+
32+
if (arg.startsWith('command:') || arg.startsWith('plugin:')) {
33+
addr = arg.substring(0,arg.indexOf(':'))
34+
arg = arg.substring(arg.indexOf(':') + 1)
35+
}
36+
37+
let msg = arg.startsWith('{') ? JSON.parse(arg) : {}
38+
39+
if (path.basename(addr) === 'command') {
40+
msg.message = 'invokeCommands'
41+
msg.commands = arg.split(',').map(v => v.trim())
42+
}
43+
else if (path.basename(addr) === 'plugin') {
44+
msg.message = 'invokePlugin'
45+
if (!msg.name || msg.name === '') {
46+
const [pluginName, method, ...methodArgs] = arg.split(',')
47+
msg.name = pluginName
48+
if (method) {
49+
msg.method = method
50+
}
51+
if (methodArgs && methodArgs.length > 0) {
52+
msg.args = JSON.parse(`[${methodArgs.join(',').replace(/\\/g, "\\\\")}]`)
53+
}
5554
}
56-
global.SibeliusConnect.send(msg);
57-
})
58-
}
55+
}
56+
57+
return msg
58+
})
59+
.reduce(async (a, msg) => {
60+
await a
61+
global.SibeliusConnect.sendMessage(msg)
62+
return new Promise(resolve => setTimeout(resolve, 50));
63+
}, Promise.resolve())
5964
}
60-
else if (address === '/DoricoRemote') {
65+
else if (address === '/dorico') {
6166
args.forEach(arg => {
6267
global.DoricoRemote.send(JSON.parse(arg.value))
6368
})

0 commit comments

Comments
 (0)