forked from teotigraphix/OSC4Bitwig
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.js
More file actions
80 lines (63 loc) · 2.18 KB
/
Config.js
File metadata and controls
80 lines (63 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// ------------------------------
// Static configurations
// ------------------------------
// Inc/Dec of knobs
Config.fractionValue = 1;
Config.fractionMinValue = 0.5;
Config.maxParameterValue = 128;
// ------------------------------
// Editable configurations
// ------------------------------
Config.RECEIVE_HOST = 0;
Config.RECEIVE_PORT = 1;
Config.SEND_HOST = 2;
Config.SEND_PORT = 3;
Config.receiveHost = '127.0.0.1';
Config.receivePort = 8000;
Config.sendHost = '127.0.0.1';
Config.sendPort = 9000;
Config.init = function ()
{
var prefs = host.getPreferences ();
Config.receiveHostSetting = prefs.getStringSetting ('Host', 'Receive from (Script restart required)', 15, '127.0.0.1');
Config.receiveHostSetting.addValueObserver (function (value)
{
Config.receiveHost = value;
Config.notifyListeners (Config.RECEIVE_HOST);
});
Config.receivePortSetting = prefs.getNumberSetting ('Port', 'Receive from (Script restart required)', 0, 65535, 1, '', 8000);
Config.receivePortSetting.addRawValueObserver (function (value)
{
Config.receivePort = Math.floor (value);
Config.notifyListeners (Config.RECEIVE_PORT);
});
Config.sendHostSetting = prefs.getStringSetting ('Host', 'Send to', 15, '127.0.0.1');
Config.sendHostSetting.addValueObserver (function (value)
{
Config.sendHost = value;
Config.notifyListeners (Config.SEND_HOST);
});
Config.sendPortSetting = prefs.getNumberSetting ('Port', 'Send to', 0, 65535, 1, '', 9000);
Config.sendPortSetting.addRawValueObserver (function (value)
{
Config.sendPort = Math.floor (value);
Config.notifyListeners (Config.SEND_PORT);
});
};
// ------------------------------
// Property listeners
// ------------------------------
Config.listeners = [];
for (var i = 0; i <= Config.SEND_PORT; i++)
Config.listeners[i] = [];
Config.addPropertyListener = function (property, listener)
{
Config.listeners[property].push (listener);
};
Config.notifyListeners = function (property)
{
var ls = Config.listeners[property];
for (var i = 0; i < ls.length; i++)
ls[i].call (null);
};
function Config () {}