Spaces:
Running
Running
What happens when u press record, it should save it somewhere as mp3 or something - Follow Up Deployment
Browse files- README.md +7 -5
- index.html +519 -19
- prompts.txt +6 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 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: dj-beatz
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: yellow
|
| 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,519 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>DJ Beats Pad</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 |
+
<style>
|
| 10 |
+
.pad {
|
| 11 |
+
transition: all 0.1s ease;
|
| 12 |
+
box-shadow: 0 5px 0 rgba(0,0,0,0.3);
|
| 13 |
+
}
|
| 14 |
+
.pad:active, .pad.active {
|
| 15 |
+
transform: translateY(5px);
|
| 16 |
+
box-shadow: 0 2px 0 rgba(0,0,0,0.3);
|
| 17 |
+
}
|
| 18 |
+
.bpm-slider::-webkit-slider-thumb {
|
| 19 |
+
-webkit-appearance: none;
|
| 20 |
+
appearance: none;
|
| 21 |
+
width: 24px;
|
| 22 |
+
height: 24px;
|
| 23 |
+
border-radius: 50%;
|
| 24 |
+
background: #7367F0;
|
| 25 |
+
cursor: pointer;
|
| 26 |
+
border: 2px solid white;
|
| 27 |
+
}
|
| 28 |
+
.metronome-light {
|
| 29 |
+
transition: all 0.1s ease;
|
| 30 |
+
box-shadow: 0 0 10px rgba(255,255,255,0.7);
|
| 31 |
+
background: #7367F0;
|
| 32 |
+
}
|
| 33 |
+
.metronome-light.active {
|
| 34 |
+
background-color: #FF6289;
|
| 35 |
+
box-shadow: 0 0 15px rgba(255,98,137,0.8);
|
| 36 |
+
}
|
| 37 |
+
/* Sequence step colors */
|
| 38 |
+
.step.kick { background-color: #10B981; }
|
| 39 |
+
.step.snare { background-color: #3B82F6; }
|
| 40 |
+
.step.hihat { background-color: #F59E0B; }
|
| 41 |
+
.step.clap { background-color: #EF4444; }
|
| 42 |
+
.step.tom { background-color: #8B5CF6; }
|
| 43 |
+
.blink {
|
| 44 |
+
animation: blink 1s infinite;
|
| 45 |
+
}
|
| 46 |
+
@keyframes blink {
|
| 47 |
+
0% { opacity: 1; }
|
| 48 |
+
50% { opacity: 0.5; }
|
| 49 |
+
100% { opacity: 1; }
|
| 50 |
+
}
|
| 51 |
+
</style>
|
| 52 |
+
</head>
|
| 53 |
+
<body class="bg-gray-900 text-white min-h-screen flex flex-col">
|
| 54 |
+
<div class="container mx-auto px-4 py-8 flex-grow flex flex-col">
|
| 55 |
+
<header class="text-center mb-8">
|
| 56 |
+
<h1 class="text-4xl font-bold mb-2 bg-gradient-to-r from-purple-500 to-blue-500 bg-clip-text text-transparent">DJ Beats Pad</h1>
|
| 57 |
+
<p class="text-gray-300">Tap the pads to play sounds. Hold for looping.</p>
|
| 58 |
+
</header>
|
| 59 |
+
|
| 60 |
+
<div class="flex-grow flex flex-col">
|
| 61 |
+
<!-- BPM Control -->
|
| 62 |
+
<div class="flex items-center justify-center mb-6 gap-4">
|
| 63 |
+
<button id="decrease-bpm" class="bg-gray-700 hover:bg-gray-600 rounded-full w-10 h-10 flex items-center justify-center">
|
| 64 |
+
<i class="fas fa-minus"></i>
|
| 65 |
+
</button>
|
| 66 |
+
<div class="text-center w-32">
|
| 67 |
+
<div class="text-lg font-semibold">BPM: <span id="bpm-value">120</span></div>
|
| 68 |
+
<input type="range" id="bpm-slider" min="60" max="180" value="120"
|
| 69 |
+
class="bpm-slider w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer">
|
| 70 |
+
</div>
|
| 71 |
+
<button id="increase-bpm" class="bg-gray-700 hover:bg-gray-600 rounded-full w-10 h-10 flex items-center justify-center">
|
| 72 |
+
<i class="fas fa-plus"></i>
|
| 73 |
+
</button>
|
| 74 |
+
<button id="toggle-play" class="ml-4 px-4 py-2 rounded-lg bg-indigo-600 hover:bg-indigo-700 flex items-center gap-2">
|
| 75 |
+
<i class="fas fa-play" id="play-icon"></i>
|
| 76 |
+
<span>Play</span>
|
| 77 |
+
</button>
|
| 78 |
+
<div class="metronome-light w-4 h-4 rounded-full bg-gray-600 ml-4"></div>
|
| 79 |
+
</div>
|
| 80 |
+
|
| 81 |
+
<!-- Beat Pads -->
|
| 82 |
+
<div class="grid grid-cols-4 gap-4 md:gap-6 mb-8">
|
| 83 |
+
<!-- Row 1 -->
|
| 84 |
+
<div class="pad bg-red-500 aspect-square rounded-lg flex items-center justify-center cursor-pointer text-2xl font-bold" data-sound="clap">
|
| 85 |
+
Clap
|
| 86 |
+
</div>
|
| 87 |
+
<div class="pad bg-yellow-500 aspect-square rounded-lg flex items-center justify-center cursor-pointer text-2xl font-bold" data-sound="hihat">
|
| 88 |
+
Hi-Hat
|
| 89 |
+
</div>
|
| 90 |
+
<div class="pad bg-green-500 aspect-square rounded-lg flex items-center justify-center cursor-pointer text-2xl font-bold" data-sound="kick">
|
| 91 |
+
Kick
|
| 92 |
+
</div>
|
| 93 |
+
<div class="pad bg-blue-500 aspect-square rounded-lg flex items-center justify-center cursor-pointer text-2xl font-bold" data-sound="openhat">
|
| 94 |
+
Open Hat
|
| 95 |
+
</div>
|
| 96 |
+
<!-- Row 2 -->
|
| 97 |
+
<div class="pad bg-purple-500 aspect-square rounded-lg flex items-center justify-center cursor-pointer text-2xl font-bold" data-sound="boom">
|
| 98 |
+
Boom
|
| 99 |
+
</div>
|
| 100 |
+
<div class="pad bg-pink-500 aspect-square rounded-lg flex items-center justify-center cursor-pointer text-2xl font-bold" data-sound="ride">
|
| 101 |
+
Ride
|
| 102 |
+
</div>
|
| 103 |
+
<div class="pad bg-indigo-500 aspect-square rounded-lg flex items-center justify-center cursor-pointer text-2xl font-bold" data-sound="snare">
|
| 104 |
+
Snare
|
| 105 |
+
</div>
|
| 106 |
+
<div class="pad bg-teal-500 aspect-square rounded-lg flex items-center justify-center cursor-pointer text-2xl font-bold" data-sound="tom">
|
| 107 |
+
Tom
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
+
|
| 111 |
+
<!-- Sequence Recorder -->
|
| 112 |
+
<div class="bg-gray-800 rounded-lg p-4 mb-6">
|
| 113 |
+
<h2 class="text-xl font-semibold mb-3">Sequence Recorder</h2>
|
| 114 |
+
<div class="grid grid-cols-8 gap-2 mb-4">
|
| 115 |
+
<!-- Sequence steps will be added here -->
|
| 116 |
+
</div>
|
| 117 |
+
<div class="flex gap-3">
|
| 118 |
+
<button id="record-btn" class="px-4 py-2 bg-red-600 hover:bg-red-700 rounded-lg flex items-center gap-2">
|
| 119 |
+
<i class="fas fa-circle"></i> Record
|
| 120 |
+
</button>
|
| 121 |
+
<button id="clear-btn" class="px-4 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg flex items-center gap-2">
|
| 122 |
+
<i class="fas fa-trash"></i> Clear
|
| 123 |
+
</button>
|
| 124 |
+
<button id="save-btn" class="px-4 py-2 bg-green-600 hover:bg-green-700 rounded-lg flex items-center gap-2">
|
| 125 |
+
<i class="fas fa-save"></i> Save Sequence
|
| 126 |
+
</button>
|
| 127 |
+
<div id="audio-recording-status" class="ml-auto text-gray-300 flex items-center gap-2 hidden">
|
| 128 |
+
<i class="fas fa-circle text-red-500 blink"></i>
|
| 129 |
+
<span>Recording audio...</span>
|
| 130 |
+
</div>
|
| 131 |
+
<button id="save-audio-btn" class="px-4 py-2 bg-purple-600 hover:bg-purple-700 rounded-lg flex items-center gap-2 hidden">
|
| 132 |
+
<i class="fas fa-download"></i> Save Audio
|
| 133 |
+
</button>
|
| 134 |
+
</div>
|
| 135 |
+
</div>
|
| 136 |
+
</div>
|
| 137 |
+
|
| 138 |
+
<footer class="text-center text-gray-400 text-sm mt-8">
|
| 139 |
+
Tap pads to play sounds. Adjust BPM for tempo. Press record to create sequences.
|
| 140 |
+
</footer>
|
| 141 |
+
</div>
|
| 142 |
+
|
| 143 |
+
<script>
|
| 144 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 145 |
+
// Audio context and samples
|
| 146 |
+
const AudioContext = window.AudioContext || window.webkitAudioContext;
|
| 147 |
+
const audioCtx = new AudioContext();
|
| 148 |
+
|
| 149 |
+
// Sound samples (using base64 encoded short samples for demonstration)
|
| 150 |
+
const sounds = {
|
| 151 |
+
'clap': 'https://assets.codepen.io/1159990/clap.wav',
|
| 152 |
+
'hihat': 'https://assets.codepen.io/1159990/hihat.wav',
|
| 153 |
+
'kick': 'https://assets.codepen.io/1159990/kick.wav',
|
| 154 |
+
'openhat': 'https://assets.codepen.io/1159990/openhat.wav',
|
| 155 |
+
'boom': 'https://assets.codepen.io/1159990/boom.wav',
|
| 156 |
+
'ride': 'https://assets.codepen.io/1159990/ride.wav',
|
| 157 |
+
'snare': 'https://assets.codepen.io/1159990/snare.wav',
|
| 158 |
+
'tom': 'https://assets.codepen.io/1159990/tom.wav'
|
| 159 |
+
};
|
| 160 |
+
|
| 161 |
+
// Load all sounds
|
| 162 |
+
const soundBuffers = {};
|
| 163 |
+
Promise.all(Object.keys(sounds).map(key =>
|
| 164 |
+
fetch(sounds[key])
|
| 165 |
+
.then(res => res.arrayBuffer())
|
| 166 |
+
.then(arrayBuffer => audioCtx.decodeAudioData(arrayBuffer))
|
| 167 |
+
.then(audioBuffer => { soundBuffers[key] = audioBuffer; })
|
| 168 |
+
)).then(() => {
|
| 169 |
+
console.log('All sounds loaded');
|
| 170 |
+
}).catch(err => {
|
| 171 |
+
console.error('Error loading sounds:', err);
|
| 172 |
+
});
|
| 173 |
+
|
| 174 |
+
// Play sound function
|
| 175 |
+
function playSound(soundName) {
|
| 176 |
+
if (soundBuffers[soundName]) {
|
| 177 |
+
const source = audioCtx.createBufferSource();
|
| 178 |
+
source.buffer = soundBuffers[soundName];
|
| 179 |
+
source.connect(audioCtx.destination);
|
| 180 |
+
source.start();
|
| 181 |
+
return source;
|
| 182 |
+
}
|
| 183 |
+
return null;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
// Pad interactions
|
| 187 |
+
const pads = document.querySelectorAll('.pad');
|
| 188 |
+
let heldPads = {};
|
| 189 |
+
|
| 190 |
+
pads.forEach(pad => {
|
| 191 |
+
const soundName = pad.dataset.sound;
|
| 192 |
+
|
| 193 |
+
// Mouse/click events
|
| 194 |
+
pad.addEventListener('mousedown', () => startPad(soundName, pad));
|
| 195 |
+
pad.addEventListener('mouseup', () => stopPad(soundName));
|
| 196 |
+
pad.addEventListener('mouseleave', () => stopPad(soundName));
|
| 197 |
+
|
| 198 |
+
// Touch events for mobile
|
| 199 |
+
pad.addEventListener('touchstart', (e) => {
|
| 200 |
+
e.preventDefault();
|
| 201 |
+
startPad(soundName, pad);
|
| 202 |
+
});
|
| 203 |
+
pad.addEventListener('touchend', (e) => {
|
| 204 |
+
e.preventDefault();
|
| 205 |
+
stopPad(soundName);
|
| 206 |
+
});
|
| 207 |
+
pad.addEventListener('touchcancel', (e) => {
|
| 208 |
+
e.preventDefault();
|
| 209 |
+
stopPad(soundName);
|
| 210 |
+
});
|
| 211 |
+
});
|
| 212 |
+
|
| 213 |
+
function startPad(soundName, padElement) {
|
| 214 |
+
if (!heldPads[soundName]) {
|
| 215 |
+
padElement.classList.add('active');
|
| 216 |
+
playSound(soundName);
|
| 217 |
+
|
| 218 |
+
// For looping on hold
|
| 219 |
+
heldPads[soundName] = setInterval(() => {
|
| 220 |
+
playSound(soundName);
|
| 221 |
+
}, 100); // Quick repeat for hold effect
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
function stopPad(soundName) {
|
| 226 |
+
if (heldPads[soundName]) {
|
| 227 |
+
clearInterval(heldPads[soundName]);
|
| 228 |
+
delete heldPads[soundName];
|
| 229 |
+
|
| 230 |
+
// Remove active class from all pads with this sound
|
| 231 |
+
document.querySelectorAll(`.pad[data-sound="${soundName}"]`).forEach(pad => {
|
| 232 |
+
pad.classList.remove('active');
|
| 233 |
+
});
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
// BPM control
|
| 238 |
+
const bpmSlider = document.getElementById('bpm-slider');
|
| 239 |
+
const bpmValue = document.getElementById('bpm-value');
|
| 240 |
+
const decreaseBpm = document.getElementById('decrease-bpm');
|
| 241 |
+
const increaseBpm = document.getElementById('increase-bpm');
|
| 242 |
+
const togglePlay = document.getElementById('toggle-play');
|
| 243 |
+
const playIcon = document.getElementById('play-icon');
|
| 244 |
+
const metronomeLight = document.querySelector('.metronome-light');
|
| 245 |
+
|
| 246 |
+
let bpm = 120;
|
| 247 |
+
let isPlaying = false;
|
| 248 |
+
let playInterval;
|
| 249 |
+
let beatCounter = 0;
|
| 250 |
+
|
| 251 |
+
bpmSlider.addEventListener('input', () => {
|
| 252 |
+
bpm = parseInt(bpmSlider.value);
|
| 253 |
+
bpmValue.textContent = bpm;
|
| 254 |
+
if (isPlaying) {
|
| 255 |
+
stopPlayback();
|
| 256 |
+
startPlayback();
|
| 257 |
+
}
|
| 258 |
+
});
|
| 259 |
+
|
| 260 |
+
decreaseBpm.addEventListener('click', () => {
|
| 261 |
+
bpm = Math.max(60, bpm - 5);
|
| 262 |
+
bpmSlider.value = bpm;
|
| 263 |
+
bpmValue.textContent = bpm;
|
| 264 |
+
if (isPlaying) {
|
| 265 |
+
stopPlayback();
|
| 266 |
+
startPlayback();
|
| 267 |
+
}
|
| 268 |
+
});
|
| 269 |
+
|
| 270 |
+
increaseBpm.addEventListener('click', () => {
|
| 271 |
+
bpm = Math.min(180, bpm + 5);
|
| 272 |
+
bpmSlider.value = bpm;
|
| 273 |
+
bpmValue.textContent = bpm;
|
| 274 |
+
if (isPlaying) {
|
| 275 |
+
stopPlayback();
|
| 276 |
+
startPlayback();
|
| 277 |
+
}
|
| 278 |
+
});
|
| 279 |
+
|
| 280 |
+
togglePlay.addEventListener('click', () => {
|
| 281 |
+
if (isPlaying) {
|
| 282 |
+
stopPlayback();
|
| 283 |
+
} else {
|
| 284 |
+
startPlayback();
|
| 285 |
+
}
|
| 286 |
+
});
|
| 287 |
+
|
| 288 |
+
function startPlayback() {
|
| 289 |
+
isPlaying = true;
|
| 290 |
+
playIcon.classList.replace('fa-play', 'fa-pause');
|
| 291 |
+
togglePlay.classList.replace('bg-indigo-600', 'bg-indigo-700');
|
| 292 |
+
|
| 293 |
+
const interval = (60 / bpm) * 1000; // Convert BPM to milliseconds
|
| 294 |
+
const stepsPerBeat = 4; // 16 steps divided into 4 beats
|
| 295 |
+
const stepInterval = interval / stepsPerBeat;
|
| 296 |
+
let currentStep = 0;
|
| 297 |
+
|
| 298 |
+
playInterval = setInterval(() => {
|
| 299 |
+
beatCounter++;
|
| 300 |
+
|
| 301 |
+
// Flash the metronome light
|
| 302 |
+
metronomeLight.classList.add('active');
|
| 303 |
+
setTimeout(() => metronomeLight.classList.remove('active'), 100);
|
| 304 |
+
|
| 305 |
+
// Play sounds from the sequence
|
| 306 |
+
if (sequenceSteps[currentStep]?.sound) {
|
| 307 |
+
playSound(sequenceSteps[currentStep].sound);
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
// Highlight current step
|
| 311 |
+
const steps = document.querySelectorAll('.step');
|
| 312 |
+
steps.forEach(step => step.classList.remove('ring-2', 'ring-white'));
|
| 313 |
+
if (steps[currentStep]) {
|
| 314 |
+
steps[currentStep].classList.add('ring-2', 'ring-white');
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
currentStep = (currentStep + 1) % 16;
|
| 318 |
+
|
| 319 |
+
}, stepInterval);
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
function stopPlayback() {
|
| 323 |
+
isPlaying = false;
|
| 324 |
+
playIcon.classList.replace('fa-pause', 'fa-play');
|
| 325 |
+
togglePlay.classList.replace('bg-indigo-700', 'bg-indigo-600');
|
| 326 |
+
clearInterval(playInterval);
|
| 327 |
+
beatCounter = 0;
|
| 328 |
+
metronomeLight.classList.remove('active');
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
// Sequence recorder functionality
|
| 332 |
+
const recordBtn = document.getElementById('record-btn');
|
| 333 |
+
const clearBtn = document.getElementById('clear-btn');
|
| 334 |
+
const saveBtn = document.getElementById('save-btn');
|
| 335 |
+
const sequenceGrid = document.querySelector('.grid.grid-cols-8.gap-2.mb-4');
|
| 336 |
+
|
| 337 |
+
let isRecording = false;
|
| 338 |
+
let recordedSequence = [];
|
| 339 |
+
let recordingStartTime;
|
| 340 |
+
let sequenceSteps = Array(16).fill(null).map(() => ({}));
|
| 341 |
+
|
| 342 |
+
// Initialize sequence grid
|
| 343 |
+
function initSequenceGrid() {
|
| 344 |
+
sequenceGrid.innerHTML = '';
|
| 345 |
+
for (let i = 0; i < 16; i++) {
|
| 346 |
+
const step = document.createElement('div');
|
| 347 |
+
step.className = 'h-8 bg-gray-700 rounded cursor-pointer hover:bg-gray-600 step';
|
| 348 |
+
step.dataset.step = i;
|
| 349 |
+
step.addEventListener('click', (e) => {
|
| 350 |
+
const sounds = ['kick', 'snare', 'hihat', 'clap', 'tom'];
|
| 351 |
+
|
| 352 |
+
// Find next sound in the cycle
|
| 353 |
+
let nextSound = 'kick';
|
| 354 |
+
if (sequenceSteps[i].sound) {
|
| 355 |
+
const currentIndex = sounds.indexOf(sequenceSteps[i].sound);
|
| 356 |
+
nextSound = sounds[(currentIndex + 1) % sounds.length];
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
toggleStep(i, nextSound);
|
| 360 |
+
playSound(nextSound); // Play the sound for feedback
|
| 361 |
+
});
|
| 362 |
+
sequenceGrid.appendChild(step);
|
| 363 |
+
}
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
function toggleStep(stepIndex, sound = 'kick') {
|
| 367 |
+
if (sequenceSteps[stepIndex].sound === sound) {
|
| 368 |
+
sequenceSteps[stepIndex] = {};
|
| 369 |
+
} else {
|
| 370 |
+
sequenceSteps[stepIndex] = { sound: sound };
|
| 371 |
+
}
|
| 372 |
+
updateSequenceGrid();
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
function updateSequenceGrid() {
|
| 376 |
+
const steps = document.querySelectorAll('.step');
|
| 377 |
+
steps.forEach((step, i) => {
|
| 378 |
+
// Reset step classes
|
| 379 |
+
step.className = 'h-8 bg-gray-700 rounded cursor-pointer hover:bg-gray-600 step';
|
| 380 |
+
|
| 381 |
+
if (sequenceSteps[i].sound) {
|
| 382 |
+
step.classList.add(sequenceSteps[i].sound);
|
| 383 |
+
}
|
| 384 |
+
});
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
recordBtn.addEventListener('click', () => {
|
| 388 |
+
isRecording = !isRecording;
|
| 389 |
+
if (isRecording) {
|
| 390 |
+
recordBtn.innerHTML = '<i class="fas fa-stop"></i> Stop';
|
| 391 |
+
recordBtn.classList.remove('bg-red-600');
|
| 392 |
+
recordBtn.classList.add('bg-red-700');
|
| 393 |
+
recordedSequence = [];
|
| 394 |
+
recordingStartTime = Date.now();
|
| 395 |
+
|
| 396 |
+
// Add event listeners to track pad presses
|
| 397 |
+
pads.forEach(pad => {
|
| 398 |
+
pad.addEventListener('mousedown', recordPadPress);
|
| 399 |
+
pad.addEventListener('touchstart', recordPadPress);
|
| 400 |
+
});
|
| 401 |
+
} else {
|
| 402 |
+
recordBtn.innerHTML = '<i class="fas fa-circle"></i> Record';
|
| 403 |
+
recordBtn.classList.add('bg-red-600');
|
| 404 |
+
recordBtn.classList.remove('bg-red-700');
|
| 405 |
+
|
| 406 |
+
// Convert recorded sequence into 16 steps
|
| 407 |
+
processRecordedSequence();
|
| 408 |
+
|
| 409 |
+
// Remove event listeners
|
| 410 |
+
pads.forEach(pad => {
|
| 411 |
+
pad.removeEventListener('mousedown', recordPadPress);
|
| 412 |
+
pad.removeEventListener('touchstart', recordPadPress);
|
| 413 |
+
});
|
| 414 |
+
}
|
| 415 |
+
});
|
| 416 |
+
|
| 417 |
+
function recordPadPress(e) {
|
| 418 |
+
e.preventDefault();
|
| 419 |
+
const sound = e.target.closest('.pad').dataset.sound;
|
| 420 |
+
const timestamp = Date.now() - recordingStartTime;
|
| 421 |
+
recordedSequence.push({
|
| 422 |
+
sound: sound,
|
| 423 |
+
time: timestamp
|
| 424 |
+
});
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
function processRecordedSequence() {
|
| 428 |
+
if (recordedSequence.length === 0) return;
|
| 429 |
+
|
| 430 |
+
const totalDuration = recordedSequence[recordedSequence.length - 1].time;
|
| 431 |
+
const stepDuration = totalDuration / 16;
|
| 432 |
+
|
| 433 |
+
// Clear previous sequence
|
| 434 |
+
sequenceSteps = Array(16).fill(null).map(() => ({}));
|
| 435 |
+
|
| 436 |
+
// Map recorded sounds to steps
|
| 437 |
+
recordedSequence.forEach(event => {
|
| 438 |
+
const stepIndex = Math.min(15, Math.floor(event.time / stepDuration));
|
| 439 |
+
sequenceSteps[stepIndex].sound = event.sound;
|
| 440 |
+
});
|
| 441 |
+
|
| 442 |
+
updateSequenceGrid();
|
| 443 |
+
console.log('Processed sequence:', sequenceSteps);
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
clearBtn.addEventListener('click', () => {
|
| 447 |
+
sequenceSteps = Array(16).fill(null).map(() => ({}));
|
| 448 |
+
updateSequenceGrid();
|
| 449 |
+
});
|
| 450 |
+
|
| 451 |
+
saveBtn.addEventListener('click', () => {
|
| 452 |
+
alert('Sequence saved! (Demo functionality)');
|
| 453 |
+
});
|
| 454 |
+
|
| 455 |
+
// Audio recording functions
|
| 456 |
+
async function startAudioRecording() {
|
| 457 |
+
audioChunks = [];
|
| 458 |
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
| 459 |
+
mediaRecorder = new MediaRecorder(stream);
|
| 460 |
+
mediaRecorder.ondataavailable = (e) => audioChunks.push(e.data);
|
| 461 |
+
mediaRecorder.onstop = () => {
|
| 462 |
+
const audioBlob = new Blob(audioChunks, { type: 'audio/mp3' });
|
| 463 |
+
const audioUrl = URL.createObjectURL(audioBlob);
|
| 464 |
+
saveAudioBtn.onclick = () => {
|
| 465 |
+
const a = document.createElement('a');
|
| 466 |
+
a.href = audioUrl;
|
| 467 |
+
a.download = `dj-mix-${new Date().toISOString().slice(0,19)}.mp3`;
|
| 468 |
+
a.click();
|
| 469 |
+
};
|
| 470 |
+
saveAudioBtn.classList.remove('hidden');
|
| 471 |
+
};
|
| 472 |
+
mediaRecorder.start();
|
| 473 |
+
isAudioRecording = true;
|
| 474 |
+
audioRecordingStatus.classList.remove('hidden');
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
function stopAudioRecording() {
|
| 478 |
+
if (!mediaRecorder) return;
|
| 479 |
+
mediaRecorder.stop();
|
| 480 |
+
mediaRecorder.stream.getTracks().forEach(track => track.stop());
|
| 481 |
+
isAudioRecording = false;
|
| 482 |
+
audioRecordingStatus.classList.add('hidden');
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
+
// Audio recording toggle button
|
| 486 |
+
document.getElementById('record-btn').addEventListener('click', async (e) => {
|
| 487 |
+
if (!isAudioRecording) {
|
| 488 |
+
try {
|
| 489 |
+
await startAudioRecording();
|
| 490 |
+
} catch (err) {
|
| 491 |
+
console.error('Recording failed:', err);
|
| 492 |
+
alert('Could not start audio recording. Please check microphone permissions.');
|
| 493 |
+
}
|
| 494 |
+
} else {
|
| 495 |
+
stopAudioRecording();
|
| 496 |
+
}
|
| 497 |
+
});
|
| 498 |
+
|
| 499 |
+
// Initialize
|
| 500 |
+
initSequenceGrid();
|
| 501 |
+
|
| 502 |
+
// For mobile, we need to handle audio context on touch
|
| 503 |
+
document.body.addEventListener('touchstart', function() {
|
| 504 |
+
// Resume audio context on first touch (iOS requirement)
|
| 505 |
+
if (audioCtx.state === 'suspended') {
|
| 506 |
+
audioCtx.resume();
|
| 507 |
+
}
|
| 508 |
+
}, { once: true });
|
| 509 |
+
|
| 510 |
+
document.body.addEventListener('mousedown', function() {
|
| 511 |
+
// Resume audio context on first click
|
| 512 |
+
if (audioCtx.state === 'suspended') {
|
| 513 |
+
audioCtx.resume();
|
| 514 |
+
}
|
| 515 |
+
}, { once: true });
|
| 516 |
+
});
|
| 517 |
+
</script>
|
| 518 |
+
<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=AnonymousSub/dj-beatz" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 519 |
+
</html>
|
prompts.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Generate a dj beats pad with proper working sounds for mobile
|
| 2 |
+
Record is not working
|
| 3 |
+
Sequence me only one type of sound can be added, why
|
| 4 |
+
Sure proper colour in
|
| 5 |
+
Show proper colour in sequence
|
| 6 |
+
What happens when u press record, it should save it somewhere as mp3 or something
|