xxxxxxxxxx
155
let angles = [4, 5, 15, 25, 10, 6, 13, 8, 12, 15, 7];
let startAngles = [0, 73, 80, 93, 140, 168, 174, 255, 263, 275, 320];
let audioFiles = [];
let currentAngle = 0;
let angleSpeed = 0.01;
let clockRadius = 300;
let colors, labels;
let currentAudioIndex = -1;
// Add this new array to set volume levels for each audio track
let audioVolumes = [2.0, 1.0, 1.0, 2.0, 1.2, 0.8, 1.0, 5.0, 4.0, 9.0, 1.5];
function preload() {
const audioNames = [
'Opening_closing fridge.m4a',
'apple bite.m4a',
'tea boils boils.mp4',
'breakfast cooking.mp4',
'nachonacho.mp4',
'final deliveryry.mp4',
'Raj_20 hours_ Eating sounds.mp4',
'Raj_18 hours_ Meal prep, cutting veggies.mp4',
'Raj_19 hours_ Cooking.mp4',
'Raj_22 hours_ Cleaning, washing dishes.mp4',
'Raj_17 hours_ Drinking water.mp4'
];
audioFiles = audioNames.map(name => loadSound(name, () => console.log("Audio loaded: " + name), err => console.log("Error loading audio:", err)));
}
function setup() {
createCanvas(650, 650);
angleMode(DEGREES);
textAlign(CENTER, CENTER);
// Set the volume for each audio file
audioFiles.forEach((audio, index) => {
audio.setVolume(audioVolumes[index]);
});
colors = [
color(255, 0, 0, 100), // Red
color(255, 165, 0, 100), // Orange
color(255, 255, 0, 100), // Yellow
color(245, 245, 220, 100), // Beige
color(250, 128, 114, 100), // Salmon
color(255, 165, 0, 100), // Orange
color(255, 0, 0, 100), // Red
color(245, 245, 220, 100), // Beige
color(250, 128, 114, 100), // Salmon
color(255, 165, 0, 100), // Orange
color(255, 255, 0, 100) // Yellow
];
labels = [
{ text: "🌃🥱🍪", size: 40 },
{ text: "🍎", size: 30 },
{ text: "🍵", size: 30 },
{ text: "🍳", size: 55 },
{ text: "🍿🍟", size: 30 },
{ text: " 🚘🙋", size: 30 },
{ text: " 🤤🥘🍱🥢", size: 40 },
{ text: "🔪", size: 30 },
{ text: "🍝", size: 50 },
{ text: "🍴🍽️", size: 25 },
{ text: "🚰", size: 50 }
];
}
function draw() {
background(255);
translate(width / 2, height / 2);
// Draw clock segments and labels
for (let i = 0; i < angles.length; i++) {
fill(colors[i]);
arc(0, 0, clockRadius * 2, clockRadius * 2, startAngles[i], startAngles[i] + angles[i]);
if (labels[i]) {
push();
rotate(startAngles[i] + angles[i] / 2);
translate(clockRadius * 0.68, 0);
rotate(-(startAngles[i] + angles[i] / 2));
fill(0);
noStroke();
textFont('Georgia');
textSize(labels[i].size);
text(labels[i].text, 0, 0);
pop();
}
}
// Draw clock outline
stroke(0);
noFill();
ellipse(0, 0, clockRadius * 2);
// Move the clock hand
if (!mouseIsPressed) {
currentAngle = (currentAngle + angleSpeed) % 360;
}
// Draw the clock hand
stroke(0);
strokeWeight(5);
let handX = clockRadius * cos(currentAngle);
let handY = clockRadius * sin(currentAngle);
line(0, 0, handX, handY);
updateAudioPlayback();
}
function mousePressed() {
let dx = mouseX - width/2;
let dy = mouseY - height/2;
if (dist(0, 0, dx, dy) <= clockRadius) {
currentAngle = (atan2(dy, dx) + 360) % 360;
updateAudioPlayback();
}
}
function updateAudioPlayback() {
let newAudioIndex = -1;
for (let i = 0; i < angles.length; i++) {
let start = startAngles[i];
let end = (start + angles[i]) % 360;
if (start < end) {
if (currentAngle >= start && currentAngle < end) {
newAudioIndex = i;
break;
}
} else {
if (currentAngle >= start || currentAngle < end) {
newAudioIndex = i;
break;
}
}
}
if (newAudioIndex !== currentAudioIndex) {
stopAllAudio();
if (audioFiles[newAudioIndex]) {
audioFiles[newAudioIndex].play();
console.log("Playing audio:", newAudioIndex);
}
currentAudioIndex = newAudioIndex;
}
}
function stopAllAudio() {
audioFiles.forEach(audio => {
if (audio && audio.isPlaying()) {
audio.stop();
}
});
}