This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ASoundParameter.qml
65 lines (57 loc) · 1.88 KB
/
ASoundParameter.qml
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
import QtQuick 2.0
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "ByteList.js" as ByteList
ColumnLayout {
id: root
property var eeParameterData
RowLayout {
AIntParameter {
id: ticks
eeParameterData: root.eeParameterData.ticks
}
}
RowLayout {
visible: ByteList.toInt(ticks.getParameterValue()) > 0
ColumnLayout {
Repeater {
id: repeaterPWM
model: ByteList.toInt(ticks.getParameterValue())
ARealParameter {
eeParameterData: root.eeParameterData.pwm
}
}
}
ColumnLayout {
Repeater {
id: repeaterDuration
model: ByteList.toInt(ticks.getParameterValue())
ARealParameter {
eeParameterData: root.eeParameterData.duration
}
}
}
}
function getParameterValue() {
var tc = ByteList.toInt(ticks.getParameterValue())
var vals = []
for (var t = 0; t < tc; t++) {
var valsPWM = repeaterPWM.itemAt(t).getParameterValue()
vals = vals.concat(ByteList.zeroPad(valsPWM, 2))
var valsDuration = repeaterDuration.itemAt(t).getParameterValue()
vals = vals.concat(ByteList.zeroPad(valsDuration, 2))
}
vals = vals.concat([0,0,0,0])
return vals
}
function setParameterValue(vals) {
var tc = 0
while (tc * 4 < vals.length && ByteList.toInt(vals.slice(tc * 4 + 2, tc * 4 + 4)) !== 0)
tc++
ticks.setParameterValue(ByteList.fromInt(tc))
for (var t = 0; t < tc; t++) {
repeaterPWM.itemAt(t).setParameterValue(vals.slice(t * 4, t * 4 + 2))
repeaterDuration.itemAt(t).setParameterValue(vals.slice(t * 4 + 2, t * 4 + 4))
}
}
}