Joe-C-Wales commited on
Commit
0540ef6
·
verified ·
1 Parent(s): 9bd30cb

Can you generate a funtion that can generate 3d viewable of the notes across distances or even a simplwe way to view the notes in this new position>

Browse files
Files changed (4) hide show
  1. index.html +2 -1
  2. quantum.html +2 -1
  3. synthesizer.html +2 -1
  4. visualization.html +324 -0
index.html CHANGED
@@ -52,9 +52,10 @@
52
  <li><a href="index.html" class="hover:text-purple-300">Home</a></li>
53
  <li><a href="synthesizer.html" class="hover:text-purple-300">Synthesizer</a></li>
54
  <li><a href="quantum.html" class="hover:text-purple-300">Quantum</a></li>
 
55
  </ul>
56
  </nav>
57
- </div>
58
  </header>
59
 
60
  <!-- Hero Section -->
 
52
  <li><a href="index.html" class="hover:text-purple-300">Home</a></li>
53
  <li><a href="synthesizer.html" class="hover:text-purple-300">Synthesizer</a></li>
54
  <li><a href="quantum.html" class="hover:text-purple-300">Quantum</a></li>
55
+ <li><a href="visualization.html" class="hover:text-purple-300">Visualization</a></li>
56
  </ul>
57
  </nav>
58
+ </div>
59
  </header>
60
 
61
  <!-- Hero Section -->
quantum.html CHANGED
@@ -70,9 +70,10 @@
70
  <li><a href="index.html" class="hover:text-purple-300">Home</a></li>
71
  <li><a href="synthesizer.html" class="hover:text-purple-300">Synthesizer</a></li>
72
  <li><a href="quantum.html" class="hover:text-purple-300">Quantum</a></li>
 
73
  </ul>
74
  </nav>
75
- </div>
76
  </header>
77
 
78
  <!-- Quantum Operations Section -->
 
70
  <li><a href="index.html" class="hover:text-purple-300">Home</a></li>
71
  <li><a href="synthesizer.html" class="hover:text-purple-300">Synthesizer</a></li>
72
  <li><a href="quantum.html" class="hover:text-purple-300">Quantum</a></li>
73
+ <li><a href="visualization.html" class="hover:text-purple-300">Visualization</a></li>
74
  </ul>
75
  </nav>
76
+ </div>
77
  </header>
78
 
79
  <!-- Quantum Operations Section -->
synthesizer.html CHANGED
@@ -60,9 +60,10 @@
60
  <li><a href="index.html" class="hover:text-purple-300">Home</a></li>
61
  <li><a href="synthesizer.html" class="hover:text-purple-300">Synthesizer</a></li>
62
  <li><a href="quantum.html" class="hover:text-purple-300">Quantum</a></li>
 
63
  </ul>
64
  </nav>
65
- </div>
66
  </header>
67
 
68
  <!-- Synthesizer Section -->
 
60
  <li><a href="index.html" class="hover:text-purple-300">Home</a></li>
61
  <li><a href="synthesizer.html" class="hover:text-purple-300">Synthesizer</a></li>
62
  <li><a href="quantum.html" class="hover:text-purple-300">Quantum</a></li>
63
+ <li><a href="visualization.html" class="hover:text-purple-300">Visualization</a></li>
64
  </ul>
65
  </nav>
66
+ </div>
67
  </header>
68
 
69
  <!-- Synthesizer Section -->
visualization.html ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>3D Visualization - Quantum Music</title>
7
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="https://cdn.jsdelivr.net/npm/animejs/lib/anime.iife.min.js"></script>
11
+ <script src="https://unpkg.com/feather-icons"></script>
12
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
13
+ <style>
14
+ .quantum-bg {
15
+ background: linear-gradient(135deg, #6e45e2, #88d3ce);
16
+ background-size: 400% 400%;
17
+ animation: gradient 15s ease infinite;
18
+ }
19
+ @keyframes gradient {
20
+ 0% { background-position: 0% 50%; }
21
+ 50% { background-position: 100% 50%; }
22
+ 100% { background-position: 0% 50%; }
23
+ }
24
+ .hovered-element {
25
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
26
+ }
27
+ .hovered-element:hover {
28
+ transform: translateY(-5px);
29
+ box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
30
+ }
31
+ .stylized-font {
32
+ font-family: 'Arial Rounded MT Bold', 'Helvetica Rounded', Arial, sans-serif;
33
+ letter-spacing: 1px;
34
+ }
35
+ #visualization-container {
36
+ width: 100%;
37
+ height: 500px;
38
+ background: rgba(0, 0, 0, 0.3);
39
+ border-radius: 8px;
40
+ position: relative;
41
+ overflow: hidden;
42
+ }
43
+ .controls {
44
+ background: rgba(31, 41, 55, 0.7);
45
+ border-radius: 8px;
46
+ padding: 1rem;
47
+ }
48
+ .note-info {
49
+ background: rgba(31, 41, 55, 0.7);
50
+ border-radius: 8px;
51
+ padding: 1rem;
52
+ min-height: 100px;
53
+ }
54
+ </style>
55
+ </head>
56
+ <body class="bg-gray-900 text-white min-h-screen">
57
+ <div class="quantum-bg min-h-screen hovered-element">
58
+ <!-- Header -->
59
+ <header class="container mx-auto py-6 px-4 hovered-element">
60
+ <div class="flex justify-between items-center">
61
+ <h1 class="text-3xl font-bold stylized-font">Quantum Music Synthesizer</h1>
62
+ <nav>
63
+ <ul class="flex space-x-6">
64
+ <li><a href="index.html" class="hover:text-purple-300">Home</a></li>
65
+ <li><a href="synthesizer.html" class="hover:text-purple-300">Synthesizer</a></li>
66
+ <li><a href="quantum.html" class="hover:text-purple-300">Quantum</a></li>
67
+ <li><a href="visualization.html" class="hover:text-purple-300">Visualization</a></li>
68
+ </ul>
69
+ </nav>
70
+ </div>
71
+ </header>
72
+
73
+ <!-- Visualization Section -->
74
+ <section class="container mx-auto py-16 px-4 hovered-element">
75
+ <h2 class="text-4xl font-bold text-center mb-12 stylized-font">3D Note Visualization</h2>
76
+
77
+ <div class="max-w-6xl mx-auto bg-gray-800 bg-opacity-50 rounded-xl p-8 hovered-element">
78
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-8 mb-8">
79
+ <div class="lg:col-span-2">
80
+ <div id="visualization-container"></div>
81
+ </div>
82
+ <div class="space-y-6">
83
+ <div class="controls">
84
+ <h3 class="text-xl font-bold mb-4 stylized-font">Controls</h3>
85
+ <div class="space-y-4">
86
+ <div>
87
+ <label class="block mb-2">Rotation Speed</label>
88
+ <input type="range" id="rotation-speed" min="0" max="2" step="0.1" value="0.5" class="w-full">
89
+ </div>
90
+ <div>
91
+ <label class="block mb-2">Point Size</label>
92
+ <input type="range" id="point-size" min="1" max="10" step="0.5" value="3" class="w-full">
93
+ </div>
94
+ <div>
95
+ <button id="reset-view" class="bg-purple-600 hover:bg-purple-700 text-white font-bold py-2 px-4 rounded w-full">
96
+ Reset View
97
+ </button>
98
+ </div>
99
+ </div>
100
+ </div>
101
+
102
+ <div class="note-info">
103
+ <h3 class="text-xl font-bold mb-4 stylized-font">Selected Note</h3>
104
+ <div id="note-details">
105
+ <p>Click on a note to see details</p>
106
+ </div>
107
+ </div>
108
+ </div>
109
+ </div>
110
+
111
+ <div class="mt-8">
112
+ <h3 class="text-2xl font-bold mb-4 stylized-font">Visualization Legend</h3>
113
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
114
+ <div class="bg-gray-700 p-4 rounded-lg">
115
+ <h4 class="font-bold mb-2">X-Axis: Frequency</h4>
116
+ <p>Position represents note frequency (Hz)</p>
117
+ </div>
118
+ <div class="bg-gray-700 p-4 rounded-lg">
119
+ <h4 class="font-bold mb-2">Y-Axis: Amplitude</h4>
120
+ <p>Height represents note volume</p>
121
+ </div>
122
+ <div class="bg-gray-700 p-4 rounded-lg">
123
+ <h4 class="font-bold mb-2">Z-Axis: Time</h4>
124
+ <p>Depth represents note sequence timing</p>
125
+ </div>
126
+ </div>
127
+ </div>
128
+ </div>
129
+ </section>
130
+
131
+ <!-- Footer -->
132
+ <footer class="container mx-auto py-8 px-4 text-center border-t border-gray-700">
133
+ <p>Powered by QuantumToolbox.jl, Amazon Braket, and Lindblad Solvers</p>
134
+ </footer>
135
+ </div>
136
+
137
+ <script>
138
+ feather.replace();
139
+
140
+ // Initialize Three.js scene
141
+ let scene, camera, renderer, points;
142
+ let rotationSpeed = 0.5;
143
+ let pointSize = 3;
144
+ let noteData = [];
145
+
146
+ function init() {
147
+ // Create scene
148
+ scene = new THREE.Scene();
149
+ scene.background = new THREE.Color(0x1a202c);
150
+
151
+ // Create camera
152
+ camera = new THREE.PerspectiveCamera(75,
153
+ document.getElementById('visualization-container').clientWidth /
154
+ document.getElementById('visualization-container').clientHeight,
155
+ 0.1, 1000);
156
+ camera.position.z = 30;
157
+ camera.position.y = 10;
158
+
159
+ // Create renderer
160
+ renderer = new THREE.WebGLRenderer({ antialias: true });
161
+ renderer.setSize(
162
+ document.getElementById('visualization-container').clientWidth,
163
+ document.getElementById('visualization-container').clientHeight
164
+ );
165
+ document.getElementById('visualization-container').appendChild(renderer.domElement);
166
+
167
+ // Add lighting
168
+ const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
169
+ scene.add(ambientLight);
170
+
171
+ const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
172
+ directionalLight.position.set(20, 20, 20);
173
+ scene.add(directionalLight);
174
+
175
+ // Generate sample note data
176
+ generateNoteData();
177
+
178
+ // Create 3D points
179
+ createPoints();
180
+
181
+ // Add axes helper
182
+ const axesHelper = new THREE.AxesHelper(20);
183
+ scene.add(axesHelper);
184
+
185
+ // Add event listeners
186
+ setupEventListeners();
187
+
188
+ // Start animation
189
+ animate();
190
+ }
191
+
192
+ function generateNoteData() {
193
+ // Generate sample musical sequence data
194
+ const baseNotes = [261.63, 293.66, 329.63, 349.23, 392.00, 440.00, 493.88, 523.25]; // C4 to C5
195
+ const durations = [0.5, 1.0, 1.5, 2.0];
196
+
197
+ for (let i = 0; i < 50; i++) {
198
+ noteData.push({
199
+ frequency: baseNotes[Math.floor(Math.random() * baseNotes.length)] + (Math.random() * 100),
200
+ amplitude: Math.random(),
201
+ duration: durations[Math.floor(Math.random() * durations.length)],
202
+ time: i * 0.5,
203
+ color: new THREE.Color(Math.random() * 0xffffff)
204
+ });
205
+ }
206
+ }
207
+
208
+ function createPoints() {
209
+ const positions = new Float32Array(noteData.length * 3);
210
+ const colors = new Float32Array(noteData.length * 3);
211
+
212
+ // Normalize data for visualization
213
+ const maxFreq = Math.max(...noteData.map(n => n.frequency));
214
+ const minFreq = Math.min(...noteData.map(n => n.frequency));
215
+ const maxTime = Math.max(...noteData.map(n => n.time));
216
+
217
+ for (let i = 0; i < noteData.length; i++) {
218
+ // Map frequency to X-axis (0-20)
219
+ positions[i * 3] = ((noteData[i].frequency - minFreq) / (maxFreq - minFreq)) * 20 - 10;
220
+
221
+ // Map amplitude to Y-axis (0-20)
222
+ positions[i * 3 + 1] = noteData[i].amplitude * 20;
223
+
224
+ // Map time to Z-axis (0-20)
225
+ positions[i * 3 + 2] = (noteData[i].time / maxTime) * 20 - 10;
226
+
227
+ // Set colors
228
+ colors[i * 3] = noteData[i].color.r;
229
+ colors[i * 3 + 1] = noteData[i].color.g;
230
+ colors[i * 3 + 2] = noteData[i].color.b;
231
+ }
232
+
233
+ // Create geometry
234
+ const geometry = new THREE.BufferGeometry();
235
+ geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
236
+ geometry.setAttribute('color', new THREE.BufferAttribute(colors, 3));
237
+
238
+ // Create material
239
+ const material = new THREE.PointsMaterial({
240
+ size: pointSize,
241
+ vertexColors: true,
242
+ transparent: true,
243
+ opacity: 0.9
244
+ });
245
+
246
+ // Create points
247
+ points = new THREE.Points(geometry, material);
248
+ scene.add(points);
249
+ }
250
+
251
+ function setupEventListeners() {
252
+ // Rotation speed control
253
+ document.getElementById('rotation-speed').addEventListener('input', function() {
254
+ rotationSpeed = parseFloat(this.value);
255
+ });
256
+
257
+ // Point size control
258
+ document.getElementById('point-size').addEventListener('input', function() {
259
+ pointSize = parseFloat(this.value);
260
+ points.material.size = pointSize;
261
+ });
262
+
263
+ // Reset view button
264
+ document.getElementById('reset-view').addEventListener('click', function() {
265
+ camera.position.set(0, 10, 30);
266
+ camera.lookAt(0, 0, 0);
267
+ });
268
+
269
+ // Handle window resize
270
+ window.addEventListener('resize', function() {
271
+ camera.aspect = document.getElementById('visualization-container').clientWidth /
272
+ document.getElementById('visualization-container').clientHeight;
273
+ camera.updateProjectionMatrix();
274
+ renderer.setSize(
275
+ document.getElementById('visualization-container').clientWidth,
276
+ document.getElementById('visualization-container').clientHeight
277
+ );
278
+ });
279
+
280
+ // Mouse interaction for note selection
281
+ const raycaster = new THREE.Raycaster();
282
+ const mouse = new THREE.Vector2();
283
+
284
+ document.getElementById('visualization-container').addEventListener('click', function(event) {
285
+ // Calculate mouse position in normalized device coordinates
286
+ const rect = renderer.domElement.getBoundingClientRect();
287
+ mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
288
+ mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
289
+
290
+ // Update the picking ray with the camera and mouse position
291
+ raycaster.setFromCamera(mouse, camera);
292
+
293
+ // Calculate objects intersecting the picking ray
294
+ const intersects = raycaster.intersectObject(points);
295
+
296
+ if (intersects.length > 0) {
297
+ const index = intersects[0].index;
298
+ const note = noteData[index];
299
+ document.getElementById('note-details').innerHTML = `
300
+ <p><strong>Frequency:</strong> ${note.frequency.toFixed(2)} Hz</p>
301
+ <p><strong>Amplitude:</strong> ${(note.amplitude * 100).toFixed(0)}%</p>
302
+ <p><strong>Duration:</strong> ${note.duration} seconds</p>
303
+ <p><strong>Time:</strong> ${note.time.toFixed(1)} seconds</p>
304
+ `;
305
+ }
306
+ });
307
+ }
308
+
309
+ function animate() {
310
+ requestAnimationFrame(animate);
311
+
312
+ // Rotate the entire scene
313
+ if (points) {
314
+ points.rotation.y += 0.005 * rotationSpeed;
315
+ }
316
+
317
+ renderer.render(scene, camera);
318
+ }
319
+
320
+ // Initialize when page loads
321
+ window.addEventListener('load', init);
322
+ </script>
323
+ </body>
324
+ </html>