-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_real_audio_integration.qml
More file actions
197 lines (166 loc) · 6.44 KB
/
Copy pathtest_real_audio_integration.qml
File metadata and controls
197 lines (166 loc) · 6.44 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/usr/bin/env qml
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import LibVisualBackend 1.0
ApplicationWindow {
id: window
width: 800
height: 600
title: "Real Audio Backend Integration Test"
visible: true
property real testSensitivity: 1.0
LibVisualBackend {
id: backend
Component.onCompleted: {
console.log("=== Real Audio Backend Integration Test ===")
console.log("Backend initialized successfully!")
console.log("FFT Size:", fftSize)
console.log("Initial audio active:", audioActive)
console.log("Initial decibels:", decibels)
console.log("Spectrum array length:", spectrum.length)
}
onAudioActiveChanged: {
console.log("Audio active state changed:", audioActive)
statusText.text = audioActive ? "AUDIO ACTIVE" : "AUDIO INACTIVE"
statusText.color = audioActive ? "green" : "red"
}
onDecibelsChanged: {
if (Math.random() < 0.05) { // Log 5% of the time
console.log("Audio level:", decibels.toFixed(1), "dB")
}
}
}
// Main test interface
ColumnLayout {
anchors.fill: parent
anchors.margins: 20
Text {
id: statusText
text: "INITIALIZING..."
font.pointSize: 24
font.bold: true
color: "blue"
Layout.alignment: Qt.AlignHCenter
}
GroupBox {
title: "Backend Status"
Layout.fillWidth: true
GridLayout {
columns: 2
anchors.fill: parent
Label { text: "FFT Size:" }
Label { text: backend.fftSize }
Label { text: "Audio Active:" }
Label {
text: backend.audioActive ? "YES" : "NO"
color: backend.audioActive ? "green" : "red"
font.bold: true
}
Label { text: "Decibels:" }
Label {
text: backend.decibels.toFixed(1) + " dB"
color: backend.decibels > -50 ? "green" : "gray"
}
Label { text: "Spectrum Bins:" }
Label { text: backend.spectrum.length }
}
}
GroupBox {
title: "Audio Level Simulation (like main wallpaper)"
Layout.fillWidth: true
GridLayout {
columns: 2
anchors.fill: parent
Label { text: "Audio Peak:" }
Label {
property real audioPeak: backend.audioActive ?
Math.max(0.1, (backend.decibels + 60) / 60 * testSensitivity) : 0.1
text: audioPeak.toFixed(2)
color: "orange"
}
Label { text: "Bass Level (0-15):" }
Label {
property real bassLevel: getBandLevel(0, 15)
text: bassLevel.toFixed(2)
color: "red"
}
Label { text: "Mid Level (16-39):" }
Label {
property real midLevel: getBandLevel(16, 39)
text: midLevel.toFixed(2)
color: "yellow"
}
Label { text: "Treble Level (40-63):" }
Label {
property real trebleLevel: getBandLevel(40, 63)
text: trebleLevel.toFixed(2)
color: "cyan"
}
}
}
GroupBox {
title: "Real-time Spectrum Preview"
Layout.fillWidth: true
Layout.fillHeight: true
Rectangle {
anchors.fill: parent
color: "black"
Row {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
spacing: 2
Repeater {
model: Math.min(32, backend.spectrum.length)
Rectangle {
width: 10
height: Math.max(5, (backend.spectrum[index] || 0) * 200 * testSensitivity)
color: index < 8 ? "red" : index < 16 ? "yellow" : index < 24 ? "green" : "cyan"
Text {
anchors.bottom: parent.bottom
anchors.bottomMargin: -15
text: index
color: "white"
font.pointSize: 8
}
}
}
}
}
}
RowLayout {
Label { text: "Test Sensitivity:" }
Slider {
from: 0.1
to: 3.0
value: testSensitivity
onValueChanged: testSensitivity = value
Layout.fillWidth: true
}
Label { text: testSensitivity.toFixed(1) }
}
Button {
text: "Generate Test Audio Instructions"
Layout.alignment: Qt.AlignHCenter
onClicked: {
console.log("=== To test audio capture ===")
console.log("1. Play music or speak into microphone")
console.log("2. Watch for 'Audio Active' to turn green")
console.log("3. Observe spectrum bars responding to audio")
console.log("4. Check decibel levels changing above -50 dB")
}
}
}
function getBandLevel(startBin, endBin) {
if (!backend.audioActive || !backend.spectrum || backend.spectrum.length === 0) {
return 0.1
}
let sum = 0
let count = 0
for (let i = startBin; i <= endBin && i < backend.spectrum.length; i++) {
sum += backend.spectrum[i] || 0
count++
}
return count > 0 ? Math.max(0.1, (sum / count) * testSensitivity) : 0.1
}
}