Compare commits

...
50 Commits
Author SHA1 Message Date
el-yazide.mohamed 0352efbc34 sensi re 2025-06-08 10:55:22 +02:00
el-yazide.mohamed 911049a2fe rewind 2025-06-08 10:53:07 +02:00
el-yazide.mohamed 60bb918f54 d 2025-06-08 10:50:50 +02:00
el-yazide.mohamed 0f16a93a7e c 2025-06-08 10:32:20 +02:00
el-yazide.mohamed 8cde0ef01e b 2025-06-08 10:29:30 +02:00
el-yazide.mohamed 62cac7c459 web audio API 2025-06-08 10:25:31 +02:00
el-yazide.mohamed be551e8844 seuil 1 2025-06-08 09:54:33 +02:00
el-yazide.mohamed d56266d1f3 b2 2025-06-08 09:53:45 +02:00
el-yazide.mohamed c74daf7337 bis 2025-06-08 09:51:07 +02:00
el-yazide.mohamed a9808ba9d4 sensi + seuil 2025-06-08 09:46:21 +02:00
el-yazide.mohamed 303c76cbd6 anim css x 2025-06-07 21:11:51 +02:00
el-yazide.mohamed 8c1e56c3f9 html change 2025-06-07 21:05:22 +02:00
el-yazide.mohamed 82ce27c10d rewind encore 2025-06-07 20:59:01 +02:00
el-yazide.mohamed 10e8782798 parser 2025-06-07 20:55:18 +02:00
el-yazide.mohamed fe24e5aa23 bis 2025-06-07 20:43:37 +02:00
el-yazide.mohamed 702e428ee5 bis 2025-06-07 20:26:42 +02:00
el-yazide.mohamed f236665829 mpg123 2025-06-07 20:20:14 +02:00
el-yazide.mohamed 21f18d1b2a bis 2025-06-07 19:51:31 +02:00
el-yazide.mohamed daa0505504 rewind 2025-06-07 19:49:27 +02:00
el-yazide.mohamed 69b45e386f test son raspberry 2025-06-07 19:44:29 +02:00
el-yazide.mohamed 8accaf4ab2 son exterieur 1 2025-06-07 19:16:30 +02:00
el-yazide.mohamed cf8c4b0e47 - sensi reverse 2025-06-07 17:35:53 +02:00
el-yazide.mohamed 710cd0506d bis 2025-06-07 17:26:07 +02:00
el-yazide.mohamed 7a7c04dbe4 animation js 2025-06-07 17:18:25 +02:00
el-yazide.mohamed 1e04b86236 animation css 2025-06-07 17:14:30 +02:00
el-yazide.mohamed 6a8463fab5 css 2025-06-07 17:09:51 +02:00
el-yazide.mohamed 9cf7c74f9c bisbis 2025-06-07 17:04:57 +02:00
el-yazide.mohamed 825acfe48b bis 2025-06-07 16:56:27 +02:00
el-yazide.mohamed cadb42d693 reverse timeline 2025-06-07 16:53:59 +02:00
el-yazide.mohamed 024338d4dc Vitesse normalisée 2025-06-07 16:49:13 +02:00
el-yazide.mohamed a33466d6d9 speed 2025-06-07 16:38:15 +02:00
el-yazide.mohamed ebc97c8930 timeline rewind 2025-06-07 13:41:45 +02:00
el-yazide.mohamed 0e8efa0902 animation vinyle 2025-06-07 13:34:02 +02:00
el-yazide.mohamed 4eadf7dc7e bis 2025-06-07 13:20:10 +02:00
el-yazide.mohamed 9033c8ad20 audio src 2025-06-07 13:14:34 +02:00
el-yazide.mohamed ac89ce77e6 retour sensi - 2025-06-07 12:44:45 +02:00
el-yazide.mohamed 2b54c71eae test 2025-06-07 09:26:53 +02:00
el-yazide.mohamed e957de4d86 bisbis 2025-06-07 08:32:34 +02:00
el-yazide.mohamed 61f68ca41f bis 2025-06-07 08:19:34 +02:00
el-yazide.mohamed bdd82be393 audio back and forth 2025-06-07 08:06:05 +02:00
el-yazide.mohamed a9c1f21fe3 audio reverse add 2025-06-07 07:52:01 +02:00
el-yazide.mohamed 98f3a4a02f sensi - 2025-06-07 07:23:29 +02:00
el-yazide.mohamed 80002351ad sensi 2025-06-07 07:18:49 +02:00
el-yazide.mohamed 533cd1052e reverse 2025-06-07 07:00:55 +02:00
el-yazide.mohamed 3b7b46f25b position -> vitesse 2025-06-07 06:14:25 +02:00
el-yazide.mohamed 0252347f65 socket re 2025-06-07 05:52:58 +02:00
el-yazide.mohamed c3bf6811ea socket 2025-06-07 05:45:24 +02:00
el-yazide.mohamed b2f9e5abb5 server 2025-06-06 17:04:27 +02:00
el-yazide.mohamed 1088699977 socket library 2025-06-06 16:56:31 +02:00
el-yazide.mohamed 44ec586c1e socket 2025-06-06 16:51:21 +02:00
18 changed files with 126 additions and 79 deletions
+4 -1
View File
@@ -43,9 +43,12 @@
<button id="forward">10s +</button>
</div>
<audio id="audio" src="song to song v4.mp3"></audio>
<audio id="audio"
src="song_to_song_v4.mp3"
data-reverse-src="song_to_song_v4_reverse.mp3"></audio>
</main>
<script src="socket.io.min.js"></script>
<script src="script.js"></script>
</body>
</html>
+4 -1
View File
@@ -43,9 +43,12 @@
<button id="forward">10s +</button>
</div>
<audio id="audio" src="paradisev2.mp3"></audio>
<audio id="audio"
src="paradisev2.mp3"
data-reverse-src="paradisev2_reverse.mp3"></audio>
</main>
<script src="socket.io.min.js"></script>
<script src="script.js"></script>
</body>
</html>
+7 -2
View File
@@ -28,7 +28,7 @@
</h2>
<div class="progress-container">
<input type="range" id="progress" value="0" />
<input type="range" id="progress" value="0" max="100" />
<div class="time-wrapper">
<div id="currentTime" class="time">0:00</div>
@@ -43,9 +43,14 @@
<button id="forward">10s +</button>
</div>
<audio id="audio" src="muddy_files.mp3"></audio>
<audio id="audio"
src="muddy_files.mp3"
data-reverse-src="muddy_files_reverse.mp3"></audio>
</main>
<script src="socket.io.min.js"></script>
<script src="script.js"></script>
</body>
</html>
Binary file not shown.
Binary file not shown.
+69 -56
View File
@@ -1,4 +1,4 @@
// 1. Sélection des éléments du DOM
// 1. Sélection des éléments DOM
const vinyl = document.getElementById('vinyl');
const audio = document.getElementById('audio');
const progress = document.getElementById('progress');
@@ -11,42 +11,89 @@ const loopBtn = document.getElementById('loop');
// 2. Variables utiles
let isPlaying = false;
let isLooping = false;
let idleTimeout = null;
let lastPosition = null;
let lastTime = null;
// sokcet.io & arduino serial info
const rotationsPerTrack = 3; // tours complets du vinyle sur toute la durée
let currentRotation = 0; // rotation en degrés actuelle du vinyle
// 3. Connexion Socket.io
const socket = io();
socket.on('position', (position) => {
console.log('recieved position', position);
const now = Date.now();
if (lastPosition !== null && lastTime !== null) {
const deltaPos = position - lastPosition;
const deltaTime = (now - lastTime) / 1000;
const speed = deltaPos / deltaTime; // vitesse de rotation
clearTimeout(idleTimeout);
// Seuil de mouvement pour arrêt
if (Math.abs(speed) < 1) {
stopPlayback();
return;
}
if (speed < 0) {
// Rotation inverse : on recule la timeline
audio.pause();
isPlaying = false;
// recule proportionnellement à la vitesse (sensibilité ajustable)
audio.currentTime = Math.max(0, audio.currentTime + speed * 0.0025);
} else {
// Rotation avant : jouer la piste et ajuster vitesse
if (!isPlaying) {
audio.play();
isPlaying = true;
}
// SENSIBILITÉ : le facteur diviseur est plus grand → plus doux
let playbackSpeed = 0.5 + speed / 600;
playbackSpeed = Math.min(Math.max(playbackSpeed, 0.5), 1.1); // plage limitée à x1 max
audio.playbackRate = playbackSpeed;
}
}
lastPosition = position;
lastTime = now;
// Détection d'inactivité
idleTimeout = setTimeout(() => {
stopPlayback();
}, 300);
});
// 3. Fonctions
// 4. Fonctions
// Fonction pour basculer la lecture
function togglePlay() {
if (isPlaying) {
audio.pause();
vinyl.style.animationPlayState = 'paused';
} else {
audio.play();
vinyl.style.animationPlayState = 'running';
}
isPlaying = !isPlaying;
}
// Mise à jour de la barre de progression
function updateProgress() {
if (!isNaN(audio.duration)) {
const progressPercent = (audio.currentTime / audio.duration) * 100;
progress.value = progressPercent;
currentTimeEl.textContent = formatTime(audio.currentTime);
durationEl.textContent = formatTime(audio.duration);
updateVinylRotation();
}
}
// Fonction pour formater le temps (min:sec)
function formatTime(time) {
const minutes = Math.floor(time / 60);
const seconds = Math.floor(time % 60);
return `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
}
// Fonction pour changer la position de lecture en cliquant sur la barre
function setProgress(e) {
const width = progress.clientWidth;
const clickX = e.offsetX;
@@ -54,85 +101,51 @@ function setProgress(e) {
audio.currentTime = (clickX / width) * duration;
}
// Fonction pour regler la vitesse de lecture en fonction de la balle
function controlPlayback(speed) {
if (speed > 0) {
if (!isPlaying) {
audio.play();
vinyl.style.animationPlayState = 'running';
isPlaying = true;
}
// Ajuste la vitesse de lecture audio (entre 0.5 et 2 par exemple)
audio.playbackRate = Math.min(2, Math.max(0.5, speed));
} else {
if (isPlaying) {
function stopPlayback() {
audio.pause();
vinyl.style.animationPlayState = 'paused';
isPlaying = false;
audio.playbackRate = 1;
}
// La rotation est synchronisée avec la timeline audio
function updateVinylRotation() {
if (audio.duration && audio.currentTime >= 0) {
// Rotation proportionnelle au temps courant
currentRotation = (audio.currentTime / audio.duration) * 360 * rotationsPerTrack;
vinyl.style.transform = `rotate(${currentRotation}deg)`;
console.log('Rotation:', currentRotation); // Debug
}
}
// 4. Événements
// 5. Événements
// Clique sur le vinyle pour basculer lecture
vinyl.addEventListener('click', togglePlay);
// Mise à jour de la barre de progression à chaque changement de temps
audio.addEventListener('timeupdate', updateProgress);
// Mise à jour de la durée du titre dès que l'audio est chargé
audio.addEventListener('loadedmetadata', () => {
durationEl.textContent = formatTime(audio.duration);
console.log('Audio duration:', audio.duration);
});
// Permet de cliquer sur la barre de progression
progress.addEventListener('click', setProgress);
// Bouton reculer de 10s
backwardBtn.addEventListener('click', () => {
audio.currentTime = Math.max(0, audio.currentTime - 10);
});
// Bouton avancer de 10s
forwardBtn.addEventListener('click', () => {
audio.currentTime = Math.min(audio.duration, audio.currentTime + 10);
});
// Bouton pour activer/désactiver la boucle (LOOP)
loopBtn.addEventListener('click', () => {
isLooping = !isLooping;
loopBtn.style.backgroundColor = isLooping ? 'white' : 'transparent';
loopBtn.style.color = isLooping ? '#18344b' : 'white';
});
// Lorsque l'audio est terminé, on répète si la boucle est activée
audio.addEventListener('ended', () => {
if (isLooping) {
audio.currentTime = 0;
audio.play();
} else {
vinyl.style.animationPlayState = 'paused';
isPlaying = false;
}
});
// server WebSocket
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 3000 });
wss.on('connection', function connection(ws) {
console.log('🟢 Un client WebSocket est connecté');
ws.on('message', function incoming(message) {
console.log('📨 Message reçu:', message);
});
ws.send('🔗 Connexion WebSocket établie avec le Raspberry Pi');
});
const socket = new WebSocket('ws://[IP_DU_PI]:8080');
socket.onopen = () => console.log("✅ Connecté");
socket.onmessage = e => console.log("📩 Message :", e.data);
socket.onerror = e => console.log("❌ Erreur :", e);
Binary file not shown.
Binary file not shown.
+4 -1
View File
@@ -43,9 +43,12 @@
<button id="forward">10s +</button>
</div>
<audio id="audio" src="stamina-v17.mp3"></audio>
<audio id="audio"
src="stamina-v17.mp3"
data-reverse-src="stamina-v17_reverse.mp3"></audio>
</main>
<script src="socket.io.min.js"></script>
<script src="script.js"></script>
</body>
</html>
+5 -1
View File
@@ -78,7 +78,7 @@ body {
height: 600px;
border-radius: 50%;
background: radial-gradient(circle at center, #444 0%, #111 60%, #000 100%);
animation: spin 5s linear infinite paused;
/*animation: spin 5s linear infinite paused;*/
display: flex;
align-items: center;
justify-content: center;
@@ -87,6 +87,10 @@ body {
margin: 20px 0;
}
.vinyl.reverse {
animation: spin-reverse 4s linear infinite;
}
.vinyl img {
width: 40%;
border-radius: 50%;
+14 -6
View File
@@ -78,15 +78,22 @@ body {
height: 600px;
border-radius: 50%;
background: radial-gradient(circle at center, #444 0%, #111 60%, #000 100%);
animation: spin 5s linear infinite paused;
/*animation: spin 4s linear infinite;
animation-play-state: paused;*/
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
transition: transform 0.3s linear;
cursor: pointer;
margin: 20px 0;
}
.vinyl.reverse {
animation: spin-reverse 4s linear infinite;
}
.vinyl img {
width: 40%;
border-radius: 50%;
@@ -166,12 +173,13 @@ body {
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
@keyframes spin-reverse {
from { transform: rotate(0deg); }
to { transform: rotate(-360deg); }
}
@media (max-width: 768px) {
+5 -1
View File
@@ -78,7 +78,7 @@ body {
height: 600px;
border-radius: 50%;
background: radial-gradient(circle at center, #444 0%, #111 60%, #000 100%);
animation: spin 5s linear infinite paused;
/*animation: spin 5s linear infinite paused;*/
display: flex;
align-items: center;
justify-content: center;
@@ -87,6 +87,10 @@ body {
margin: 20px 0;
}
.vinyl.reverse {
animation: spin-reverse 4s linear infinite;
}
.vinyl img {
width: 40%;
border-radius: 50%;
+5 -1
View File
@@ -78,7 +78,7 @@ body {
height: 600px;
border-radius: 50%;
background: radial-gradient(circle at center, #444 0%, #111 60%, #000 100%);
animation: spin 5s linear infinite paused;
/*animation: spin 5s linear infinite paused;*/
display: flex;
align-items: center;
justify-content: center;
@@ -87,6 +87,10 @@ body {
margin: 20px 0;
}
.vinyl.reverse {
animation: spin-reverse 4s linear infinite;
}
.vinyl img {
width: 40%;
border-radius: 50%;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.