Debian Codegraph @

src/ui/main.qml

raw
1 import QtQuick 2.7
2 import QtQuick.Layouts 1.3
3 import QtQuick.Controls 2.0
4 import QtQuick.Dialogs 1.2
5
6 import sfxr 1.0
7
8 ApplicationWindow {
9 id: root
10 visible: true
11 minimumHeight: 700
12 minimumWidth: leftColumn.width + mainContent.implicitWidth + fileActions.width + 2 * margin
13
14 property real margin: 12
15 property real sideColumnWidth: 200
16 property real columnWidth: 350
17 property Sound sound: {
18 var row = soundListView.currentIndex;
19 row >= 0 ? soundListModel.soundForRow(row) : null;
20 }
21
22 SoundPlayer {
23 id: soundPlayer
24 sound: root.sound
25 }
26
27 SoundListModel {
28 id: soundListModel
29 }
30
31 Generator {
32 id: generator
33 onSoundGenerated: {
34 soundListModel.addNew(sound);
35 soundListView.currentIndex = 0;
36 }
37 }
38
39 Item {
40 id: rootItem
41 anchors.fill: parent
42 ColumnLayout {
43 id: leftColumn
44 anchors {
45 left: parent.left
46 top: parent.top
47 bottom: parent.bottom
48 }
49 width: sideColumnWidth
50
51 Generators {
52 id: generators
53 generator: generator
54 sound: root.sound
55 }
56
57 VerticalSpacer {}
58
59 SoundListView {
60 id: soundListView
61 model: soundListModel
62 Layout.fillWidth: true
63 Layout.fillHeight: true
64 onCurrentSoundClicked: {
65 soundPlayer.play();
66 }
67 }
68 }
69
70 ColumnLayout {
71 id: mainContent
72 anchors {
73 left: leftColumn.right
74 right: fileActions.left
75 top: parent.top
76 bottom: parent.bottom
77 leftMargin: margin
78 rightMargin: margin
79 }
80 Layout.minimumWidth: implicitWidth
81
82 RowLayout {
83 id: waveFormRow
84 spacing: 12
85 Layout.alignment: Qt.AlignHCenter
86 Label {
87 text: qsTr("Wave form")
88 }
89 WaveFormSelector {
90 sound: root.sound
91 }
92 }
93
94 SoundPreview {
95 soundPlayer: soundPlayer
96 Layout.fillWidth: true
97 Layout.fillHeight: true
98 Layout.maximumHeight: parent.height / 4
99 }
100
101 VerticalSpacer {}
102
103 Row {
104 spacing: margin * 2
105
106 Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
107
108 ColumnLayout {
109 width: root.columnWidth
110
111 SliderGroup {
112 Layout.fillWidth: true
113 text: qsTr("Envelop")
114 sound: root.sound
115 model: ListModel {
116 ListElement {
117 text: qsTr("Attack time")
118 soundProperty: "attackTime"
119 }
120 ListElement {
121 text: qsTr("Sustain time")
122 soundProperty: "sustainTime"
123 }
124 ListElement {
125 text: qsTr("Sustain punch")
126 soundProperty: "sustainPunch"
127 }
128 ListElement {
129 text: qsTr("Decay time")
130 soundProperty: "decayTime"
131 }
132 }
133 }
134
135 SliderGroup {
136 Layout.fillWidth: true
137 text: qsTr("Frequency")
138 sound: root.sound
139 model: ListModel {
140 ListElement {
141 text: qsTr("Start frequency")
142 soundProperty: "baseFrequency"
143 }
144 ListElement {
145 text: qsTr("Min frequency")
146 soundProperty: "minFrequency"
147 }
148 ListElement {
149 text: qsTr("Slide")
150 soundProperty: "slide"
151 bipolar: true
152 }
153 ListElement {
154 text: qsTr("Delta slide")
155 soundProperty: "deltaSlide"
156 bipolar: true
157 }
158 ListElement {
159 text: qsTr("Vibrato depth")
160 soundProperty: "vibratoDepth"
161 }
162 ListElement {
163 text: qsTr("Vibrato speed")
164 soundProperty: "vibratoSpeed"
165 }
166 }
167 }
168
169 SliderGroup {
170 Layout.fillWidth: true
171 text: qsTr("Change")
172 sound: root.sound
173 model: ListModel {
174 ListElement {
175 text: qsTr("Change amount")
176 soundProperty: "changeAmount"
177 bipolar: true
178 }
179 ListElement {
180 text: qsTr("Change speed")
181 soundProperty: "changeSpeed"
182 }
183 }
184 }
185 }
186
187 ColumnLayout {
188 width: root.columnWidth
189
190 SliderGroup {
191 Layout.fillWidth: true
192 enabled: Number(sound.waveForm) === WaveForm.Square
193 text: qsTr("Square")
194 sound: root.sound
195 model: ListModel {
196 ListElement {
197 text: qsTr("Square duty")
198 soundProperty: "squareDuty"
199 }
200 ListElement {
201 text: qsTr("Duty sweep")
202 soundProperty: "dutySweep"
203 bipolar: true
204 }
205 }
206 }
207
208 SliderGroup {
209 Layout.fillWidth: true
210 text: qsTr("Repeat")
211 sound: root.sound
212 model: ListModel {
213 ListElement {
214 text: qsTr("Repeat speed")
215 soundProperty: "repeatSpeed"
216 }
217 }
218 }
219
220 SliderGroup {
221 Layout.fillWidth: true
222 text: qsTr("Phaser")
223 sound: root.sound
224 model: ListModel {
225 ListElement {
226 text: qsTr("Phaser offset")
227 soundProperty: "phaserOffset"
228 bipolar: true
229 }
230 ListElement {
231 text: qsTr("Phaser sweep")
232 soundProperty: "phaserSweep"
233 bipolar: true
234 }
235 }
236 }
237
238 SliderGroup {
239 Layout.fillWidth: true
240 text: qsTr("Filters")
241 sound: root.sound
242 model: ListModel {
243 ListElement {
244 text: qsTr("LP filter cutoff")
245 soundProperty: "lpFilterCutoff"
246 }
247 ListElement {
248 text: qsTr("LP filter cutoff sweep")
249 soundProperty: "lpFilterCutoffSweep"
250 bipolar: true
251 }
252 ListElement {
253 text: qsTr("LP filter resonance")
254 soundProperty: "lpFilterResonance"
255 }
256 ListElement {
257 text: qsTr("HP filter cutoff")
258 soundProperty: "hpFilterCutoff"
259 }
260 ListElement {
261 text: qsTr("HP filter cutoff sweep")
262 soundProperty: "hpFilterCutoffSweep"
263 bipolar: true
264 }
265 }
266 }
267
268 SliderGroup {
269 Layout.fillWidth: true
270 text: qsTr("Others")
271 sound: root.sound
272 model: ListModel {
273 ListElement {
274 text: qsTr("Volume")
275 soundProperty: "volume"
276 }
277 }
278 }
279 }
280 }
281
282 PlayBar {
283 Layout.alignment: Qt.AlignHCenter
284 soundPlayer: soundPlayer
285 }
286 }
287
288 FileActions {
289 id: fileActions
290 sound: root.sound
291 anchors {
292 right: parent.right
293 top: parent.top
294 }
295 width: sideColumnWidth
296 }
297 }
298
299 function loadSound(url) {
300 fileActions.loadSound(url);
301 }
302 }