Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- index.html +333 -263
index.html
CHANGED
|
@@ -1,168 +1,185 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
|
|
|
| 3 |
<head>
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
.
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
</head>
|
|
|
|
| 125 |
<body>
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
class="w-32 h-2 bg-white/30 rounded-lg appearance-none cursor-pointer">
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
<i class="fas fa-random mr-2"></i>Random Play
|
| 147 |
</button>
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
<!-- Main Content -->
|
| 153 |
-
<main class="container mx-auto px-4 pb-32">
|
| 154 |
-
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4" id="soundGrid">
|
| 155 |
-
<!-- Sound buttons will be generated here -->
|
| 156 |
-
</div>
|
| 157 |
-
</main>
|
| 158 |
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
|
|
|
| 162 |
</div>
|
|
|
|
| 163 |
|
| 164 |
-
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
| 167 |
let masterGainNode = audioContext.createGain();
|
| 168 |
masterGainNode.connect(audioContext.destination);
|
|
@@ -189,7 +206,17 @@
|
|
| 189 |
{ id: 17, name: 'Fire', icon: 'fa-fire', category: 'element' },
|
| 190 |
{ id: 18, name: 'Thunder', icon: 'fa-cloud-bolt', category: 'element' },
|
| 191 |
{ id: 19, name: 'Level Up', icon: 'fa-trophy', category: 'ui' },
|
| 192 |
-
{ id: 20, name: 'Game Over', icon: 'fa-skull', category: 'ui' }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
];
|
| 194 |
|
| 195 |
// Sound synthesis functions
|
|
@@ -670,117 +697,160 @@
|
|
| 670 |
|
| 671 |
osc.start(audioContext.currentTime);
|
| 672 |
osc.stop(audioContext.currentTime + 1);
|
| 673 |
-
}
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 699 |
|
| 700 |
-
|
| 701 |
-
const
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
|
|
|
| 717 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 718 |
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
audioContext.
|
| 728 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 729 |
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 734 |
|
| 735 |
-
//
|
| 736 |
-
|
| 737 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 738 |
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
}, 500);
|
| 742 |
-
}
|
| 743 |
-
|
| 744 |
-
// Volume control
|
| 745 |
-
const volumeControl = document.getElementById('volumeControl');
|
| 746 |
-
const volumeValue = document.getElementById('volumeValue');
|
| 747 |
-
|
| 748 |
-
volumeControl.addEventListener('input', (e) => {
|
| 749 |
-
const value = e.target.value;
|
| 750 |
-
masterGainNode.gain.value = value / 100;
|
| 751 |
-
volumeValue.textContent = `${value}%`;
|
| 752 |
-
});
|
| 753 |
-
|
| 754 |
-
// Random play
|
| 755 |
-
document.getElementById('randomPlay').addEventListener('click', () => {
|
| 756 |
-
const randomIndex = Math.floor(Math.random() * sounds.length);
|
| 757 |
-
const randomSound = sounds[randomIndex];
|
| 758 |
-
const buttons = document.querySelectorAll('.sound-button');
|
| 759 |
-
playSound(randomSound.id, buttons[randomIndex]);
|
| 760 |
-
});
|
| 761 |
-
|
| 762 |
-
// Initialize
|
| 763 |
-
createSoundButtons();
|
| 764 |
-
createVisualizer();
|
| 765 |
-
|
| 766 |
-
// Periodic visualizer animation
|
| 767 |
-
setInterval(() => {
|
| 768 |
-
if (audioContext.state === 'running') {
|
| 769 |
-
animateVisualizer();
|
| 770 |
-
}
|
| 771 |
-
}, 100);
|
| 772 |
-
|
| 773 |
-
// Add footer link
|
| 774 |
-
const footer = document.createElement('footer');
|
| 775 |
-
footer.className = 'fixed bottom-24 left-0 right-0 text-center p-2';
|
| 776 |
-
footer.innerHTML = `
|
| 777 |
-
<a href="https://huggingface.co/spaces/akhaliq/anycoder"
|
| 778 |
-
target="_blank"
|
| 779 |
-
class="text-white/80 hover:text-white text-sm transition-colors">
|
| 780 |
-
Built with anycoder
|
| 781 |
-
</a>
|
| 782 |
-
`;
|
| 783 |
-
document.body.appendChild(footer);
|
| 784 |
-
</script>
|
| 785 |
-
</body>
|
| 786 |
-
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
+
|
| 4 |
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
+
<title>Game Sound Synthesizer - 30 Effects</title>
|
| 8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 10 |
+
<style>
|
| 11 |
+
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');
|
| 12 |
+
|
| 13 |
+
* {
|
| 14 |
+
margin: 0;
|
| 15 |
+
padding: 0;
|
| 16 |
+
box-sizing: border-box;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
body {
|
| 20 |
+
font-family: 'Orbitron', monospace;
|
| 21 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 22 |
+
min-height: 100vh;
|
| 23 |
+
overflow-x: hidden;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
.sound-button {
|
| 27 |
+
background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
|
| 28 |
+
backdrop-filter: blur(10px);
|
| 29 |
+
border: 2px solid rgba(255, 255, 255, 0.2);
|
| 30 |
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
| 31 |
+
position: relative;
|
| 32 |
+
overflow: hidden;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
.sound-button::before {
|
| 36 |
+
content: '';
|
| 37 |
+
position: absolute;
|
| 38 |
+
top: 50%;
|
| 39 |
+
left: 50%;
|
| 40 |
+
width: 0;
|
| 41 |
+
height: 0;
|
| 42 |
+
border-radius: 50%;
|
| 43 |
+
background: rgba(255, 255, 255, 0.5);
|
| 44 |
+
transform: translate(-50%, -50%);
|
| 45 |
+
transition: width 0.6s, height 0.6s;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
.sound-button.playing::before {
|
| 49 |
+
width: 300px;
|
| 50 |
+
height: 300px;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.sound-button:hover {
|
| 54 |
+
transform: translateY(-5px) scale(1.05);
|
| 55 |
+
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
|
| 56 |
+
border-color: rgba(255, 255, 255, 0.4);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
.sound-button:active {
|
| 60 |
+
transform: translateY(-2px) scale(1.02);
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
.visualizer {
|
| 64 |
+
position: fixed;
|
| 65 |
+
bottom: 0;
|
| 66 |
+
left: 0;
|
| 67 |
+
right: 0;
|
| 68 |
+
height: 100px;
|
| 69 |
+
background: rgba(0, 0, 0, 0.3);
|
| 70 |
+
backdrop-filter: blur(10px);
|
| 71 |
+
display: flex;
|
| 72 |
+
align-items: flex-end;
|
| 73 |
+
justify-content: space-around;
|
| 74 |
+
padding: 10px;
|
| 75 |
+
z-index: 10;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.bar {
|
| 79 |
+
width: 3px;
|
| 80 |
+
background: linear-gradient(to top, #00ff88, #00ffff);
|
| 81 |
+
transition: height 0.1s ease;
|
| 82 |
+
border-radius: 2px;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
@keyframes pulse {
|
| 86 |
+
0% {
|
| 87 |
+
transform: scale(1);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
50% {
|
| 91 |
+
transform: scale(1.05);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
100% {
|
| 95 |
+
transform: scale(1);
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
.pulse {
|
| 100 |
+
animation: pulse 0.5s ease-in-out;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
.glass-morphism {
|
| 104 |
+
background: rgba(255, 255, 255, 0.1);
|
| 105 |
+
backdrop-filter: blur(10px);
|
| 106 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
.neon-text {
|
| 110 |
+
text-shadow: 0 0 10px rgba(255, 255, 255, 0.8),
|
| 111 |
+
0 0 20px rgba(255, 255, 255, 0.6),
|
| 112 |
+
0 0 30px rgba(255, 255, 255, 0.4);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
.category-badge {
|
| 116 |
+
background: linear-gradient(135deg, #667eea, #764ba2);
|
| 117 |
+
padding: 2px 8px;
|
| 118 |
+
border-radius: 12px;
|
| 119 |
+
font-size: 10px;
|
| 120 |
+
text-transform: uppercase;
|
| 121 |
+
letter-spacing: 1px;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
@keyframes float {
|
| 125 |
+
|
| 126 |
+
0%,
|
| 127 |
+
100% {
|
| 128 |
+
transform: translateY(0px);
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
50% {
|
| 132 |
+
transform: translateY(-10px);
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
.float-animation {
|
| 137 |
+
animation: float 3s ease-in-out infinite;
|
| 138 |
+
}
|
| 139 |
+
</style>
|
| 140 |
</head>
|
| 141 |
+
|
| 142 |
<body>
|
| 143 |
+
<!-- Header -->
|
| 144 |
+
<header class="glass-morphism sticky top-0 z-50 p-4 mb-8">
|
| 145 |
+
<div class="container mx-auto flex justify-between items-center">
|
| 146 |
+
<div class="flex items-center space-x-4">
|
| 147 |
+
<div class="float-animation">
|
| 148 |
+
<i class="fas fa-gamepad text-3xl text-white"></i>
|
| 149 |
+
</div>
|
| 150 |
+
<div>
|
| 151 |
+
<h1 class="text-2xl font-bold text-white neon-text">Game Sound Synthesizer</h1>
|
| 152 |
+
<p class="text-xs text-gray-200">30 Procedurally Generated Sound Effects</p>
|
| 153 |
+
</div>
|
| 154 |
+
</div>
|
| 155 |
+
<div class="flex items-center space-x-4">
|
| 156 |
+
<div class="flex items-center space-x-2">
|
| 157 |
+
<i class="fas fa-volume-up text-white"></i>
|
| 158 |
+
<input type="range" id="volumeControl" min="0" max="100" value="50"
|
| 159 |
class="w-32 h-2 bg-white/30 rounded-lg appearance-none cursor-pointer">
|
| 160 |
+
<span id="volumeValue" class="text-white text-sm">50%</span>
|
| 161 |
+
</div>
|
| 162 |
+
<button id="randomPlay" class="bg-white/20 hover:bg-white/30 text-white px-4 py-2 rounded-lg transition-all">
|
| 163 |
<i class="fas fa-random mr-2"></i>Random Play
|
| 164 |
</button>
|
| 165 |
+
</div>
|
| 166 |
+
</div>
|
| 167 |
+
</header>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
+
<!-- Main Content -->
|
| 170 |
+
<main class="container mx-auto px-4 pb-32">
|
| 171 |
+
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4" id="soundGrid">
|
| 172 |
+
<!-- Sound buttons will be generated here -->
|
| 173 |
</div>
|
| 174 |
+
</main>
|
| 175 |
|
| 176 |
+
<!-- Visualizer -->
|
| 177 |
+
<div class="visualizer" id="visualizer">
|
| 178 |
+
<!-- Bars will be generated here -->
|
| 179 |
+
</div>
|
| 180 |
+
|
| 181 |
+
<script>
|
| 182 |
+
// Audio Context
|
| 183 |
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
| 184 |
let masterGainNode = audioContext.createGain();
|
| 185 |
masterGainNode.connect(audioContext.destination);
|
|
|
|
| 206 |
{ id: 17, name: 'Fire', icon: 'fa-fire', category: 'element' },
|
| 207 |
{ id: 18, name: 'Thunder', icon: 'fa-cloud-bolt', category: 'element' },
|
| 208 |
{ id: 19, name: 'Level Up', icon: 'fa-trophy', category: 'ui' },
|
| 209 |
+
{ id: 20, name: 'Game Over', icon: 'fa-skull', category: 'ui' },
|
| 210 |
+
{ id: 21, name: 'Menu Click', icon: 'fa-mouse-pointer', category: 'ui' },
|
| 211 |
+
{ id: 22, name: 'Pause', icon: 'fa-pause-circle', category: 'ui' },
|
| 212 |
+
{ id: 23, name: 'Resume', icon: 'fa-play-circle', category: 'ui' },
|
| 213 |
+
{ id: 24, name: 'Achievement', icon: 'fa-medal', category: 'ui' },
|
| 214 |
+
{ id: 25, name: 'Critical Hit', icon: 'fa-crosshairs', category: 'impact' },
|
| 215 |
+
{ id: 26, name: 'Dodge', icon: 'fa-wind', category: 'movement' },
|
| 216 |
+
{ id: 27, name: 'Potion Drink', icon: 'fa-flask', category: 'power' },
|
| 217 |
+
{ id: 28, name: 'Lockpick', icon: 'fa-key', category: 'environment' },
|
| 218 |
+
{ id: 29, name: 'Chest Open', icon: 'fa-box-open', category: 'collect' },
|
| 219 |
+
{ id: 30, name: 'Monster Roar', icon: 'fa-dragon', category: 'creature' }
|
| 220 |
];
|
| 221 |
|
| 222 |
// Sound synthesis functions
|
|
|
|
| 697 |
|
| 698 |
osc.start(audioContext.currentTime);
|
| 699 |
osc.stop(audioContext.currentTime + 1);
|
| 700 |
+
},
|
| 701 |
+
|
| 702 |
+
21: () => { // Menu Click
|
| 703 |
+
const osc = audioContext.createOscillator();
|
| 704 |
+
const gain = audioContext.createGain();
|
| 705 |
+
|
| 706 |
+
osc.connect(gain);
|
| 707 |
+
gain.connect(masterGainNode);
|
| 708 |
+
|
| 709 |
+
osc.type = 'sine';
|
| 710 |
+
osc.frequency.setValueAtTime(800, audioContext.currentTime);
|
| 711 |
+
osc.frequency.exponentialRampToValueAtTime(1200, audioContext.currentTime + 0.05);
|
| 712 |
+
|
| 713 |
+
gain.gain.setValueAtTime(0.2, audioContext.currentTime);
|
| 714 |
+
gain.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.05);
|
| 715 |
+
|
| 716 |
+
osc.start(audioContext.currentTime);
|
| 717 |
+
osc.stop(audioContext.currentTime + 0.05);
|
| 718 |
+
},
|
| 719 |
+
|
| 720 |
+
22: () => { // Pause
|
| 721 |
+
const osc = audioContext.createOscillator();
|
| 722 |
+
const gain = audioContext.createGain();
|
| 723 |
+
|
| 724 |
+
osc.connect(gain);
|
| 725 |
+
gain.connect(masterGainNode);
|
| 726 |
+
|
| 727 |
+
osc.type = 'triangle';
|
| 728 |
+
osc.frequency.setValueAtTime(440, audioContext.currentTime);
|
| 729 |
+
osc.frequency.linearRampToValueAtTime(220, audioContext.currentTime + 0.2);
|
| 730 |
+
|
| 731 |
+
gain.gain.setValueAtTime(0.15, audioContext.currentTime);
|
| 732 |
+
gain.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.2);
|
| 733 |
+
|
| 734 |
+
osc.start(audioContext.currentTime);
|
| 735 |
+
osc.stop(audioContext.currentTime + 0.2);
|
| 736 |
+
},
|
| 737 |
+
|
| 738 |
+
23: () => { // Resume
|
| 739 |
+
const osc = audioContext.createOscillator();
|
| 740 |
+
const gain = audioContext.createGain();
|
| 741 |
+
|
| 742 |
+
osc.connect(gain);
|
| 743 |
+
gain.connect(masterGainNode);
|
| 744 |
+
|
| 745 |
+
osc.type = 'triangle';
|
| 746 |
+
osc.frequency.setValueAtTime(220, audioContext.currentTime);
|
| 747 |
+
osc.frequency.linearRampToValueAtTime(440, audioContext.currentTime + 0.2);
|
| 748 |
+
|
| 749 |
+
gain.gain.setValueAtTime(0.15, audioContext.currentTime);
|
| 750 |
+
gain.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.2);
|
| 751 |
+
|
| 752 |
+
osc.start(audioContext.currentTime);
|
| 753 |
+
osc.stop(audioContext.currentTime + 0.2);
|
| 754 |
+
},
|
| 755 |
|
| 756 |
+
24: () => { // Achievement
|
| 757 |
+
const notes = [523.25, 659.25, 783.99, 1046.5];
|
| 758 |
+
notes.forEach((freq, i) => {
|
| 759 |
+
const osc = audioContext.createOscillator();
|
| 760 |
+
const gain = audioContext.createGain();
|
| 761 |
+
|
| 762 |
+
osc.connect(gain);
|
| 763 |
+
gain.connect(masterGainNode);
|
| 764 |
+
|
| 765 |
+
osc.frequency.value = freq;
|
| 766 |
+
osc.type = 'sine';
|
| 767 |
+
|
| 768 |
+
gain.gain.setValueAtTime(0, audioContext.currentTime + i * 0.08);
|
| 769 |
+
gain.gain.linearRampToValueAtTime(0.25, audioContext.currentTime + i * 0.08 + 0.05);
|
| 770 |
+
gain.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + i * 0.08 + 0.3);
|
| 771 |
+
|
| 772 |
+
osc.start(audioContext.currentTime + i * 0.08);
|
| 773 |
+
osc.stop(audioContext.currentTime + i * 0.08 + 0.3);
|
| 774 |
});
|
| 775 |
+
},
|
| 776 |
+
|
| 777 |
+
25: () => { // Critical Hit
|
| 778 |
+
const osc = audioContext.createOscillator();
|
| 779 |
+
const gain = audioContext.createGain();
|
| 780 |
+
const filter = audioContext.createBiquadFilter();
|
| 781 |
|
| 782 |
+
osc.connect(filter);
|
| 783 |
+
filter.connect(gain);
|
| 784 |
+
gain.connect(masterGainNode);
|
| 785 |
+
|
| 786 |
+
osc.type = 'sawtooth';
|
| 787 |
+
osc.frequency.setValueAtTime(100, audioContext.currentTime);
|
| 788 |
+
|
| 789 |
+
filter.type = 'highpass';
|
| 790 |
+
filter.frequency.setValueAtTime(500, audioContext.currentTime);
|
| 791 |
+
filter.Q.value = 15;
|
| 792 |
+
|
| 793 |
+
gain.gain.setValueAtTime(0.5, audioContext.currentTime);
|
| 794 |
+
gain.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.3);
|
| 795 |
+
|
| 796 |
+
osc.start(audioContext.currentTime);
|
| 797 |
+
osc.stop(audioContext.currentTime + 0.3);
|
| 798 |
+
},
|
| 799 |
|
| 800 |
+
26: () => { // Dodge
|
| 801 |
+
const noise = audioContext.createBufferSource();
|
| 802 |
+
const filter = audioContext.createBiquadFilter();
|
| 803 |
+
const gain = audioContext.createGain();
|
| 804 |
+
const bufferSize = audioContext.sampleRate * 0.15;
|
| 805 |
+
const buffer = audioContext.createBuffer(1, bufferSize, audioContext.sampleRate);
|
| 806 |
+
const output = buffer.getChannelData(0);
|
| 807 |
+
|
| 808 |
+
for (let i = 0; i < bufferSize; i++) {
|
| 809 |
+
output[i] = (Math.random() * 2 - 1) * Math.exp(-i / (bufferSize * 0.2));
|
| 810 |
+
}
|
| 811 |
+
|
| 812 |
+
noise.buffer = buffer;
|
| 813 |
+
filter.type = 'bandpass';
|
| 814 |
+
filter.frequency.setValueAtTime(3000, audioContext.currentTime);
|
| 815 |
+
filter.frequency.exponentialRampToValueAtTime(1000, audioContext.currentTime + 0.15);
|
| 816 |
+
|
| 817 |
+
noise.connect(filter);
|
| 818 |
+
filter.connect(gain);
|
| 819 |
+
gain.connect(masterGainNode);
|
| 820 |
+
|
| 821 |
+
gain.gain.setValueAtTime(0.2, audioContext.currentTime);
|
| 822 |
+
gain.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.15);
|
| 823 |
+
|
| 824 |
+
noise.start();
|
| 825 |
+
},
|
| 826 |
|
| 827 |
+
27: () => { // Potion Drink
|
| 828 |
+
const osc1 = audioContext.createOscillator();
|
| 829 |
+
const osc2 = audioContext.createOscillator();
|
| 830 |
+
const gain = audioContext.createGain();
|
| 831 |
+
|
| 832 |
+
osc1.connect(gain);
|
| 833 |
+
osc2.connect(gain);
|
| 834 |
+
gain.connect(masterGainNode);
|
| 835 |
+
|
| 836 |
+
osc1.type = 'sine';
|
| 837 |
+
osc2.type = 'triangle';
|
| 838 |
+
|
| 839 |
+
osc1.frequency.setValueAtTime(349.23, audioContext.currentTime);
|
| 840 |
+
osc2.frequency.setValueAtTime(440, audioContext.currentTime);
|
| 841 |
+
|
| 842 |
+
osc1.frequency.exponentialRampToValueAtTime(698.46, audioContext.currentTime + 0.4);
|
| 843 |
+
osc2.frequency.exponentialRampToValueAtTime(880, audioContext.currentTime + 0.4);
|
| 844 |
+
|
| 845 |
+
gain.gain.setValueAtTime(0, audioContext.currentTime);
|
| 846 |
+
gain.gain.linearRampToValueAtTime(0.2, audioContext.currentTime + 0.05);
|
| 847 |
+
gain.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.6);
|
| 848 |
+
|
| 849 |
+
osc1.start(audioContext.currentTime);
|
| 850 |
+
osc2.start(audioContext.currentTime);
|
| 851 |
+
osc1.stop(audioContext.currentTime + 0.6);
|
| 852 |
+
osc2.stop(audioContext.currentTime + 0.6);
|
| 853 |
+
},
|
| 854 |
|
| 855 |
+
28: () => { // Lockpick
|
| 856 |
+
const osc = audioContext.createO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|