ditty.bpm = 55;
// --- Synthlead estilo 2 Unlimited (triple sierra desafinada) ---
const hardcoreLead = synth.def((phase, env, tick, options) => {
const normalize = p => (p / (2 * Math.PI)) % 1;
const saw = p => normalize(p) * 2 - 1;
// Tres osciladores ligeramente desafinados
const wave = (
saw(phase) +
saw(phase * 1.007) +
saw(phase * 0.993)
) / 3 * env.value;
return wave;
});
// --- Tus notas completas (convertidas a array) ---
const notes = [
[0.00000, 52.0, 0.25000],
[0.00000, 56.0, 0.25000],
[0.00000, 59.0, 0.25000],
[0.00000, 64.0, 0.25000],
[0.31250, 52.0, 0.56250],
[0.31250, 56.0, 0.56250],
[0.31250, 59.0, 0.56250],
[0.31250, 64.0, 0.56250],
[0.62500, 52.0, 0.81250],
[0.62500, 56.0, 0.81250],
[0.62500, 59.0, 0.81250],
[0.62500, 64.0, 0.81250],
[0.81250, 45.0, 0.93750],
[0.81250, 49.0, 0.93750],
[0.81250, 52.0, 0.93750],
[0.81250, 57.0, 0.93750],
[1.00000, 45.0, 1.12500],
[1.00000, 49.0, 1.12500],
[1.00000, 52.0, 1.12500],
[1.00000, 57.0, 1.12500],
[1.18750, 47.0, 1.31250],
[1.18750, 51.0, 1.31250],
[1.18750, 54.0, 1.31250],
[1.18750, 59.0, 1.31250],
[1.37500, 47.0, 1.50000],
[1.37500, 51.0, 1.50000],
[1.37500, 54.0, 1.50000],
[1.37500, 59.0, 1.50000],
[1.56250, 52.0, 1.81250],
[1.56250, 56.0, 1.81250],
[1.56250, 59.0, 1.81250],
[1.56250, 64.0, 1.81250],
[1.87500, 52.0, 2.12500],
[1.87500, 56.0, 2.12500],
[1.87500, 59.0, 2.12500],
[1.87500, 64.0, 2.12500],
[2.18750, 52.0, 2.37500],
[2.18750, 56.0, 2.37500],
[2.18750, 59.0, 2.37500],
[2.18750, 64.0, 2.37500],
[2.43750, 55.0, 2.56250],
[2.43750, 59.0, 2.56250],
[2.43750, 62.0, 2.56250],
[2.43750, 67.0, 2.56250],
[2.62500, 55.0, 2.75000],
[2.62500, 59.0, 2.75000],
[2.62500, 62.0, 2.75000],
[2.62500, 67.0, 2.75000],
[2.81250, 57.0, 2.93750],
[2.81250, 61.0, 2.93750],
[2.81250, 64.0, 2.93750],
[2.81250, 69.0, 2.93750],
[3.00000, 57.0, 3.12500],
[3.00000, 61.0, 3.12500],
[3.00000, 64.0, 3.12500],
[3.00000, 69.0, 3.12500],
[3.18750, 52.0, 3.43750],
[3.18750, 56.0, 3.43750],
[3.18750, 59.0, 3.43750],
[3.18750, 64.0, 3.43750],
[3.50000, 52.0, 3.75000],
[3.50000, 56.0, 3.75000],
[3.50000, 59.0, 3.75000],
[3.50000, 64.0, 3.75000],
[3.81250, 52.0, 4.00000],
[3.81250, 56.0, 4.00000],
[3.81250, 59.0, 4.00000],
[3.81250, 64.0, 4.00000],
[4.00000, 45.0, 4.12500],
[4.00000, 49.0, 4.12500],
[4.00000, 52.0, 4.12500],
[4.00000, 57.0, 4.12500],
[4.18750, 45.0, 4.31250],
[4.18750, 49.0, 4.31250],
[4.18750, 52.0, 4.31250],
[4.18750, 57.0, 4.31250],
[4.37500, 47.0, 4.50000],
[4.37500, 51.0, 4.50000],
[4.37500, 54.0, 4.50000],
[4.37500, 59.0, 4.50000],
[4.56250, 47.0, 4.68750],
[4.56250, 51.0, 4.68750],
[4.56250, 54.0, 4.68750],
[4.56250, 59.0, 4.68750],
[4.75000, 52.0, 5.00000],
[4.75000, 56.0, 5.00000],
[4.75000, 59.0, 5.00000],
[4.75000, 64.0, 5.00000],
[5.06250, 52.0, 5.31250],
[5.06250, 56.0, 5.31250],
[5.06250, 59.0, 5.31250],
[5.06250, 64.0, 5.31250],
[5.06250, 56.0, 5.31250],
[5.37500, 52.0, 5.56250],
[5.37500, 56.0, 5.56250],
[5.37500, 59.0, 5.56250],
[5.37500, 64.0, 5.56250],
[5.62500, 55.0, 5.75000],
[5.62500, 59.0, 5.75000],
[5.62500, 62.0, 5.75000],
[5.62500, 67.0, 5.75000],
[5.81250, 55.0, 5.93750],
[5.81250, 59.0, 5.93750],
[5.81250, 62.0, 5.93750],
[5.81250, 67.0, 5.93750],
[6.00000, 57.0, 6.12500],
[6.00000, 61.0, 6.12500],
[6.00000, 64.0, 6.12500],
[6.00000, 69.0, 6.12500],
[6.18750, 57.0, 6.31250],
[6.18750, 61.0, 6.31250],
[6.18750, 64.0, 6.31250],
[6.18750, 69.0, 6.31250],
[6.37500, 52.0, 6.62500],
[6.37500, 56.0, 6.62500],
[6.37500, 59.0, 6.62500],
[6.37500, 64.0, 6.62500],
[6.68750, 52.0, 6.93750],
[6.68750, 56.0, 6.93750],
[6.68750, 59.0, 6.93750],
[6.68750, 64.0, 6.93750],
[7.00000, 52.0, 7.18750],
[7.00000, 56.0, 7.18750],
[7.00000, 59.0, 7.18750],
[7.00000, 64.0, 7.18750],
[7.25000, 45.0, 7.37500],
[7.25000, 49.0, 7.37500],
[7.25000, 52.0, 7.37500],
[7.25000, 57.0, 7.37500],
[7.43750, 45.0, 7.56250],
[7.43750, 49.0, 7.56250],
[7.43750, 52.0, 7.56250],
[7.43750, 57.0, 7.56250],
[7.62500, 47.0, 7.75000],
[7.62500, 51.0, 7.75000],
[7.62500, 54.0, 7.75000],
[7.62500, 59.0, 7.75000],
[7.81250, 47.0, 7.93750],
[7.81250, 51.0, 7.93750],
[7.81250, 54.0, 7.93750],
[7.81250, 59.0, 7.93750],
[8.00000, 52.0, 8.25000],
[8.00000, 56.0, 8.25000],
[8.00000, 59.0, 8.25000],
[8.00000, 64.0, 8.25000],
[8.31250, 52.0, 8.56250],
[8.31250, 56.0, 8.56250],
[8.31250, 59.0, 8.56250],
[8.31250, 64.0, 8.56250]
];
// --- Agrupar notas por tiempo de inicio (para tocar acordes juntos) ---
const events = {};
notes.forEach(([start, midi, end]) => {
if (!events[start]) events[start] = [];
events[start].push({ midi, duration: end - start });
});
const times = Object.keys(events)
.map(t => parseFloat(t))
.sort((a, b) => a - b);
// --- Loop principal ---
loop(() => {
let currentTime = 0;
for (const t of times) {
// Avanzar al tiempo del próximo acorde
if (t > currentTime) {
sleep(t - currentTime);
currentTime = t;
}
// Reproducir todo el acorde
events[t].forEach(note => {
hardcoreLead.play(note.midi+36, {
duration: note.duration,
attack: 0.005, // Ataque rápido
release: 0.05, // Liberación corta
amp: 0.75 // Volumen alto
});
});
}
// Completar el compás (8 beats)
const lastTime = times[times.length - 1] || 0;
if (lastTime < 8) {
sleep(8 - lastTime);
}
}, { name: "2 Unlimited - Hardcore Lead" });