talibanta commited on
Commit
be8b7f7
·
verified ·
1 Parent(s): 32bdcda

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +6 -4
  2. index.html +654 -19
  3. prompts.txt +0 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Myspace
3
- emoji: 📚
4
- colorFrom: yellow
5
  colorTo: purple
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: myspace
3
+ emoji: 🐳
4
+ colorFrom: purple
5
  colorTo: purple
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,654 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>AM & FM Modulation Visualizer</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
9
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
10
+ <style>
11
+ .wave-container {
12
+ position: relative;
13
+ height: 200px;
14
+ overflow: hidden;
15
+ background-color: #1a202c;
16
+ border-radius: 0.5rem;
17
+ }
18
+ .wave {
19
+ position: absolute;
20
+ width: 100%;
21
+ height: 100%;
22
+ }
23
+ .slider-container {
24
+ position: relative;
25
+ height: 10px;
26
+ background-color: #e2e8f0;
27
+ border-radius: 5px;
28
+ margin: 20px 0;
29
+ }
30
+ .slider-track {
31
+ position: absolute;
32
+ height: 100%;
33
+ background-color: #4299e1;
34
+ border-radius: 5px;
35
+ }
36
+ .slider-thumb {
37
+ position: absolute;
38
+ width: 20px;
39
+ height: 20px;
40
+ background-color: #3182ce;
41
+ border-radius: 50%;
42
+ top: -5px;
43
+ transform: translateX(-50%);
44
+ cursor: pointer;
45
+ box-shadow: 0 2px 4px rgba(0,0,0,0.2);
46
+ }
47
+ .tab-content {
48
+ display: none;
49
+ }
50
+ .tab-content.active {
51
+ display: block;
52
+ animation: fadeIn 0.5s ease-in-out;
53
+ }
54
+ @keyframes fadeIn {
55
+ from { opacity: 0; transform: translateY(10px); }
56
+ to { opacity: 1; transform: translateY(0); }
57
+ }
58
+ .modulation-diagram {
59
+ width: 100%;
60
+ height: 300px;
61
+ background-color: #f7fafc;
62
+ border-radius: 0.5rem;
63
+ position: relative;
64
+ overflow: hidden;
65
+ }
66
+ </style>
67
+ </head>
68
+ <body class="bg-gray-100 min-h-screen">
69
+ <div class="container mx-auto px-4 py-8">
70
+ <header class="text-center mb-12">
71
+ <h1 class="text-4xl font-bold text-gray-800 mb-2">Radio Modulation Visualizer</h1>
72
+ <p class="text-xl text-gray-600">Explore AM and FM modulation through interactive illustrations</p>
73
+ </header>
74
+
75
+ <div class="bg-white rounded-xl shadow-lg overflow-hidden mb-8">
76
+ <div class="flex border-b border-gray-200">
77
+ <button class="tab-btn flex-1 py-4 px-6 text-center font-medium text-gray-500 hover:text-blue-600 hover:bg-gray-50 transition-all duration-300 active" data-tab="am">
78
+ <i class="fas fa-wave-square mr-2"></i> Amplitude Modulation (AM)
79
+ </button>
80
+ <button class="tab-btn flex-1 py-4 px-6 text-center font-medium text-gray-500 hover:text-blue-600 hover:bg-gray-50 transition-all duration-300" data-tab="fm">
81
+ <i class="fas fa-satellite-dish mr-2"></i> Frequency Modulation (FM)
82
+ </button>
83
+ </div>
84
+
85
+ <div id="am" class="tab-content active p-6">
86
+ <div class="grid md:grid-cols-2 gap-8">
87
+ <div>
88
+ <h3 class="text-xl font-semibold mb-4 text-gray-700">AM Modulation Process</h3>
89
+ <p class="text-gray-600 mb-6">
90
+ Amplitude Modulation varies the strength (amplitude) of the carrier wave in proportion to the waveform being transmitted.
91
+ The frequency remains constant while the amplitude changes.
92
+ </p>
93
+
94
+ <div class="mb-6">
95
+ <label class="block text-gray-700 mb-2">Message Frequency: <span id="am-message-freq-value">1</span> Hz</label>
96
+ <div class="slider-container" id="am-message-freq-slider">
97
+ <div class="slider-track" style="width: 20%"></div>
98
+ <div class="slider-thumb" style="left: 20%"></div>
99
+ </div>
100
+ </div>
101
+
102
+ <div class="mb-6">
103
+ <label class="block text-gray-700 mb-2">Carrier Frequency: <span id="am-carrier-freq-value">10</span> Hz</label>
104
+ <div class="slider-container" id="am-carrier-freq-slider">
105
+ <div class="slider-track" style="width: 50%"></div>
106
+ <div class="slider-thumb" style="left: 50%"></div>
107
+ </div>
108
+ </div>
109
+
110
+ <div class="mb-6">
111
+ <label class="block text-gray-700 mb-2">Modulation Index: <span id="am-mod-index-value">0.5</span></label>
112
+ <div class="slider-container" id="am-mod-index-slider">
113
+ <div class="slider-track" style="width: 25%"></div>
114
+ <div class="slider-thumb" style="left: 25%"></div>
115
+ </div>
116
+ </div>
117
+ </div>
118
+
119
+ <div>
120
+ <div class="wave-container mb-4">
121
+ <canvas id="am-message-wave" class="wave"></canvas>
122
+ </div>
123
+ <p class="text-center text-gray-600 mb-2">Message Signal</p>
124
+
125
+ <div class="wave-container mb-4">
126
+ <canvas id="am-carrier-wave" class="wave"></canvas>
127
+ </div>
128
+ <p class="text-center text-gray-600 mb-2">Carrier Signal</p>
129
+
130
+ <div class="wave-container mb-4">
131
+ <canvas id="am-modulated-wave" class="wave"></canvas>
132
+ </div>
133
+ <p class="text-center text-gray-600">Modulated Signal</p>
134
+ </div>
135
+ </div>
136
+
137
+ <div class="mt-8">
138
+ <h3 class="text-xl font-semibold mb-4 text-gray-700">AM Modulation Diagram</h3>
139
+ <div class="modulation-diagram" id="am-diagram">
140
+ <canvas id="am-diagram-canvas"></canvas>
141
+ </div>
142
+ </div>
143
+ </div>
144
+
145
+ <div id="fm" class="tab-content p-6">
146
+ <div class="grid md:grid-cols-2 gap-8">
147
+ <div>
148
+ <h3 class="text-xl font-semibold mb-4 text-gray-700">FM Modulation Process</h3>
149
+ <p class="text-gray-600 mb-6">
150
+ Frequency Modulation varies the frequency of the carrier wave in proportion to the waveform being transmitted.
151
+ The amplitude remains constant while the frequency changes.
152
+ </p>
153
+
154
+ <div class="mb-6">
155
+ <label class="block text-gray-700 mb-2">Message Frequency: <span id="fm-message-freq-value">1</span> Hz</label>
156
+ <div class="slider-container" id="fm-message-freq-slider">
157
+ <div class="slider-track" style="width: 20%"></div>
158
+ <div class="slider-thumb" style="left: 20%"></div>
159
+ </div>
160
+ </div>
161
+
162
+ <div class="mb-6">
163
+ <label class="block text-gray-700 mb-2">Carrier Frequency: <span id="fm-carrier-freq-value">10</span> Hz</label>
164
+ <div class="slider-container" id="fm-carrier-freq-slider">
165
+ <div class="slider-track" style="width: 50%"></div>
166
+ <div class="slider-thumb" style="left: 50%"></div>
167
+ </div>
168
+ </div>
169
+
170
+ <div class="mb-6">
171
+ <label class="block text-gray-700 mb-2">Frequency Deviation: <span id="fm-dev-value">2</span> Hz</label>
172
+ <div class="slider-container" id="fm-dev-slider">
173
+ <div class="slider-track" style="width: 20%"></div>
174
+ <div class="slider-thumb" style="left: 20%"></div>
175
+ </div>
176
+ </div>
177
+ </div>
178
+
179
+ <div>
180
+ <div class="wave-container mb-4">
181
+ <canvas id="fm-message-wave" class="wave"></canvas>
182
+ </div>
183
+ <p class="text-center text-gray-600 mb-2">Message Signal</p>
184
+
185
+ <div class="wave-container mb-4">
186
+ <canvas id="fm-carrier-wave" class="wave"></canvas>
187
+ </div>
188
+ <p class="text-center text-gray-600 mb-2">Carrier Signal</p>
189
+
190
+ <div class="wave-container mb-4">
191
+ <canvas id="fm-modulated-wave" class="wave"></canvas>
192
+ </div>
193
+ <p class="text-center text-gray-600">Modulated Signal</p>
194
+ </div>
195
+ </div>
196
+
197
+ <div class="mt-8">
198
+ <h3 class="text-xl font-semibold mb-4 text-gray-700">FM Modulation Diagram</h3>
199
+ <div class="modulation-diagram" id="fm-diagram">
200
+ <canvas id="fm-diagram-canvas"></canvas>
201
+ </div>
202
+ </div>
203
+ </div>
204
+ </div>
205
+
206
+ <div class="bg-white rounded-xl shadow-lg p-6 mt-8">
207
+ <h2 class="text-2xl font-bold text-gray-800 mb-4">Key Differences</h2>
208
+ <div class="grid md:grid-cols-2 gap-6">
209
+ <div class="bg-blue-50 p-4 rounded-lg">
210
+ <h3 class="text-lg font-semibold text-blue-800 mb-2"><i class="fas fa-wave-square mr-2"></i> AM (Amplitude Modulation)</h3>
211
+ <ul class="text-gray-700 space-y-2">
212
+ <li><i class="fas fa-arrow-up mr-2 text-blue-600"></i> Varies amplitude of carrier wave</li>
213
+ <li><i class="fas fa-waveform mr-2 text-blue-600"></i> More susceptible to noise and interference</li>
214
+ <li><i class="fas fa-broadcast-tower mr-2 text-blue-600"></i> Simpler transmitter and receiver design</li>
215
+ <li><i class="fas fa-ruler-combined mr-2 text-blue-600"></i> Bandwidth = 2 × message frequency</li>
216
+ <li><i class="fas fa-radio mr-2 text-blue-600"></i> Used in AM radio broadcasting (535-1705 kHz)</li>
217
+ </ul>
218
+ </div>
219
+ <div class="bg-purple-50 p-4 rounded-lg">
220
+ <h3 class="text-lg font-semibold text-purple-800 mb-2"><i class="fas fa-satellite-dish mr-2"></i> FM (Frequency Modulation)</h3>
221
+ <ul class="text-gray-700 space-y-2">
222
+ <li><i class="fas fa-sync-alt mr-2 text-purple-600"></i> Varies frequency of carrier wave</li>
223
+ <li><i class="fas fa-shield-alt mr-2 text-purple-600"></i> More resistant to noise and interference</li>
224
+ <li><i class="fas fa-microchip mr-2 text-purple-600"></i> More complex circuitry required</li>
225
+ <li><i class="fas fa-ruler-combined mr-2 text-purple-600"></i> Bandwidth = 2 × (frequency deviation + message frequency)</li>
226
+ <li><i class="fas fa-music mr-2 text-purple-600"></i> Used in FM radio broadcasting (88-108 MHz)</li>
227
+ </ul>
228
+ </div>
229
+ </div>
230
+ </div>
231
+ </div>
232
+
233
+ <script>
234
+ // Tab switching functionality
235
+ document.querySelectorAll('.tab-btn').forEach(btn => {
236
+ btn.addEventListener('click', () => {
237
+ // Remove active class from all tabs and buttons
238
+ document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
239
+ document.querySelectorAll('.tab-content').forEach(t => t.classList.remove('active'));
240
+
241
+ // Add active class to clicked tab and button
242
+ btn.classList.add('active');
243
+ const tabId = btn.getAttribute('data-tab');
244
+ document.getElementById(tabId).classList.add('active');
245
+
246
+ // Redraw charts when switching tabs
247
+ if (tabId === 'am') {
248
+ drawAMCharts();
249
+ } else {
250
+ drawFMCharts();
251
+ }
252
+ });
253
+ });
254
+
255
+ // Slider functionality
256
+ function createSlider(sliderId, valueId, min, max, step, initialValue, callback) {
257
+ const slider = document.getElementById(sliderId);
258
+ const thumb = slider.querySelector('.slider-thumb');
259
+ const track = slider.querySelector('.slider-track');
260
+ const valueDisplay = document.getElementById(valueId);
261
+
262
+ let isDragging = false;
263
+
264
+ // Set initial value
265
+ let value = initialValue;
266
+ updateSliderPosition();
267
+
268
+ function updateSliderPosition() {
269
+ const percentage = ((value - min) / (max - min)) * 100;
270
+ thumb.style.left = `${percentage}%`;
271
+ track.style.width = `${percentage}%`;
272
+ valueDisplay.textContent = value.toFixed(step < 1 ? 2 : 0);
273
+ }
274
+
275
+ function calculateValue(clientX) {
276
+ const rect = slider.getBoundingClientRect();
277
+ let percentage = (clientX - rect.left) / rect.width;
278
+ percentage = Math.max(0, Math.min(1, percentage));
279
+ const newValue = min + percentage * (max - min);
280
+ return Math.round(newValue / step) * step;
281
+ }
282
+
283
+ thumb.addEventListener('mousedown', () => {
284
+ isDragging = true;
285
+ });
286
+
287
+ document.addEventListener('mousemove', (e) => {
288
+ if (!isDragging) return;
289
+
290
+ const newValue = calculateValue(e.clientX);
291
+ if (newValue !== value) {
292
+ value = newValue;
293
+ updateSliderPosition();
294
+ callback(value);
295
+ }
296
+ });
297
+
298
+ document.addEventListener('mouseup', () => {
299
+ isDragging = false;
300
+ });
301
+
302
+ slider.addEventListener('click', (e) => {
303
+ const newValue = calculateValue(e.clientX);
304
+ if (newValue !== value) {
305
+ value = newValue;
306
+ updateSliderPosition();
307
+ callback(value);
308
+ }
309
+ });
310
+
311
+ return {
312
+ getValue: () => value,
313
+ setValue: (newValue) => {
314
+ value = newValue;
315
+ updateSliderPosition();
316
+ }
317
+ };
318
+ }
319
+
320
+ // Wave generation and drawing functions
321
+ function generateSineWave(frequency, amplitude, phase, sampleRate, duration) {
322
+ const samples = [];
323
+ const angularFrequency = 2 * Math.PI * frequency;
324
+
325
+ for (let i = 0; i < sampleRate * duration; i++) {
326
+ const t = i / sampleRate;
327
+ samples.push(amplitude * Math.sin(angularFrequency * t + phase));
328
+ }
329
+
330
+ return samples;
331
+ }
332
+
333
+ function generateAMWave(messageFreq, carrierFreq, modIndex, sampleRate, duration) {
334
+ const messageWave = generateSineWave(messageFreq, 1, 0, sampleRate, duration);
335
+ const carrierWave = generateSineWave(carrierFreq, 1, 0, sampleRate, duration);
336
+
337
+ const modulatedWave = [];
338
+ for (let i = 0; i < messageWave.length; i++) {
339
+ const modulation = 1 + modIndex * messageWave[i];
340
+ modulatedWave.push(modulation * carrierWave[i]);
341
+ }
342
+
343
+ return {
344
+ messageWave,
345
+ carrierWave,
346
+ modulatedWave
347
+ };
348
+ }
349
+
350
+ function generateFMWave(messageFreq, carrierFreq, frequencyDeviation, sampleRate, duration) {
351
+ const messageWave = generateSineWave(messageFreq, 1, 0, sampleRate, duration);
352
+ const carrierWave = generateSineWave(carrierFreq, 1, 0, sampleRate, duration);
353
+
354
+ const modulatedWave = [];
355
+ let phase = 0;
356
+
357
+ for (let i = 0; i < messageWave.length; i++) {
358
+ const t = i / sampleRate;
359
+ const instantaneousFrequency = carrierFreq + frequencyDeviation * messageWave[i];
360
+ phase += 2 * Math.PI * instantaneousFrequency / sampleRate;
361
+ modulatedWave.push(Math.sin(phase));
362
+ }
363
+
364
+ return {
365
+ messageWave,
366
+ carrierWave,
367
+ modulatedWave
368
+ };
369
+ }
370
+
371
+ function drawWave(canvasId, waveData, color, yScale = 1) {
372
+ const canvas = document.getElementById(canvasId);
373
+ const ctx = canvas.getContext('2d');
374
+
375
+ // Set canvas dimensions
376
+ const container = canvas.parentElement;
377
+ canvas.width = container.clientWidth;
378
+ canvas.height = container.clientHeight;
379
+
380
+ // Clear canvas
381
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
382
+
383
+ // Draw wave
384
+ ctx.beginPath();
385
+ ctx.strokeStyle = color;
386
+ ctx.lineWidth = 2;
387
+
388
+ const centerY = canvas.height / 2;
389
+ const amplitude = (canvas.height / 2) * 0.8 * yScale;
390
+
391
+ for (let i = 0; i < waveData.length; i++) {
392
+ const x = (i / waveData.length) * canvas.width;
393
+ const y = centerY - waveData[i] * amplitude;
394
+
395
+ if (i === 0) {
396
+ ctx.moveTo(x, y);
397
+ } else {
398
+ ctx.lineTo(x, y);
399
+ }
400
+ }
401
+
402
+ ctx.stroke();
403
+ }
404
+
405
+ function drawAMDiagram() {
406
+ const canvas = document.getElementById('am-diagram-canvas');
407
+ const ctx = canvas.getContext('2d');
408
+ const container = document.getElementById('am-diagram');
409
+
410
+ canvas.width = container.clientWidth;
411
+ canvas.height = container.clientHeight;
412
+
413
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
414
+
415
+ // Draw axes
416
+ ctx.beginPath();
417
+ ctx.strokeStyle = '#4a5568';
418
+ ctx.lineWidth = 1;
419
+
420
+ // X axis
421
+ ctx.moveTo(50, canvas.height / 2);
422
+ ctx.lineTo(canvas.width - 50, canvas.height / 2);
423
+
424
+ // Y axis
425
+ ctx.moveTo(canvas.width / 2, 30);
426
+ ctx.lineTo(canvas.width / 2, canvas.height - 30);
427
+
428
+ ctx.stroke();
429
+
430
+ // Draw labels
431
+ ctx.font = '14px Arial';
432
+ ctx.fillStyle = '#4a5568';
433
+ ctx.textAlign = 'center';
434
+ ctx.fillText('Time', canvas.width - 30, canvas.height / 2 + 20);
435
+ ctx.fillText('Amplitude', canvas.width / 2, 20);
436
+
437
+ // Draw modulation diagram
438
+ const messageFreq = amSliders.messageFreq.getValue();
439
+ const carrierFreq = amSliders.carrierFreq.getValue();
440
+ const modIndex = amSliders.modIndex.getValue();
441
+
442
+ const duration = 1;
443
+ const sampleRate = 1000;
444
+ const { messageWave, carrierWave, modulatedWave } = generateAMWave(
445
+ messageFreq, carrierFreq, modIndex, sampleRate, duration
446
+ );
447
+
448
+ // Draw envelope
449
+ ctx.beginPath();
450
+ ctx.strokeStyle = 'rgba(66, 153, 225, 0.5)';
451
+ ctx.lineWidth = 2;
452
+ ctx.setLineDash([5, 5]);
453
+
454
+ for (let i = 0; i < modulatedWave.length; i++) {
455
+ const x = 50 + (i / modulatedWave.length) * (canvas.width - 100);
456
+ const y = canvas.height / 2 - (1 + modIndex * messageWave[i]) * (canvas.height / 2 - 30) * 0.8;
457
+
458
+ if (i === 0) {
459
+ ctx.moveTo(x, y);
460
+ } else {
461
+ ctx.lineTo(x, y);
462
+ }
463
+ }
464
+
465
+ for (let i = 0; i < modulatedWave.length; i++) {
466
+ const x = 50 + (i / modulatedWave.length) * (canvas.width - 100);
467
+ const y = canvas.height / 2 - (1 - modIndex * messageWave[i]) * (canvas.height / 2 - 30) * 0.8;
468
+
469
+ if (i === 0) {
470
+ ctx.moveTo(x, y);
471
+ } else {
472
+ ctx.lineTo(x, y);
473
+ }
474
+ }
475
+
476
+ ctx.stroke();
477
+ ctx.setLineDash([]);
478
+
479
+ // Draw modulated wave
480
+ ctx.beginPath();
481
+ ctx.strokeStyle = '#3182ce';
482
+ ctx.lineWidth = 2;
483
+
484
+ for (let i = 0; i < modulatedWave.length; i++) {
485
+ const x = 50 + (i / modulatedWave.length) * (canvas.width - 100);
486
+ const y = canvas.height / 2 - modulatedWave[i] * (canvas.height / 2 - 30) * 0.8;
487
+
488
+ if (i === 0) {
489
+ ctx.moveTo(x, y);
490
+ } else {
491
+ ctx.lineTo(x, y);
492
+ }
493
+ }
494
+
495
+ ctx.stroke();
496
+
497
+ // Draw legend
498
+ ctx.font = '12px Arial';
499
+ ctx.fillStyle = '#3182ce';
500
+ ctx.textAlign = 'left';
501
+ ctx.fillText('Modulated Signal', 60, 30);
502
+
503
+ ctx.fillStyle = 'rgba(66, 153, 225, 0.7)';
504
+ ctx.fillText('Envelope', 60, 50);
505
+ }
506
+
507
+ function drawFMDiagram() {
508
+ const canvas = document.getElementById('fm-diagram-canvas');
509
+ const ctx = canvas.getContext('2d');
510
+ const container = document.getElementById('fm-diagram');
511
+
512
+ canvas.width = container.clientWidth;
513
+ canvas.height = container.clientHeight;
514
+
515
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
516
+
517
+ // Draw axes
518
+ ctx.beginPath();
519
+ ctx.strokeStyle = '#4a5568';
520
+ ctx.lineWidth = 1;
521
+
522
+ // X axis
523
+ ctx.moveTo(50, canvas.height / 2);
524
+ ctx.lineTo(canvas.width - 50, canvas.height / 2);
525
+
526
+ // Y axis
527
+ ctx.moveTo(canvas.width / 2, 30);
528
+ ctx.lineTo(canvas.width / 2, canvas.height - 30);
529
+
530
+ ctx.stroke();
531
+
532
+ // Draw labels
533
+ ctx.font = '14px Arial';
534
+ ctx.fillStyle = '#4a5568';
535
+ ctx.textAlign = 'center';
536
+ ctx.fillText('Time', canvas.width - 30, canvas.height / 2 + 20);
537
+ ctx.fillText('Frequency', canvas.width / 2, 20);
538
+
539
+ // Draw modulation diagram
540
+ const messageFreq = fmSliders.messageFreq.getValue();
541
+ const carrierFreq = fmSliders.carrierFreq.getValue();
542
+ const frequencyDeviation = fmSliders.frequencyDev.getValue();
543
+
544
+ const duration = 1;
545
+ const sampleRate = 1000;
546
+ const { messageWave, modulatedWave } = generateFMWave(
547
+ messageFreq, carrierFreq, frequencyDeviation, sampleRate, duration
548
+ );
549
+
550
+ // Draw frequency variation
551
+ ctx.beginPath();
552
+ ctx.strokeStyle = 'rgba(134, 65, 244, 0.5)';
553
+ ctx.lineWidth = 2;
554
+
555
+ for (let i = 0; i < messageWave.length; i++) {
556
+ const x = 50 + (i / messageWave.length) * (canvas.width - 100);
557
+ const frequency = carrierFreq + frequencyDeviation * messageWave[i];
558
+ const y = canvas.height - 30 - ((frequency - (carrierFreq - frequencyDeviation)) / (2 * frequencyDeviation)) * (canvas.height - 60);
559
+
560
+ if (i === 0) {
561
+ ctx.moveTo(x, y);
562
+ } else {
563
+ ctx.lineTo(x, y);
564
+ }
565
+ }
566
+
567
+ ctx.stroke();
568
+
569
+ // Draw modulated wave
570
+ ctx.beginPath();
571
+ ctx.strokeStyle = '#805ad5';
572
+ ctx.lineWidth = 2;
573
+
574
+ for (let i = 0; i < modulatedWave.length; i++) {
575
+ const x = 50 + (i / modulatedWave.length) * (canvas.width - 100);
576
+ const y = canvas.height / 2 - modulatedWave[i] * (canvas.height / 2 - 30) * 0.8;
577
+
578
+ if (i === 0) {
579
+ ctx.moveTo(x, y);
580
+ } else {
581
+ ctx.lineTo(x, y);
582
+ }
583
+ }
584
+
585
+ ctx.stroke();
586
+
587
+ // Draw legend
588
+ ctx.font = '12px Arial';
589
+ ctx.fillStyle = '#805ad5';
590
+ ctx.textAlign = 'left';
591
+ ctx.fillText('Modulated Signal', 60, 30);
592
+
593
+ ctx.fillStyle = 'rgba(134, 65, 244, 0.7)';
594
+ ctx.fillText('Frequency Variation', 60, 50);
595
+ }
596
+
597
+ function drawAMCharts() {
598
+ const messageFreq = amSliders.messageFreq.getValue();
599
+ const carrierFreq = amSliders.carrierFreq.getValue();
600
+ const modIndex = amSliders.modIndex.getValue();
601
+
602
+ const { messageWave, carrierWave, modulatedWave } = generateAMWave(
603
+ messageFreq, carrierFreq, modIndex, 1000, 1
604
+ );
605
+
606
+ drawWave('am-message-wave', messageWave, '#38a169');
607
+ drawWave('am-carrier-wave', carrierWave, '#dd6b20');
608
+ drawWave('am-modulated-wave', modulatedWave, '#3182ce');
609
+ drawAMDiagram();
610
+ }
611
+
612
+ function drawFMCharts() {
613
+ const messageFreq = fmSliders.messageFreq.getValue();
614
+ const carrierFreq = fmSliders.carrierFreq.getValue();
615
+ const frequencyDeviation = fmSliders.frequencyDev.getValue();
616
+
617
+ const { messageWave, carrierWave, modulatedWave } = generateFMWave(
618
+ messageFreq, carrierFreq, frequencyDeviation, 1000, 1
619
+ );
620
+
621
+ drawWave('fm-message-wave', messageWave, '#38a169');
622
+ drawWave('fm-carrier-wave', carrierWave, '#dd6b20');
623
+ drawWave('fm-modulated-wave', modulatedWave, '#805ad5');
624
+ drawFMDiagram();
625
+ }
626
+
627
+ // Initialize sliders
628
+ const amSliders = {
629
+ messageFreq: createSlider('am-message-freq-slider', 'am-message-freq-value', 0.5, 5, 0.1, 1, drawAMCharts),
630
+ carrierFreq: createSlider('am-carrier-freq-slider', 'am-carrier-freq-value', 5, 20, 1, 10, drawAMCharts),
631
+ modIndex: createSlider('am-mod-index-slider', 'am-mod-index-value', 0, 1, 0.05, 0.5, drawAMCharts)
632
+ };
633
+
634
+ const fmSliders = {
635
+ messageFreq: createSlider('fm-message-freq-slider', 'fm-message-freq-value', 0.5, 5, 0.1, 1, drawFMCharts),
636
+ carrierFreq: createSlider('fm-carrier-freq-slider', 'fm-carrier-freq-value', 5, 20, 1, 10, drawFMCharts),
637
+ frequencyDev: createSlider('fm-dev-slider', 'fm-dev-value', 1, 10, 0.5, 2, drawFMCharts)
638
+ };
639
+
640
+ // Initial draw
641
+ drawAMCharts();
642
+ drawFMCharts();
643
+
644
+ // Handle window resize
645
+ window.addEventListener('resize', () => {
646
+ if (document.getElementById('am').classList.contains('active')) {
647
+ drawAMCharts();
648
+ } else {
649
+ drawFMCharts();
650
+ }
651
+ });
652
+ </script>
653
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=talibanta/myspace" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
654
+ </html>
prompts.txt ADDED
File without changes