-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathharm-VoiceSorter.js
More file actions
54 lines (48 loc) · 1001 Bytes
/
harm-VoiceSorter.js
File metadata and controls
54 lines (48 loc) · 1001 Bytes
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
var voices = [];
var currentPitch = undefined;
var currentPreset = { name: "new preset", mapping: {} };
outlets = 2;
function bang() {
var first = voices[0];
var arr = voices.map(function (v) {
if (v === null) {
return 0;
} else {
return v - first;
}
});
outlet(0, arr);
}
function msg_int(pitch) {
currentPitch = pitch;
var chord = currentPreset.mapping[pitch];
if (chord) {
var first = chord[0];
var arr = chord.map(function (v) {
if (v === null) {
return 0;
} else {
return v - first;
}
});
outlet(0, 0, 0, 0, 0);
outlet(0, arr);
} else {
outlet(0, 0, 0, 0, 0);
}
}
function list() {
const arr = arrayfromargs(arguments);
const vel = arr[2];
const pitch = arr[1];
const voice = arr[0];
if (vel == 0) {
voices[voice - 1] = null;
} else {
voices[voice - 1] = pitch;
currentPreset.mapping[currentPitch] = voices.map(function (v) {
return v;
});
}
bang();
}