// --- Configuration Moderne ---
ditty.bpm = 122;
// --- SYNTHÉTISSEURS ---
// 1. Le son du Champignon (Power-Up)
const mushroomSynth = synth.def((phase, env, tick) => {
// Montée de fréquence rapide pour l'effet "Bling"
const slide = Math.pow(tick * 45, 2);
return Math.sin(phase * 2 * Math.PI + slide) * env.value;
}, { attack: 0.01, release: 0.4 });
// 2. Lead Mario "Plucky"
const marioPluck = synth.def((phase, env) => {
const v = Math.sin(phase * 2 * Math.PI) * Math.exp(-phase * 0.5);
return v * env.value;
}, { attack: 0.001, release: 0.15 });
// 3. Kick profond
const deepKick = synth.def((phase, env, tick) => {
const p = Math.exp(-tick * 10);
return Math.sin(phase * 2 * Math.PI * (1 + p * 4)) * env.value;
}, { attack: 0.001, release: 0.4 });
// 4. Hi-Hat (Déclaré correctement ici)
const hatSynth = synth.def((phase, env) => (Math.random() * 2 - 1) * env.value, { attack: 0.001, release: 0.02 });
// --- EFFETS ---
const Reverb = filter.def(class {
constructor() { this.buffer = new Float32Array(20000); this.ptr = 0; }
process(input) {
let out = input + this.buffer[this.ptr] * 0.7;
this.buffer[this.ptr] = out;
this.ptr = (this.ptr + 1) % this.buffer.length;
return out * 0.4 + input;
}
});
// --- SÉQUENÇAGE ---
// KICK
loop((i) => {
deepKick.play(c2, { amp: 1 });
sleep(1);
}, { name: 'kick' });
// MÉLODIE MARIO
const theme = [e5, e5, 0, e5, 0, c5, e5, 0, g5];
loop((i) => {
const note = theme[i % theme.length];
if (note !== 0) {
marioPluck.play(note, { amp: 0.3, filter: Reverb });
}
sleep(0.5);
}, { name: 'melody' });
// EFFETS DE CHAMPIGNON
loop((i) => {
if (Math.random() > 0.85) {
mushroomSynth.play(c5, { amp: 0.2 });
}
sleep(1);
}, { name: 'mushrooms' });
// BASSE "OFFBEAT"
loop((i) => {
sleep(0.5);
marioPluck.play(c3, { amp: 0.4, release: 0.3 });
sleep(0.5);
}, { name: 'offbeat_bass' });
// HI-HATS (Version corrigée)
loop((i) => {
sleep(0.5);
hatSynth.play(c4, { amp: 0.1 });
sleep(0.5);
}, { name: 'hats' });