-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
62 lines (50 loc) · 1.73 KB
/
main.js
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
const path = require('path');
var namespace = 'QuickStart.Core'
var version = '6.0-windows10.0.19041.0'
const baseNetAppPath = path.join(__dirname, '/src/' + namespace + '/bin/Debug/net' + version)
process.env.EDGE_USE_CORECLR = 1;
var edge = require('edge-js');
var baseDll = path.join(baseNetAppPath, namespace + '.dll');
var localTypeName = namespace + '.LocalMethods';
// Read Assembly
var midiHandle = edge.func({
assemblyFile: baseDll,
typeName: localTypeName,
methodName: 'PlayMidi'
});
// Logs exception : 'Midi not open. Please call with param: { openMidi : true }'
try {
midiHandle({ delay: 2000, note: 70, isOn: true }, function (error, result) {
if (error) throw error;
console.log(result);
});
} catch (e) {
console.log('.NET Exception: ' + e.Message);
}
// Await device select and add to midi out port
midiHandle({ openMidi: true }, function (error, result) {
if (error) throw error;
console.log(result);
// Play note
midiHandle({ delay: 2000, note: 70, isOn: true }, function (error, result) {
if (error) throw error;
console.log(result);
});
// Play next note 500 ms later
setTimeout(() => {
// Stop previous pote
midiHandle({ delay: 0, note: 70, isOn: false }, function (error, result) {
if (error) throw error;
console.log(result);
});
// Play notes
midiHandle({ delay: 2000, note: 80, isOn: true }, function (error, result) {
if (error) throw error;
console.log(result);
});
midiHandle({ delay: 2000, note: 50, isOn: true }, function (error, result) {
if (error) throw error;
console.log(result);
});
}, 500)
});