Zombie – Guitar Lead

Zombie – Guitar Lead

Log in to post a comment.

ditty.bpm = 40;



const brightLead = synth.def((phase, env, tick, opt) => {

  // Normalizar fase a 0..1
  const ph = (phase / (2 * Math.PI)) % 1.0;

  // --- Saw1 ---
  const saw1 = ph * 2.0 - 1.0;

  // --- Saw2 (detune 0.5%) ---
  const ph2 = ((phase * 1.005) / (2 * Math.PI)) % 1.0;
  const saw2 = ph2 * 2.0 - 1.0;

  // --- Triangular ---
  const tri = Math.abs(ph - 0.5) * 4.0 - 1.0;

  // --- Mezcla ---
  let mixed = saw1 * 0.6 + saw2 * 0.6 + tri * 0.3;

  // --- Saturación (opcional) ---
  //mixed = Math.tanh(mixed * 2.0);

  // --- Filtros (sandbox de Dittytoy permite lp/hp directo) ---
  //mixed = lp(mixed, 2500);
  //mixed = hp(mixed, 150);

  return mixed * env.value * (opt.amp ?? 0.5);
});





// ========================================================
//   NOTAS – TUS DATOS COMPLETOS
//   Formato: [tInicio, midi, tFin]
// ========================================================

const notes = [
  [0.00000,28.0,0.93750],
  [0.00000,40.0,0.12500],
  [0.00000,43.0,0.12500],
  [0.12500,40.0,0.25000],
  [0.12500,43.0,0.25000],
  [0.25000,40.0,0.37500],
  [0.25000,43.0,0.37500],
  [0.37500,40.0,0.43750],
  [0.37500,43.0,0.43750],
  [0.43750,40.0,0.56250],
  [0.43750,43.0,0.56250],
  [0.56250,40.0,0.62500],
  [0.56250,43.0,0.62500],
  [0.62500,40.0,0.75000],
  [0.62500,43.0,0.75000],
  [0.75000,40.0,0.87500],
  [0.75000,43.0,0.87500],
  [0.87500,40.0,1.00000],
  [0.87500,43.0,1.00000],
  [1.00000,24.0,1.93750],
  [1.00000,36.0,1.12500],
  [1.00000,40.0,1.12500],
  [1.12500,36.0,1.25000],
  [1.12500,40.0,1.25000],
  [1.25000,36.0,1.37500],
  [1.25000,40.0,1.37500],
  [1.37500,36.0,1.43750],
  [1.37500,40.0,1.43750],
  [1.43750,36.0,1.56250],
  [1.43750,40.0,1.56250],
  [1.56250,36.0,1.62500],
  [1.56250,40.0,1.62500],
  [1.62500,36.0,1.75000],
  [1.62500,40.0,1.75000],
  [1.75000,36.0,1.87500],
  [1.75000,40.0,1.87500],
  [1.87500,40.0,2.00000],
  [1.87500,36.0,2.00000],
  [2.00000,31.0,2.93750],
  [2.00000,43.0,2.12500],
  [2.00000,47.0,2.12500],
  [2.12500,43.0,2.25000],
  [2.12500,47.0,2.25000],
  [2.25000,43.0,2.37500],
  [2.25000,47.0,2.37500],
  [2.37500,43.0,2.43750],
  [2.37500,47.0,2.43750],
  [2.43750,43.0,2.56250],
  [2.43750,47.0,2.56250],
  [2.56250,43.0,2.62500],
  [2.56250,47.0,2.62500],
  [2.62500,43.0,2.75000],
  [2.62500,47.0,2.75000],
  [2.75000,43.0,2.87500],
  [2.75000,47.0,2.87500],
  [2.87500,43.0,3.00000],
  [2.87500,47.0,3.00000],
  [3.00000,30.0,3.93750],
  [3.00000,42.0,3.12500],
  [3.00000,45.0,3.12500],
  [3.12500,42.0,3.25000],
  [3.12500,45.0,3.25000],
  [3.25000,42.0,3.37500],
  [3.25000,45.0,3.37500],
  [3.37500,42.0,3.43750],
  [3.37500,45.0,3.43750],
  [3.43750,42.0,3.56250],
  [3.43750,45.0,3.56250],
  [3.56250,42.0,3.62500],
  [3.56250,45.0,3.62500],
  [3.62500,42.0,3.75000],
  [3.62500,45.0,3.75000],
  [3.75000,42.0,3.87500],
  [3.75000,45.0,3.87500],
  [3.87500,42.0,4.00000],
  [3.87500,45.0,4.00000],
  [4.00000,40.0,4.93750],
  [4.00000,43.0,4.93750],
  [4.00000,28.0,4.12500],
  [4.12500,28.0,4.25000],
  [4.25000,28.0,4.37500],
  [4.37500,28.0,4.50000],
  [4.50000,28.0,4.62500],
  [4.62500,28.0,4.75000],
  [4.75000,28.0,4.87500],
  [4.87500,28.0,5.00000],
  [5.00000,36.0,5.93750],
  [5.00000,40.0,5.93750],
  [5.00000,24.0,5.12500],
  [5.12500,24.0,5.25000],
  [5.25000,24.0,5.37500],
  [5.37500,24.0,5.50000],
  [5.50000,24.0,5.62500],
  [5.62500,24.0,5.75000],
  [5.75000,24.0,5.87500],
  [5.87500,24.0,6.00000],
  [6.00000,43.0,6.93750],
  [6.00000,47.0,6.93750],
  [6.00000,31.0,6.12500],
  [6.12500,31.0,6.25000],
  [6.25000,31.0,6.37500],
  [6.37500,31.0,6.50000],
  [6.50000,31.0,6.62500],
  [6.62500,31.0,6.75000],
  [6.75000,31.0,6.87500],
  [6.87500,31.0,7.00000],
  [7.00000,42.0,7.93750],
  [7.00000,45.0,7.93750],
  [7.00000,30.0,7.12500],
  [7.12500,30.0,7.25000],
  [7.25000,30.0,7.37500],
  [7.37500,30.0,7.50000],
  [7.50000,30.0,7.62500],
  [7.62500,30.0,7.75000],
  [7.75000,30.0,7.87500],
  [7.87500,30.0,8.00000],
  [8.00000,40.0,9.00000],
  [8.00000,52.0,8.75000],
  [8.78125,54.0,9.03125],
  [9.06250,36.0,10.00000],
  [9.06250,55.0,10.00000],
  [10.03125,43.0,10.96875],
  [10.03125,59.0,10.15625],
  [10.15625,60.0,10.40625],
  [10.40625,57.0,10.53125],
  [10.53125,59.0,10.78125],
  [10.78125,55.0,10.90625],
  [10.90625,57.0,11.15625],
  [11.03125,42.0,11.96875],
  [11.15625,54.0,11.28125],
  [11.28125,55.0,11.40625],
  [11.40625,54.0,11.53125],
  [11.53125,50.0,11.78125],
  [11.78125,50.0,12.03125],
  [12.03125,28.0,12.96875],
  [12.03125,47.0,12.28125],
  [12.28125,52.0,12.40625],
  [12.40625,50.0,12.65625],
  [12.65625,47.0,12.90625],
  [12.90625,47.0,13.03125],
  [13.03125,36.0,13.96875],
  [13.03125,50.0,13.15625],
  [13.15625,48.0,13.40625],
  [13.40625,47.0,13.65625],
  [13.65625,45.0,13.90625],
  [13.90625,45.0,14.03125],
  [14.03125,31.0,14.96875],
  [14.03125,48.0,14.15625],
  [14.15625,47.0,14.40625],
  [14.40625,45.0,14.65625],
  [14.65625,43.0,14.90625],
  [14.90625,45.0,15.03125],
  [15.06250,30.0,16.00000],
  [15.06250,42.0,16.00000],
  [16.03125,28.0,16.96875],
  [16.15625,47.0,16.28125],
  [16.28125,52.0,16.40625],
  [16.40625,50.0,16.65625],
  [16.65625,47.0,16.90625],
  [16.90625,47.0,17.03125],
  [17.03125,36.0,17.96875],
  [17.03125,50.0,17.15625],
  [17.15625,48.0,17.40625],
  [17.40625,47.0,17.65625],
  [17.65625,45.0,17.90625],
  [17.90625,48.0,18.15625],
  [18.03125,31.0,18.96875],
  [18.15625,47.0,18.40625],
  [18.40625,45.0,18.65625],
  [18.65625,43.0,18.90625],
  [18.90625,45.0,19.03125],
  [19.03125,30.0,20.03125],
  [19.03125,42.0,19.65625],
  [19.68750,54.0,19.81250],
  [19.81250,55.0,19.93750],
  [19.93750,52.0,20.18750],
  [20.09375,28.0,21.03125],
  [20.18750,52.0,20.31250],
  [20.31250,54.0,20.43750],
  [20.43750,52.0,20.68750],
  [20.68750,52.0,20.81250],
  [20.81250,54.0,20.93750],
  [20.93750,55.0,21.18750],
];


// ========================================================
//   MOTOR DE REPRODUCCIÓN – Igual al de tu ejemplo
// ========================================================

let index = 0;
const totalTime = notes[notes.length - 1][2];

loop(() => {
  let t = 0;
  const step = 0.03125;

  while (t <= totalTime) {
    while (index < notes.length && Math.abs(notes[index][0] - t) < 1e-4) {

      const [start, midi, end] = notes[index];

      brightLead.play(
        midi + 36,                    // transposición (12 = 1 octava arriba)
        {
          duration: end - start,
          attack: 0.01,
          release: 0.15,
          amp: 0.8
        }
      );

      index++;
    }

    sleep(step);
    t += step;
  }

  index = 0;

}, { name:"Zombie – Guitar Lead" });