Nirav Madhani commited on
Commit
ad9551d
·
1 Parent(s): 49d9ff1

Updated WebUI

Browse files
Files changed (1) hide show
  1. index.html +32 -23
index.html CHANGED
@@ -126,7 +126,8 @@
126
  </div>
127
  </div>
128
  <div style="margin-top: 1em; display: flex; gap: 0.5em;">
129
- <input type="text" id="textMessage" placeholder="Type your message here" style="flex: 1; padding: 0.5em; border: 1px solid #ddd; border-radius: 3px;" />
 
130
  <button onclick="sendText()" style="white-space: nowrap;">
131
  <span style="margin-right: 0.3em;">📤</span> Send
132
  </button>
@@ -140,9 +141,9 @@
140
 
141
  <div style="margin: 1em 0;">
142
  <strong>Log Settings:</strong><br>
143
- <label><input type="checkbox" id="logWebSocket" checked> WebSocket Events</label>
144
- <label style="margin-left: 1em"><input type="checkbox" id="logAudio" checked> Audio Events</label>
145
- <label style="margin-left: 1em"><input type="checkbox" id="logText" checked> Text Events</label>
146
  <label style="margin-left: 1em"><input type="checkbox" id="logError" checked> Error Events</label>
147
  </div>
148
 
@@ -250,7 +251,10 @@
250
 
251
  if (!analyser && playbackCtx) {
252
  analyser = playbackCtx.createAnalyser();
253
- analyser.fftSize = 2048;
 
 
 
254
  }
255
  }
256
 
@@ -259,34 +263,39 @@
259
 
260
  const bufferLength = analyser.frequencyBinCount;
261
  const dataArray = new Uint8Array(bufferLength);
262
- analyser.getByteTimeDomainData(dataArray);
263
 
264
  visualizerCtx.fillStyle = '#f0f0f0';
265
  visualizerCtx.fillRect(0, 0, visualizerCanvas.width, visualizerCanvas.height);
266
 
267
- visualizerCtx.lineWidth = 2;
268
- visualizerCtx.strokeStyle = '#4caf50';
269
- visualizerCtx.beginPath();
270
-
271
- const sliceWidth = visualizerCanvas.width / bufferLength;
272
  let x = 0;
273
 
274
  for (let i = 0; i < bufferLength; i++) {
275
- const v = dataArray[i] / 128.0;
276
- const y = v * visualizerCanvas.height / 2;
277
-
278
- if (i === 0) {
279
- visualizerCtx.moveTo(x, y);
280
- } else {
281
- visualizerCtx.lineTo(x, y);
282
- }
 
 
 
 
 
 
 
 
 
 
 
283
 
284
- x += sliceWidth;
285
  }
286
 
287
- visualizerCtx.lineTo(visualizerCanvas.width, visualizerCanvas.height / 2);
288
- visualizerCtx.stroke();
289
-
290
  animationFrame = requestAnimationFrame(drawVisualizer);
291
  }
292
 
 
126
  </div>
127
  </div>
128
  <div style="margin-top: 1em; display: flex; gap: 0.5em;">
129
+ <input type="text" id="textMessage" placeholder="Type your message here" style="flex: 1; padding: 0.5em; border: 1px solid #ddd; border-radius: 3px;"
130
+ onkeydown="if(event.key === 'Enter') { event.preventDefault(); sendText(); }" />
131
  <button onclick="sendText()" style="white-space: nowrap;">
132
  <span style="margin-right: 0.3em;">📤</span> Send
133
  </button>
 
141
 
142
  <div style="margin: 1em 0;">
143
  <strong>Log Settings:</strong><br>
144
+ <label><input type="checkbox" id="logWebSocket"> WebSocket Events</label>
145
+ <label style="margin-left: 1em"><input type="checkbox" id="logAudio"> Audio Events</label>
146
+ <label style="margin-left: 1em"><input type="checkbox" id="logText"> Text Events</label>
147
  <label style="margin-left: 1em"><input type="checkbox" id="logError" checked> Error Events</label>
148
  </div>
149
 
 
251
 
252
  if (!analyser && playbackCtx) {
253
  analyser = playbackCtx.createAnalyser();
254
+ analyser.fftSize = 256; // Reduced for wider bars
255
+ analyser.minDecibels = -90;
256
+ analyser.maxDecibels = -10;
257
+ analyser.smoothingTimeConstant = 0.85;
258
  }
259
  }
260
 
 
263
 
264
  const bufferLength = analyser.frequencyBinCount;
265
  const dataArray = new Uint8Array(bufferLength);
266
+ analyser.getByteFrequencyData(dataArray);
267
 
268
  visualizerCtx.fillStyle = '#f0f0f0';
269
  visualizerCtx.fillRect(0, 0, visualizerCanvas.width, visualizerCanvas.height);
270
 
271
+ const barWidth = (visualizerCanvas.width / bufferLength) * 2.5;
272
+ const centerY = visualizerCanvas.height / 2;
 
 
 
273
  let x = 0;
274
 
275
  for (let i = 0; i < bufferLength; i++) {
276
+ const barHeight = (dataArray[i] / 255) * (visualizerCanvas.height / 2); // Half height for centering
277
+
278
+ // Create gradient for top half (going up)
279
+ const gradientTop = visualizerCtx.createLinearGradient(0, centerY, 0, centerY - barHeight);
280
+ gradientTop.addColorStop(0, '#4caf50'); // Green at center
281
+ gradientTop.addColorStop(1, '#81c784'); // Lighter green at top
282
+
283
+ // Create gradient for bottom half (going down)
284
+ const gradientBottom = visualizerCtx.createLinearGradient(0, centerY, 0, centerY + barHeight);
285
+ gradientBottom.addColorStop(0, '#4caf50'); // Green at center
286
+ gradientBottom.addColorStop(1, '#81c784'); // Lighter green at bottom
287
+
288
+ // Draw top half of the bar
289
+ visualizerCtx.fillStyle = gradientTop;
290
+ visualizerCtx.fillRect(x, centerY - barHeight, barWidth, barHeight);
291
+
292
+ // Draw bottom half of the bar
293
+ visualizerCtx.fillStyle = gradientBottom;
294
+ visualizerCtx.fillRect(x, centerY, barWidth, barHeight);
295
 
296
+ x += barWidth + 1; // Add 1 pixel gap between bars
297
  }
298
 
 
 
 
299
  animationFrame = requestAnimationFrame(drawVisualizer);
300
  }
301