sa-rawa-tech / index.html
GeorgeFiji's picture
undefined - Initial Deployment
cd139cb verified
Raw History Blame Contribute Delete
25.1 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Musical Fun for Little Ones</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@keyframes bounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-20px); }
}
.bounce {
animation: bounce 1s infinite;
}
.key-white {
transition: all 0.1s;
}
.key-white:active, .key-white.active {
background: #fbcfe8 !important;
transform: scale(0.98);
}
.key-black {
transition: all 0.1s;
}
.key-black:active, .key-black.active {
background: #7e22ce !important;
transform: scale(0.95);
}
.animal-btn:active, .animal-btn.active {
transform: scale(0.95);
box-shadow: 0 0 0 4px rgba(236, 72, 153, 0.3);
}
.rainbow-bg {
background: linear-gradient(90deg,
rgba(255,0,0,0.7) 0%,
rgba(255,165,0,0.7) 20%,
rgba(255,255,0,0.7) 40%,
rgba(0,128,0,0.7) 60%,
rgba(0,0,255,0.7) 80%,
rgba(128,0,128,0.7) 100%);
}
</style>
</head>
<body class="bg-pink-50 min-h-screen flex flex-col items-center p-4">
<header class="text-center mb-6">
<h1 class="text-4xl md:text-5xl font-bold rainbow-bg text-white py-4 px-8 rounded-full shadow-lg mb-2">
<i class="fas fa-music mr-2"></i> Musical Fun!
</h1>
<p class="text-lg text-pink-700">Tap, play, and learn about music!</p>
</header>
<main class="w-full max-w-4xl flex flex-col items-center">
<!-- Game Mode Selector -->
<div class="flex space-x-2 mb-8">
<button onclick="setGameMode('piano')" class="game-mode-btn bg-purple-500 hover:bg-purple-600 text-white px-4 py-2 rounded-full transition">
<i class="fas fa-keyboard mr-1"></i> Piano
</button>
<button onclick="setGameMode('animals')" class="game-mode-btn bg-yellow-500 hover:bg-yellow-600 text-white px-4 py-2 rounded-full transition">
<i class="fas fa-paw mr-1"></i> Animal Sounds
</button>
<button onclick="setGameMode('rhythm')" class="game-mode-btn bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-full transition">
<i class="fas fa-drum mr-1"></i> Rhythm Game
</button>
</div>
<!-- Piano Keyboard -->
<div id="piano-mode" class="game-mode w-full bg-white rounded-xl shadow-lg p-4 mb-6">
<h2 class="text-2xl font-bold text-center text-purple-700 mb-4">
<i class="fas fa-keyboard mr-2"></i> Colorful Piano
</h2>
<div class="flex justify-center mb-4">
<div class="relative" style="width: 300px; height: 180px;">
<!-- White Keys -->
<div class="absolute flex" style="width: 300px;">
<div data-note="C" class="key-white w-12 h-40 bg-white border border-gray-200 rounded-b-md cursor-pointer flex items-end justify-center pb-2 font-bold text-purple-600" style="z-index: 1;">Do</div>
<div data-note="D" class="key-white w-12 h-40 bg-white border border-gray-200 rounded-b-md cursor-pointer flex items-end justify-center pb-2 font-bold text-blue-600" style="z-index: 1;">Re</div>
<div data-note="E" class="key-white w-12 h-40 bg-white border border-gray-200 rounded-b-md cursor-pointer flex items-end justify-center pb-2 font-bold text-green-600" style="z-index: 1;">Mi</div>
<div data-note="F" class="key-white w-12 h-40 bg-white border border-gray-200 rounded-b-md cursor-pointer flex items-end justify-center pb-2 font-bold text-yellow-600" style="z-index: 1;">Fa</div>
<div data-note="G" class="key-white w-12 h-40 bg-white border border-gray-200 rounded-b-md cursor-pointer flex items-end justify-center pb-2 font-bold text-orange-600" style="z-index: 1;">Sol</div>
<div data-note="A" class="key-white w-12 h-40 bg-white border border-gray-200 rounded-b-md cursor-pointer flex items-end justify-center pb-2 font-bold text-red-600" style="z-index: 1;">La</div>
<div data-note="B" class="key-white w-12 h-40 bg-white border border-gray-200 rounded-b-md cursor-pointer flex items-end justify-center pb-2 font-bold text-pink-600" style="z-index: 1;">Ti</div>
</div>
<!-- Black Keys -->
<div class="absolute flex" style="width: 300px; padding-left: 9px;">
<div data-note="C#" class="key-black w-8 h-24 bg-gray-800 rounded-b-md cursor-pointer ml-3" style="z-index: 2;"></div>
<div data-note="D#" class="key-black w-8 h-24 bg-gray-800 rounded-b-md cursor-pointer ml-5" style="z-index: 2;"></div>
<div class="w-12"></div> <!-- spacer -->
<div data-note="F#" class="key-black w-8 h-24 bg-gray-800 rounded-b-md cursor-pointer ml-3" style="z-index: 2;"></div>
<div data-note="G#" class="key-black w-8 h-24 bg-gray-800 rounded-b-md cursor-pointer ml-5" style="z-index: 2;"></div>
<div data-note="A#" class="key-black w-8 h-24 bg-gray-800 rounded-b-md cursor-pointer ml-5" style="z-index: 2;"></div>
</div>
</div>
</div>
<div class="text-center">
<button onclick="playSimpleSong()" class="bg-purple-500 hover:bg-purple-600 text-white px-4 py-2 rounded-full transition">
<i class="fas fa-play mr-1"></i> Play Twinkle Twinkle
</button>
</div>
</div>
<!-- Animal Sounds -->
<div id="animals-mode" class="game-mode hidden w-full bg-white rounded-xl shadow-lg p-4 mb-6">
<h2 class="text-2xl font-bold text-center text-yellow-700 mb-4">
<i class="fas fa-paw mr-2"></i> Musical Animals
</h2>
<p class="text-center mb-4 text-gray-600">Tap the animals to hear their sounds and music!</p>
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
<button data-sound="cat" class="animal-btn bg-pink-100 hover:bg-pink-200 rounded-xl p-4 flex flex-col items-center transition">
<i class="fas fa-cat text-5xl text-pink-500 mb-2"></i>
<span class="font-bold text-pink-700">Meow!</span>
</button>
<button data-sound="dog" class="animal-btn bg-blue-100 hover:bg-blue-200 rounded-xl p-4 flex flex-col items-center transition">
<i class="fas fa-dog text-5xl text-blue-500 mb-2"></i>
<span class="font-bold text-blue-700">Woof!</span>
</button>
<button data-sound="cow" class="animal-btn bg-purple-100 hover:bg-purple-200 rounded-xl p-4 flex flex-col items-center transition">
<i class="fas fa-cow text-5xl text-purple-500 mb-2"></i>
<span class="font-bold text-purple-700">Moo!</span>
</button>
<button data-sound="bird" class="animal-btn bg-green-100 hover:bg-green-200 rounded-xl p-4 flex flex-col items-center transition">
<i class="fas fa-dove text-5xl text-green-500 mb-2"></i>
<span class="font-bold text-green-700">Tweet!</span>
</button>
<button data-sound="lion" class="animal-btn bg-yellow-100 hover:bg-yellow-200 rounded-xl p-4 flex flex-col items-center transition">
<i class="fas fa-lion text-5xl text-yellow-500 mb-2"></i>
<span class="font-bold text-yellow-700">Roar!</span>
</button>
<button data-sound="frog" class="animal-btn bg-red-100 hover:bg-red-200 rounded-xl p-4 flex flex-col items-center transition">
<i class="fas fa-frog text-5xl text-red-500 mb-2"></i>
<span class="font-bold text-red-700">Ribbit!</span>
</button>
<button data-sound="elephant" class="animal-btn bg-indigo-100 hover:bg-indigo-200 rounded-xl p-4 flex flex-col items-center transition">
<i class="fas fa-elephant text-5xl text-indigo-500 mb-2"></i>
<span class="font-bold text-indigo-700">Trumpet!</span>
</button>
<button data-sound="music" class="animal-btn bg-rainbow-100 hover:bg-rainbow-200 rounded-xl p-4 flex flex-col items-center transition rainbow-bg">
<i class="fas fa-music text-5xl text-white mb-2"></i>
<span class="font-bold text-white">All Together!</span>
</button>
</div>
</div>
<!-- Rhythm Game -->
<div id="rhythm-mode" class="game-mode hidden w-full bg-white rounded-xl shadow-lg p-4 mb-6">
<h2 class="text-2xl font-bold text-center text-blue-700 mb-4">
<i class="fas fa-drum mr-2"></i> Tap the Rhythm!
</h2>
<div class="flex justify-center mb-6">
<div class="relative w-64 h-64 bg-blue-50 rounded-full flex items-center justify-center">
<div id="rhythm-circle" class="absolute w-56 h-56 bg-blue-100 rounded-full flex items-center justify-center cursor-pointer shadow-inner">
<div class="text-center">
<p class="text-xl font-bold text-blue-700">Tap Here</p>
<p id="rhythm-pattern" class="text-lg text-blue-500">🐘 🐘 🐸 🐸</p>
</div>
</div>
<div id="rhythm-indicator" class="absolute w-16 h-16 bg-yellow-400 rounded-full bounce" style="top: 20px; left: 50%; transform: translateX(-50%);"></div>
</div>
</div>
<div class="text-center">
<button onclick="startRhythmGame()" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-full transition">
<i class="fas fa-play mr-1"></i> Start Game
</button>
<button onclick="changeRhythmPattern()" class="ml-2 bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded-full transition">
<i class="fas fa-random mr-1"></i> New Pattern
</button>
</div>
</div>
<!-- Feedback Area -->
<div id="feedback" class="fixed bottom-4 left-1/2 transform -translate-x-1/2 bg-pink-500 text-white px-6 py-3 rounded-full shadow-lg opacity-0 transition-opacity duration-300">
<i class="fas fa-star mr-2"></i> <span>Great job!</span>
</div>
</main>
<footer class="mt-8 text-center text-gray-500 text-sm">
<p>Made with <i class="fas fa-heart text-pink-500"></i> for little musicians</p>
</footer>
<script>
// Audio context and sounds
let audioContext;
let oscillators = {};
let animalSounds = {
'cat': { pitch: 523.25, duration: 0.3 },
'dog': { pitch: 261.63, duration: 0.5 },
'cow': { pitch: 196.00, duration: 0.8 },
'bird': { pitch: 1046.50, duration: 0.2 },
'lion': { pitch: 87.31, duration: 1.0 },
'frog': { pitch: 293.66, duration: 0.4 },
'elephant': { pitch: 65.41, duration: 1.2 },
'music': { pitch: 'chord', duration: 1.5 }
};
// Piano notes frequencies
const pianoNotes = {
'C': 261.63, 'C#': 277.18, 'D': 293.66, 'D#': 311.13,
'E': 329.63, 'F': 349.23, 'F#': 369.99, 'G': 392.00,
'G#': 415.30, 'A': 440.00, 'A#': 466.16, 'B': 493.88
};
// Initialize audio context on first interaction
function initAudio() {
if (!audioContext) {
audioContext = new (window.AudioContext || window.webkitAudioContext)();
}
}
// Game mode switching
function setGameMode(mode) {
document.querySelectorAll('.game-mode').forEach(el => el.classList.add('hidden'));
document.getElementById(`${mode}-mode`).classList.remove('hidden');
// Highlight selected button
document.querySelectorAll('.game-mode-btn').forEach(btn => {
btn.classList.remove('ring-4', 'ring-pink-300');
});
event.target.classList.add('ring-4', 'ring-pink-300');
showFeedback(`Let's play ${mode}!`);
}
// Piano functionality
function setupPiano() {
const keys = document.querySelectorAll('.key-white, .key-black');
keys.forEach(key => {
// Mouse/touch events
key.addEventListener('mousedown', () => playNote(key.dataset.note));
key.addEventListener('mouseup', () => stopNote(key.dataset.note));
key.addEventListener('mouseleave', () => stopNote(key.dataset.note));
// Touch events for mobile
key.addEventListener('touchstart', (e) => {
e.preventDefault();
key.classList.add('active');
playNote(key.dataset.note);
});
key.addEventListener('touchend', (e) => {
e.preventDefault();
key.classList.remove('active');
stopNote(key.dataset.note);
});
});
}
function playNote(note) {
initAudio();
stopNote(note); // Stop any existing oscillator for this note
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
oscillator.type = 'sine';
oscillator.frequency.value = pianoNotes[note];
gainNode.gain.value = 0.3;
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.start();
oscillators[note] = { oscillator, gainNode };
// Visual feedback
document.querySelector(`[data-note="${note}"]`).classList.add('active');
}
function stopNote(note) {
if (oscillators[note]) {
oscillators[note].gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime + 0.03);
oscillators[note].oscillator.stop(audioContext.currentTime + 0.03);
delete oscillators[note];
// Remove visual feedback
document.querySelector(`[data-note="${note}"]`).classList.remove('active');
}
}
function playSimpleSong() {
initAudio();
const sequence = [
{note: 'C', duration: 0.5}, {note: 'C', duration: 0.5},
{note: 'G', duration: 0.5}, {note: 'G', duration: 0.5},
{note: 'A', duration: 0.5}, {note: 'A', duration: 0.5},
{note: 'G', duration: 1},
{note: 'F', duration: 0.5}, {note: 'F', duration: 0.5},
{note: 'E', duration: 0.5}, {note: 'E', duration: 0.5},
{note: 'D', duration: 0.5}, {note: 'D', duration: 0.5},
{note: 'C', duration: 1}
];
let time = audioContext.currentTime;
sequence.forEach((step, i) => {
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
oscillator.type = 'sine';
oscillator.frequency.value = pianoNotes[step.note];
gainNode.gain.value = 0.3;
gainNode.gain.setValueAtTime(0.3, time);
gainNode.gain.exponentialRampToValueAtTime(0.001, time + step.duration * 0.9);
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.start(time);
oscillator.stop(time + step.duration);
// Visual feedback
const key = document.querySelector(`[data-note="${step.note}"]`);
key.classList.add('active');
setTimeout(() => key.classList.remove('active'), (time - audioContext.currentTime) * 1000 + step.duration * 500);
time += step.duration;
});
showFeedback("Twinkle twinkle little star!");
}
// Animal sounds functionality
function setupAnimalSounds() {
const buttons = document.querySelectorAll('.animal-btn');
buttons.forEach(btn => {
btn.addEventListener('click', () => {
const sound = btn.dataset.sound;
playAnimalSound(sound);
// Visual feedback
btn.classList.add('active');
setTimeout(() => btn.classList.remove('active'), 300);
showFeedback(btn.querySelector('span').textContent);
});
});
}
function playAnimalSound(animal) {
initAudio();
if (animal === 'music') {
// Play a chord with all animal sounds
const animals = ['cat', 'bird', 'dog', 'frog'];
const time = audioContext.currentTime;
animals.forEach((a, i) => {
setTimeout(() => playSingleAnimalSound(a), i * 300);
});
return;
}
playSingleAnimalSound(animal);
}
function playSingleAnimalSound(animal) {
const sound = animalSounds[animal];
if (sound.pitch === 'chord') {
// Play a major chord
const notes = [261.63, 329.63, 392.00]; // C, E, G
const time = audioContext.currentTime;
notes.forEach(freq => {
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
oscillator.type = 'sine';
oscillator.frequency.value = freq;
gainNode.gain.value = 0.2;
gainNode.gain.exponentialRampToValueAtTime(0.001, time + sound.duration);
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.start(time);
oscillator.stop(time + sound.duration);
});
return;
}
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
// Different waveforms for different animals
if (animal === 'cat') oscillator.type = 'sine';
else if (animal === 'dog') oscillator.type = 'sawtooth';
else if (animal === 'cow') oscillator.type = 'square';
else if (animal === 'bird') oscillator.type = 'triangle';
else oscillator.type = 'sine';
oscillator.frequency.value = sound.pitch;
gainNode.gain.value = 0.3;
gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime + sound.duration);
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.start();
oscillator.stop(audioContext.currentTime + sound.duration);
}
// Rhythm game functionality
let currentPattern = ['🐘', '🐘', '🐸', '🐸'];
let rhythmGameInterval;
let currentStep = 0;
function setupRhythmGame() {
const circle = document.getElementById('rhythm-circle');
circle.addEventListener('click', () => {
if (!rhythmGameInterval) return;
circle.classList.add('bg-blue-200');
setTimeout(() => circle.classList.remove('bg-blue-200'), 200);
// Check if tap matches the current step
const expectedAnimal = currentPattern[currentStep % currentPattern.length];
const feedback = expectedAnimal === '🐘' ? "Big elephant stomp!" : "Little frog hop!";
showFeedback(feedback);
currentStep++;
updateRhythmIndicator();
});
}
function startRhythmGame() {
if (rhythmGameInterval) clearInterval(rhythmGameInterval);
currentStep = 0;
updateRhythmIndicator();
// Start the rhythm indicator animation
rhythmGameInterval = setInterval(() => {
currentStep++;
updateRhythmIndicator();
}, 800);
showFeedback("Follow the bouncing ball!");
}
function updateRhythmIndicator() {
const indicator = document.getElementById('rhythm-indicator');
const positions = [
{ top: '20px', left: '50%' }, // top
{ top: '50%', left: '80%' }, // right
{ top: '80%', left: '50%' }, // bottom
{ top: '50%', left: '20%' } // left
];
const pos = positions[currentStep % 4];
indicator.style.top = pos.top;
indicator.style.left = pos.left;
// Change color based on current animal in pattern
const currentAnimal = currentPattern[currentStep % currentPattern.length];
indicator.className = currentAnimal === '🐘' ?
'absolute w-16 h-16 bg-purple-400 rounded-full bounce' :
'absolute w-16 h-16 bg-green-400 rounded-full bounce';
}
function changeRhythmPattern() {
const patterns = [
['🐘', '🐘', '🐸', '🐸'],
['🐘', '🐸', '🐘', '🐸'],
['🐸', '🐸', '🐘', '🐘'],
['🐘', '🐸', '🐸', '🐘']
];
currentPattern = patterns[Math.floor(Math.random() * patterns.length)];
document.getElementById('rhythm-pattern').textContent = currentPattern.join(' ');
showFeedback("New pattern! " + currentPattern.join(' '));
}
// Feedback system
function showFeedback(message) {
const feedback = document.getElementById('feedback');
feedback.querySelector('span').textContent = message;
feedback.classList.remove('opacity-0');
feedback.classList.add('opacity-100');
setTimeout(() => {
feedback.classList.remove('opacity-100');
feedback.classList.add('opacity-0');
}, 2000);
}
// Initialize everything when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
setupPiano();
setupAnimalSounds();
setupRhythmGame();
setGameMode('piano');
});
</script>
<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=GeorgeFiji/sa-rawa-tech" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>