-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
50 lines (38 loc) · 1.78 KB
/
Copy pathscript.js
File metadata and controls
50 lines (38 loc) · 1.78 KB
1
2
3
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
// script.js
const genres = [
"Pop", "Rock", "Jazz", "Hip-Hop", "Orchestral", "EDM", "Country", "Blues", "Soul", "Funk", "Disco", "Folk", "Metal", "Grunge", "Punk",
"R&B", "Trap", "House", "Techno", "Ambient", "Latin", "Garage", "Anthem", "Electroswing", "Instrumental", "Techno"
];
const structures = [
"I, IV, V, I", "I, V, vi, IV", "ii, V, I", "I, vi, IV, V", "I, IV, I, V",
"I, IV, V", "ii, V, vi, IV", "I, vi, ii, V", "I, IV, V, vi", "I, V, I",
"vi, IV, V, I", "I, V, IV, I", "I, ii, IV, V", "I, IV, V, IV",
"ii, IV, V, I", "I, IV, V, vi, IV", "I, V, ii, vi"
];
const vibes = [
"Fun", "Angry", "Silly", "Chill", "Energetic", "Dark", "Melancholic",
"Dreamy", "Quirky", "Motivational", "Mysterious", "Peaceful",
"Upbeat", "Aggressive", "Hopeful", "Enlightening", "Experimental"
];
function getRandomItem(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
function generateSong() {
// Populate the random song details
document.getElementById("genre").textContent = getRandomItem(genres);
document.getElementById("structure").textContent = getRandomItem(structures);
document.getElementById("bpm").textContent = Math.floor(Math.random() * 61) + 80; // BPM between 80-140
document.getElementById("vibe").textContent = getRandomItem(vibes);
// Reveal the output section
document.getElementById("output").classList.remove("hidden");
}
// Add event listener to the button
document.getElementById("generate-button").addEventListener("click", generateSong);
// Play Sound When Clicking Button
const Button_Sound = new Audio('click.mp3'); // Create an Audio object
// Function to play the sound
function playButton_Sound() {
Button_Sound.play();
}
// Add event listeners to buttons
document.getElementById('generate-button').addEventListener('click', playButton_Sound);