Spaces:
Running
Running
Add 3 files
Browse files- README.md +6 -4
- index.html +557 -19
- prompts.txt +1 -0
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: pink
|
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: testing-web
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: red
|
5 |
colorTo: pink
|
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,557 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Neon MIDI Player</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/Tone.min.js"></script>
|
10 |
+
<script src="https://cdn.jsdelivr.net/npm/@magenta/[email protected]/es6/core.js"></script>
|
11 |
+
<script src="https://cdn.jsdelivr.net/npm/@magenta/[email protected]/es6/midi_visualizer.js"></script>
|
12 |
+
<style>
|
13 |
+
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;600;700&display=swap');
|
14 |
+
|
15 |
+
:root {
|
16 |
+
--primary: #6366f1;
|
17 |
+
--primary-dark: #4f46e5;
|
18 |
+
--secondary: #f43f5e;
|
19 |
+
--dark: #1e293b;
|
20 |
+
--light: #f8fafc;
|
21 |
+
}
|
22 |
+
|
23 |
+
body {
|
24 |
+
font-family: 'Montserrat', sans-serif;
|
25 |
+
background-color: #0f172a;
|
26 |
+
color: var(--light);
|
27 |
+
}
|
28 |
+
|
29 |
+
.glass-card {
|
30 |
+
background: rgba(255, 255, 255, 0.05);
|
31 |
+
backdrop-filter: blur(10px);
|
32 |
+
-webkit-backdrop-filter: blur(10px);
|
33 |
+
border-radius: 12px;
|
34 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
35 |
+
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.2);
|
36 |
+
}
|
37 |
+
|
38 |
+
.neon-text {
|
39 |
+
text-shadow: 0 0 5px var(--primary), 0 0 10px var(--primary);
|
40 |
+
}
|
41 |
+
|
42 |
+
.piano-roll {
|
43 |
+
height: 300px;
|
44 |
+
overflow-y: auto;
|
45 |
+
background-color: rgba(15, 23, 42, 0.7);
|
46 |
+
}
|
47 |
+
|
48 |
+
.progress-bar {
|
49 |
+
height: 6px;
|
50 |
+
background: rgba(255, 255, 255, 0.1);
|
51 |
+
}
|
52 |
+
|
53 |
+
.progress-fill {
|
54 |
+
height: 100%;
|
55 |
+
background: linear-gradient(90deg, var(--primary), var(--secondary));
|
56 |
+
transition: width 0.1s linear;
|
57 |
+
}
|
58 |
+
|
59 |
+
.btn-primary {
|
60 |
+
background: linear-gradient(135deg, var(--primary), var(--primary-dark));
|
61 |
+
transition: all 0.3s ease;
|
62 |
+
}
|
63 |
+
|
64 |
+
.btn-primary:hover {
|
65 |
+
transform: translateY(-2px);
|
66 |
+
box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
|
67 |
+
}
|
68 |
+
|
69 |
+
.btn-secondary {
|
70 |
+
background: linear-gradient(135deg, var(--secondary), #e11d48);
|
71 |
+
transition: all 0.3s ease;
|
72 |
+
}
|
73 |
+
|
74 |
+
.btn-secondary:hover {
|
75 |
+
transform: translateY(-2px);
|
76 |
+
box-shadow: 0 4px 15px rgba(244, 63, 94, 0.4);
|
77 |
+
}
|
78 |
+
|
79 |
+
.keyboard {
|
80 |
+
display: flex;
|
81 |
+
height: 120px;
|
82 |
+
margin-top: 20px;
|
83 |
+
}
|
84 |
+
|
85 |
+
.white-key {
|
86 |
+
flex: 1;
|
87 |
+
background: white;
|
88 |
+
border: 1px solid #ccc;
|
89 |
+
border-radius: 0 0 5px 5px;
|
90 |
+
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
|
91 |
+
z-index: 1;
|
92 |
+
position: relative;
|
93 |
+
}
|
94 |
+
|
95 |
+
.black-key {
|
96 |
+
width: 0.6;
|
97 |
+
height: 60%;
|
98 |
+
background: #333;
|
99 |
+
margin-left: -0.3;
|
100 |
+
margin-right: -0.3;
|
101 |
+
z-index: 2;
|
102 |
+
position: relative;
|
103 |
+
border-radius: 0 0 3px 3px;
|
104 |
+
}
|
105 |
+
|
106 |
+
.active-key {
|
107 |
+
background: linear-gradient(180deg, var(--primary), var(--secondary));
|
108 |
+
}
|
109 |
+
|
110 |
+
.visualizer {
|
111 |
+
width: 100%;
|
112 |
+
height: 100%;
|
113 |
+
}
|
114 |
+
|
115 |
+
/* Custom scrollbar */
|
116 |
+
::-webkit-scrollbar {
|
117 |
+
width: 8px;
|
118 |
+
}
|
119 |
+
|
120 |
+
::-webkit-scrollbar-track {
|
121 |
+
background: rgba(255, 255, 255, 0.05);
|
122 |
+
}
|
123 |
+
|
124 |
+
::-webkit-scrollbar-thumb {
|
125 |
+
background: var(--primary);
|
126 |
+
border-radius: 4px;
|
127 |
+
}
|
128 |
+
|
129 |
+
/* Animation for loading */
|
130 |
+
@keyframes pulse {
|
131 |
+
0%, 100% { opacity: 0.6; }
|
132 |
+
50% { opacity: 1; }
|
133 |
+
}
|
134 |
+
|
135 |
+
.pulse {
|
136 |
+
animation: pulse 1.5s infinite;
|
137 |
+
}
|
138 |
+
</style>
|
139 |
+
</head>
|
140 |
+
<body class="min-h-screen flex flex-col">
|
141 |
+
<div class="container mx-auto px-4 py-8 flex-1">
|
142 |
+
<header class="text-center mb-10">
|
143 |
+
<h1 class="text-4xl md:text-5xl font-bold mb-2 neon-text">Neon MIDI Player</h1>
|
144 |
+
<p class="text-lg text-gray-300">Play MIDI files with custom SoundFonts</p>
|
145 |
+
</header>
|
146 |
+
|
147 |
+
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
148 |
+
<!-- Controls Section -->
|
149 |
+
<div class="glass-card p-6 lg:col-span-1">
|
150 |
+
<h2 class="text-xl font-semibold mb-4 flex items-center">
|
151 |
+
<i class="fas fa-sliders-h mr-2"></i> Controls
|
152 |
+
</h2>
|
153 |
+
|
154 |
+
<div class="space-y-4">
|
155 |
+
<div>
|
156 |
+
<label class="block text-sm font-medium mb-1">MIDI File</label>
|
157 |
+
<input type="file" id="midi-file" accept=".mid,.midi" class="hidden">
|
158 |
+
<button id="load-midi-btn" class="w-full btn-primary text-white py-2 px-4 rounded-lg flex items-center justify-center">
|
159 |
+
<i class="fas fa-file-import mr-2"></i> Load MIDI File
|
160 |
+
</button>
|
161 |
+
</div>
|
162 |
+
|
163 |
+
<div>
|
164 |
+
<label class="block text-sm font-medium mb-1">SoundFont</label>
|
165 |
+
<select id="soundfont-select" class="w-full bg-gray-800 border border-gray-700 rounded-lg py-2 px-3 text-white focus:outline-none focus:ring-2 focus:ring-indigo-500">
|
166 |
+
<option value="acoustic_grand_piano">Acoustic Grand Piano</option>
|
167 |
+
<option value="electric_piano_1">Electric Piano 1</option>
|
168 |
+
<option value="electric_piano_2">Electric Piano 2</option>
|
169 |
+
<option value="honkytonk_piano">Honky-tonk Piano</option>
|
170 |
+
<option value="electric_guitar_clean">Electric Guitar (Clean)</option>
|
171 |
+
<option value="electric_guitar_jazz">Electric Guitar (Jazz)</option>
|
172 |
+
<option value="electric_bass_finger">Electric Bass (Finger)</option>
|
173 |
+
<option value="synth_bass_1">Synth Bass 1</option>
|
174 |
+
<option value="violin">Violin</option>
|
175 |
+
<option value="cello">Cello</option>
|
176 |
+
</select>
|
177 |
+
</div>
|
178 |
+
|
179 |
+
<div class="grid grid-cols-3 gap-2">
|
180 |
+
<button id="play-btn" class="btn-primary text-white py-2 px-4 rounded-lg flex items-center justify-center">
|
181 |
+
<i class="fas fa-play mr-2"></i> Play
|
182 |
+
</button>
|
183 |
+
<button id="pause-btn" class="bg-gray-700 text-white py-2 px-4 rounded-lg flex items-center justify-center">
|
184 |
+
<i class="fas fa-pause mr-2"></i> Pause
|
185 |
+
</button>
|
186 |
+
<button id="stop-btn" class="btn-secondary text-white py-2 px-4 rounded-lg flex items-center justify-center">
|
187 |
+
<i class="fas fa-stop mr-2"></i> Stop
|
188 |
+
</button>
|
189 |
+
</div>
|
190 |
+
|
191 |
+
<div>
|
192 |
+
<label class="block text-sm font-medium mb-1">Volume</label>
|
193 |
+
<input type="range" id="volume-slider" min="0" max="1" step="0.01" value="0.8" class="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer">
|
194 |
+
</div>
|
195 |
+
|
196 |
+
<div>
|
197 |
+
<label class="block text-sm font-medium mb-1">Tempo</label>
|
198 |
+
<input type="range" id="tempo-slider" min="20" max="200" step="1" value="120" class="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer">
|
199 |
+
<div class="flex justify-between text-xs text-gray-400">
|
200 |
+
<span>Slow</span>
|
201 |
+
<span id="tempo-value">120 BPM</span>
|
202 |
+
<span>Fast</span>
|
203 |
+
</div>
|
204 |
+
</div>
|
205 |
+
|
206 |
+
<div class="pt-4 border-t border-gray-700">
|
207 |
+
<div class="flex justify-between text-sm mb-1">
|
208 |
+
<span>Status:</span>
|
209 |
+
<span id="status-text" class="text-indigo-300">Ready</span>
|
210 |
+
</div>
|
211 |
+
<div class="progress-bar rounded-full">
|
212 |
+
<div id="progress-fill" class="progress-fill rounded-full" style="width: 0%"></div>
|
213 |
+
</div>
|
214 |
+
<div class="flex justify-between text-xs text-gray-400 mt-1">
|
215 |
+
<span id="current-time">0:00</span>
|
216 |
+
<span id="total-time">0:00</span>
|
217 |
+
</div>
|
218 |
+
</div>
|
219 |
+
</div>
|
220 |
+
</div>
|
221 |
+
|
222 |
+
<!-- Visualizer Section -->
|
223 |
+
<div class="glass-card p-6 lg:col-span-2">
|
224 |
+
<h2 class="text-xl font-semibold mb-4 flex items-center">
|
225 |
+
<i class="fas fa-music mr-2"></i> Visualizer
|
226 |
+
</h2>
|
227 |
+
|
228 |
+
<div class="piano-roll glass-card p-4 mb-4">
|
229 |
+
<div id="visualizer" class="visualizer">
|
230 |
+
<div class="flex items-center justify-center h-full text-gray-500">
|
231 |
+
<div class="text-center">
|
232 |
+
<i class="fas fa-music text-4xl mb-2"></i>
|
233 |
+
<p>No MIDI file loaded</p>
|
234 |
+
</div>
|
235 |
+
</div>
|
236 |
+
</div>
|
237 |
+
</div>
|
238 |
+
|
239 |
+
<div class="keyboard hidden" id="keyboard-preview">
|
240 |
+
<!-- White keys -->
|
241 |
+
<div class="white-key" data-note="C"></div>
|
242 |
+
<div class="white-key" data-note="D"></div>
|
243 |
+
<div class="white-key" data-note="E"></div>
|
244 |
+
<div class="white-key" data-note="F"></div>
|
245 |
+
<div class="white-key" data-note="G"></div>
|
246 |
+
<div class="white-key" data-note="A"></div>
|
247 |
+
<div class="white-key" data-note="B"></div>
|
248 |
+
|
249 |
+
<!-- Black keys -->
|
250 |
+
<div class="black-key" data-note="C#"></div>
|
251 |
+
<div class="black-key" data-note="D#"></div>
|
252 |
+
<div class="black-key" data-note="F#"></div>
|
253 |
+
<div class="black-key" data-note="G#"></div>
|
254 |
+
<div class="black-key" data-note="A#"></div>
|
255 |
+
</div>
|
256 |
+
</div>
|
257 |
+
</div>
|
258 |
+
</div>
|
259 |
+
|
260 |
+
<footer class="text-center py-4 text-gray-400 text-sm">
|
261 |
+
<p>Neon MIDI Player © 2023 | Powered by Tone.js and Magenta.js</p>
|
262 |
+
</footer>
|
263 |
+
|
264 |
+
<script>
|
265 |
+
document.addEventListener('DOMContentLoaded', () => {
|
266 |
+
// Initialize Tone.js
|
267 |
+
Tone.start();
|
268 |
+
|
269 |
+
// Elements
|
270 |
+
const loadMidiBtn = document.getElementById('load-midi-btn');
|
271 |
+
const midiFileInput = document.getElementById('midi-file');
|
272 |
+
const soundfontSelect = document.getElementById('soundfont-select');
|
273 |
+
const playBtn = document.getElementById('play-btn');
|
274 |
+
const pauseBtn = document.getElementById('pause-btn');
|
275 |
+
const stopBtn = document.getElementById('stop-btn');
|
276 |
+
const volumeSlider = document.getElementById('volume-slider');
|
277 |
+
const tempoSlider = document.getElementById('tempo-slider');
|
278 |
+
const tempoValue = document.getElementById('tempo-value');
|
279 |
+
const statusText = document.getElementById('status-text');
|
280 |
+
const progressFill = document.getElementById('progress-fill');
|
281 |
+
const currentTime = document.getElementById('current-time');
|
282 |
+
const totalTime = document.getElementById('total-time');
|
283 |
+
const visualizer = document.getElementById('visualizer');
|
284 |
+
const keyboardPreview = document.getElementById('keyboard-preview');
|
285 |
+
|
286 |
+
// Variables
|
287 |
+
let player;
|
288 |
+
let midiData;
|
289 |
+
let sequence;
|
290 |
+
let isPlaying = false;
|
291 |
+
let currentSoundfont = 'acoustic_grand_piano';
|
292 |
+
let visualizerSVG;
|
293 |
+
|
294 |
+
// Initialize player
|
295 |
+
async function initPlayer() {
|
296 |
+
player = new mm.SoundFontPlayer(
|
297 |
+
'https://storage.googleapis.com/magentadata/js/soundfonts/sgm_plus',
|
298 |
+
undefined,
|
299 |
+
undefined,
|
300 |
+
undefined,
|
301 |
+
Tone.context
|
302 |
+
);
|
303 |
+
|
304 |
+
await player.loadSoundFont(currentSoundfont);
|
305 |
+
player.setVolume(volumeSlider.value);
|
306 |
+
|
307 |
+
// Set up callbacks
|
308 |
+
player.onLoad = () => {
|
309 |
+
statusText.textContent = 'Ready';
|
310 |
+
statusText.classList.remove('text-indigo-300');
|
311 |
+
statusText.classList.add('text-green-400');
|
312 |
+
};
|
313 |
+
|
314 |
+
player.onError = (error) => {
|
315 |
+
statusText.textContent = `Error: ${error}`;
|
316 |
+
statusText.classList.remove('text-indigo-300');
|
317 |
+
statusText.classList.add('text-red-400');
|
318 |
+
};
|
319 |
+
|
320 |
+
player.onPlaybackStarted = () => {
|
321 |
+
isPlaying = true;
|
322 |
+
statusText.textContent = 'Playing';
|
323 |
+
statusText.classList.remove('text-indigo-300');
|
324 |
+
statusText.classList.add('text-green-400');
|
325 |
+
updatePlaybackControls();
|
326 |
+
};
|
327 |
+
|
328 |
+
player.onPlaybackPaused = () => {
|
329 |
+
isPlaying = false;
|
330 |
+
statusText.textContent = 'Paused';
|
331 |
+
statusText.classList.remove('text-green-400');
|
332 |
+
statusText.classList.add('text-yellow-400');
|
333 |
+
updatePlaybackControls();
|
334 |
+
};
|
335 |
+
|
336 |
+
player.onPlaybackStopped = () => {
|
337 |
+
isPlaying = false;
|
338 |
+
statusText.textContent = 'Stopped';
|
339 |
+
statusText.classList.remove('text-green-400');
|
340 |
+
statusText.classList.add('text-indigo-300');
|
341 |
+
progressFill.style.width = '0%';
|
342 |
+
currentTime.textContent = '0:00';
|
343 |
+
updatePlaybackControls();
|
344 |
+
};
|
345 |
+
|
346 |
+
player.onPlaybackProgress = (progress) => {
|
347 |
+
progressFill.style.width = `${progress * 100}%`;
|
348 |
+
if (player.currentTime && player.totalTime) {
|
349 |
+
currentTime.textContent = formatTime(player.currentTime);
|
350 |
+
totalTime.textContent = formatTime(player.totalTime);
|
351 |
+
}
|
352 |
+
};
|
353 |
+
}
|
354 |
+
|
355 |
+
// Initialize visualizer
|
356 |
+
function initVisualizer() {
|
357 |
+
visualizerSVG = new mm.PianoRollSVGVisualizer(
|
358 |
+
null,
|
359 |
+
visualizer,
|
360 |
+
{
|
361 |
+
noteHeight: 8,
|
362 |
+
pixelsPerTimeStep: 30,
|
363 |
+
noteSpacing: 1,
|
364 |
+
noteRGB: '125, 211, 252',
|
365 |
+
activeNoteRGB: '236, 72, 153',
|
366 |
+
minPitch: 21,
|
367 |
+
maxPitch: 108
|
368 |
+
}
|
369 |
+
);
|
370 |
+
}
|
371 |
+
|
372 |
+
// Format time (seconds to MM:SS)
|
373 |
+
function formatTime(seconds) {
|
374 |
+
const mins = Math.floor(seconds / 60);
|
375 |
+
const secs = Math.floor(seconds % 60);
|
376 |
+
return `${mins}:${secs < 10 ? '0' : ''}${secs}`;
|
377 |
+
}
|
378 |
+
|
379 |
+
// Update playback controls
|
380 |
+
function updatePlaybackControls() {
|
381 |
+
if (isPlaying) {
|
382 |
+
playBtn.disabled = true;
|
383 |
+
playBtn.classList.remove('btn-primary');
|
384 |
+
playBtn.classList.add('bg-gray-600');
|
385 |
+
|
386 |
+
pauseBtn.disabled = false;
|
387 |
+
pauseBtn.classList.remove('bg-gray-700');
|
388 |
+
pauseBtn.classList.add('btn-secondary');
|
389 |
+
|
390 |
+
stopBtn.disabled = false;
|
391 |
+
} else {
|
392 |
+
playBtn.disabled = !midiData;
|
393 |
+
playBtn.classList.add('btn-primary');
|
394 |
+
playBtn.classList.remove('bg-gray-600');
|
395 |
+
|
396 |
+
pauseBtn.disabled = true;
|
397 |
+
pauseBtn.classList.add('bg-gray-700');
|
398 |
+
pauseBtn.classList.remove('btn-secondary');
|
399 |
+
|
400 |
+
stopBtn.disabled = !midiData;
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
// Load MIDI file
|
405 |
+
loadMidiBtn.addEventListener('click', () => {
|
406 |
+
midiFileInput.click();
|
407 |
+
});
|
408 |
+
|
409 |
+
midiFileInput.addEventListener('change', async (e) => {
|
410 |
+
const file = e.target.files[0];
|
411 |
+
if (!file) return;
|
412 |
+
|
413 |
+
statusText.textContent = 'Loading MIDI...';
|
414 |
+
statusText.classList.add('pulse');
|
415 |
+
|
416 |
+
try {
|
417 |
+
const arrayBuffer = await file.arrayBuffer();
|
418 |
+
midiData = new mm.MidiFile(arrayBuffer);
|
419 |
+
|
420 |
+
// Update visualizer
|
421 |
+
visualizerSVG = new mm.PianoRollSVGVisualizer(
|
422 |
+
midiData,
|
423 |
+
visualizer,
|
424 |
+
{
|
425 |
+
noteHeight: 8,
|
426 |
+
pixelsPerTimeStep: 30,
|
427 |
+
noteSpacing: 1,
|
428 |
+
noteRGB: '125, 211, 252',
|
429 |
+
activeNoteRGB: '236, 72, 153',
|
430 |
+
minPitch: 21,
|
431 |
+
maxPitch: 108
|
432 |
+
}
|
433 |
+
);
|
434 |
+
|
435 |
+
// Calculate total time
|
436 |
+
const totalSeconds = midiData.totalTime;
|
437 |
+
totalTime.textContent = formatTime(totalSeconds);
|
438 |
+
|
439 |
+
// Show keyboard preview
|
440 |
+
keyboardPreview.classList.remove('hidden');
|
441 |
+
|
442 |
+
statusText.textContent = 'Ready';
|
443 |
+
statusText.classList.remove('pulse');
|
444 |
+
updatePlaybackControls();
|
445 |
+
} catch (error) {
|
446 |
+
console.error('Error loading MIDI:', error);
|
447 |
+
statusText.textContent = `Error: ${error.message}`;
|
448 |
+
statusText.classList.remove('pulse');
|
449 |
+
statusText.classList.add('text-red-400');
|
450 |
+
}
|
451 |
+
});
|
452 |
+
|
453 |
+
// Play MIDI
|
454 |
+
playBtn.addEventListener('click', () => {
|
455 |
+
if (!midiData) return;
|
456 |
+
|
457 |
+
player.loadSamples(midiData).then(() => {
|
458 |
+
player.start(midiData);
|
459 |
+
|
460 |
+
// Update visualizer to follow playback
|
461 |
+
if (visualizerSVG) {
|
462 |
+
visualizerSVG = new mm.PianoRollSVGVisualizer(
|
463 |
+
midiData,
|
464 |
+
visualizer,
|
465 |
+
{
|
466 |
+
noteHeight: 8,
|
467 |
+
pixelsPerTimeStep: 30,
|
468 |
+
noteSpacing: 1,
|
469 |
+
noteRGB: '125, 211, 252',
|
470 |
+
activeNoteRGB: '236, 72, 153',
|
471 |
+
minPitch: 21,
|
472 |
+
maxPitch: 108
|
473 |
+
}
|
474 |
+
);
|
475 |
+
visualizerSVG.redraw(player.currentTime);
|
476 |
+
}
|
477 |
+
});
|
478 |
+
});
|
479 |
+
|
480 |
+
// Pause MIDI
|
481 |
+
pauseBtn.addEventListener('click', () => {
|
482 |
+
if (!isPlaying) return;
|
483 |
+
player.pause();
|
484 |
+
});
|
485 |
+
|
486 |
+
// Stop MIDI
|
487 |
+
stopBtn.addEventListener('click', () => {
|
488 |
+
if (!isPlaying) return;
|
489 |
+
player.stop();
|
490 |
+
});
|
491 |
+
|
492 |
+
// Change volume
|
493 |
+
volumeSlider.addEventListener('input', () => {
|
494 |
+
if (player) {
|
495 |
+
player.setVolume(volumeSlider.value);
|
496 |
+
}
|
497 |
+
});
|
498 |
+
|
499 |
+
// Change tempo
|
500 |
+
tempoSlider.addEventListener('input', () => {
|
501 |
+
const tempo = parseInt(tempoSlider.value);
|
502 |
+
tempoValue.textContent = `${tempo} BPM`;
|
503 |
+
|
504 |
+
if (player) {
|
505 |
+
player.setTempo(tempo);
|
506 |
+
}
|
507 |
+
});
|
508 |
+
|
509 |
+
// Change soundfont
|
510 |
+
soundfontSelect.addEventListener('change', async () => {
|
511 |
+
currentSoundfont = soundfontSelect.value;
|
512 |
+
statusText.textContent = 'Loading SoundFont...';
|
513 |
+
statusText.classList.add('pulse');
|
514 |
+
|
515 |
+
try {
|
516 |
+
await player.loadSoundFont(currentSoundfont);
|
517 |
+
statusText.textContent = 'Ready';
|
518 |
+
statusText.classList.remove('pulse');
|
519 |
+
} catch (error) {
|
520 |
+
console.error('Error loading SoundFont:', error);
|
521 |
+
statusText.textContent = `Error: ${error.message}`;
|
522 |
+
statusText.classList.remove('pulse');
|
523 |
+
statusText.classList.add('text-red-400');
|
524 |
+
}
|
525 |
+
});
|
526 |
+
|
527 |
+
// Keyboard preview interaction
|
528 |
+
keyboardPreview.addEventListener('mousedown', (e) => {
|
529 |
+
if (e.target.classList.contains('white-key') || e.target.classList.contains('black-key')) {
|
530 |
+
e.target.classList.add('active-key');
|
531 |
+
|
532 |
+
// Play the note
|
533 |
+
const note = e.target.dataset.note;
|
534 |
+
const synth = new Tone.Synth().toDestination();
|
535 |
+
synth.triggerAttackRelease(`${note}4`, "8n");
|
536 |
+
}
|
537 |
+
});
|
538 |
+
|
539 |
+
keyboardPreview.addEventListener('mouseup', (e) => {
|
540 |
+
if (e.target.classList.contains('white-key') || e.target.classList.contains('black-key')) {
|
541 |
+
e.target.classList.remove('active-key');
|
542 |
+
}
|
543 |
+
});
|
544 |
+
|
545 |
+
keyboardPreview.addEventListener('mouseleave', () => {
|
546 |
+
const activeKeys = keyboardPreview.querySelectorAll('.active-key');
|
547 |
+
activeKeys.forEach(key => key.classList.remove('active-key'));
|
548 |
+
});
|
549 |
+
|
550 |
+
// Initialize everything
|
551 |
+
initPlayer();
|
552 |
+
initVisualizer();
|
553 |
+
updatePlaybackControls();
|
554 |
+
});
|
555 |
+
</script>
|
556 |
+
<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=NeoPy/testing-web" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
557 |
+
</html>
|
prompts.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
website to play midi file with custom soundfont and make the css more modern
|