Haddaway-What is love_v1

Haddaway-What is love_v1

Log in to post a comment.

//por jorge2017a2
///NamePiano:Haddaway-What is love piano tutorial Sheets;  (youtube)
/// referencia osc- by Catzpaw

ditty.bpm = 55;

const  osc02=(t, hz) => { let p=t*hz;  return 2.0*(p-floor((p*2.0+0.5)/2.0) ); }


// --- sawlead de Catzpaw, adaptado a Dittytoy ---
const sawlead = synth.def((phase, env, tick, options) => {
  const norm1 = (phase / (2 * Math.PI)) % 1;
  const norm2 = (phase * 2.05 / (2.0 * Math.PI)) % 1;
  const norm3 = (phase * 2.01 / (2.0 * Math.PI)) % 1;
  
  const saw1 = norm1 * 2 - 1;
  const saw2 = norm2 * 2 - 1;
  const saw3 = norm3 * 2 - 1;
  const saw4= osc02(norm1, 1.0);
  return (saw1 + saw2+saw3+saw4) *  env.value/4.0;
});

// --- Solo 10 notas de prueba ---
const testNotes = [
  [0.00000, 50, 0.31250],
  [0.25000, 53, 0.50000],
  [0.50000, 55, 1.18750],
  [0.75000, 19, 1.00000],
  [1.00000, 31, 1.06250],
  [1.18750, 38, 1.43750],
  [1.43750, 43, 1.56250],
  [1.68750, 43, 2.00000],
  [1.68750, 46, 2.06250],
  [1.68750, 50, 1.81250],
  [1.93750, 51, 2.00000],
  [2.06250, 38, 2.12500],
  [2.06250, 50, 2.68750],
  [2.25000, 41, 2.68750],
  [2.25000, 53, 2.68750],
  [2.25000, 46, 2.75000],
  [2.50000, 22, 2.62500],
  [2.62500, 29, 2.75000],
  [2.75000, 34, 2.81250],
  [2.93750, 41, 3.18750],
  [2.93750, 46, 3.18750],
  [2.93750, 50, 3.15625],
  [3.12500, 38, 3.25000],
  [3.25000, 34, 3.37500],
  [3.37500, 38, 3.68750],
  [3.37500, 41, 3.43750],
  [3.37500, 46, 3.50000],
  [3.37500, 50, 3.62500],
  [3.56250, 41, 3.93750],
  [3.56250, 53, 3.87500],
  [3.75000, 26, 3.93750],
  [3.87500, 33, 4.06250],
  [4.00000, 38, 4.12500],
  [4.15625, 41, 4.40625],
  [4.15625, 45, 4.46875],
  [4.15625, 50, 4.40625],
  [4.34375, 33, 4.46875],
  [4.50000, 38, 5.00000],
  [4.68750, 41, 4.75000],
  [4.68750, 45, 4.81250],
  [4.68750, 50, 4.87500],
  [5.00000, 41, 5.50000],
  [5.00000, 45, 5.75000],
  [5.00000, 48, 5.71875],
  [5.18750, 29, 5.93750],
  [5.37500, 36, 6.06250],
  [5.62500, 41, 5.87500],
  [5.81250, 43, 6.06250],
  [6.00000, 45, 7.06250],
  [6.25000, 36, 6.43750],
  [6.43750, 29, 6.56250],
  [6.68750, 31, 6.93750],
  [6.87500, 19, 7.06250],
  [7.06250, 31, 7.18750],
  [7.31250, 38, 7.56250],
  [7.56250, 43, 7.68750],
  [7.81250, 43, 8.06250],
  [7.81250, 46, 8.18750],
  [7.81250, 50, 7.93750],
  [8.06250, 51, 8.12500],
  [8.18750, 38, 8.25000],
  [8.18750, 50, 8.56250],
  [8.37500, 41, 8.75000],
  [8.37500, 46, 8.78125],
  [8.37500, 53, 8.71875],
  [8.56250, 22, 8.75000],
  [8.75000, 17, 8.93750],
  [8.75000, 29, 8.93750],
  [8.93750, 34, 9.00000],
  [9.12500, 41, 9.37500],
  [9.12500, 46, 9.34375],
  [9.12500, 50, 9.34375],
  [9.31250, 38, 9.43750],
  [9.50000, 34, 9.62500],
  [9.68750, 38, 10.18750],
  [9.68750, 41, 9.75000],
  [9.68750, 46, 9.75000],
  [9.81250, 41, 10.31250],
  [9.81250, 53, 10.18750],
  [10.03125, 26, 10.21875],
  [10.21875, 33, 10.40625],
  [10.40625, 38, 10.53125],
  [10.56250, 41, 10.75000],
  [10.56250, 45, 10.71875],
  [10.56250, 50, 10.71875],
  [10.75000, 33, 10.87500],
  [10.93750, 38, 11.12500],
  [11.12500, 41, 11.18750],
  [11.12500, 45, 11.18750],
  [11.12500, 50, 11.25000],
  [11.37500, 41, 11.68750],
  [11.37500, 45, 12.06250],
  [11.37500, 48, 12.06250],
  [11.62500, 29, 12.12500],
  [11.81250, 36, 12.00000],
  [11.93750, 41, 12.56250],
  [12.12500, 43, 12.31250],
  [12.31250, 45, 12.68750],
  [12.87500, 19, 13.31250],
  [12.87500, 31, 13.31250],
  [12.87500, 43, 13.12500],
  [12.87500, 46, 13.06250],
  [12.87500, 50, 13.06250],
  [13.25000, 43, 13.31250],
  [13.25000, 46, 13.31250],
  [13.25000, 50, 13.31250],
  [13.43750, 19, 13.56250],
  [13.43750, 31, 13.56250],
  [13.59375, 43, 13.71875],
  [13.59375, 46, 13.71875],
  [13.59375, 50, 13.68750],
  [13.78125, 19, 13.84375],
  [13.78125, 31, 13.84375],
  [13.84375, 43, 13.96875],
  [13.84375, 46, 14.03125],
  [13.84375, 50, 13.96875],
  [14.03125, 19, 14.21875],
  [14.03125, 31, 14.28125],
  [14.15625, 41, 14.21875],
  [14.15625, 46, 14.21875],
  [14.15625, 51, 14.21875],
  [14.28125, 41, 14.53125],
  [14.28125, 46, 14.56250],
  [14.28125, 50, 14.53125],
  [14.46875, 22, 14.53125],
  [14.46875, 34, 14.53125],
  [14.53125, 22, 14.59375],
  [14.53125, 34, 14.59375],
  [14.59375, 41, 14.71875],
  [14.59375, 46, 14.75000],
  [14.59375, 50, 14.71875],
  [14.75000, 22, 14.93750],
  [14.75000, 34, 14.93750],
  [14.93750, 41, 15.12500],
  [14.93750, 46, 15.18750],
  [14.93750, 50, 15.12500],
  [15.18750, 22, 15.25000],
  [15.18750, 34, 15.25000],
  [15.25000, 41, 15.37500],
  [15.25000, 46, 15.43750],
  [15.25000, 50, 15.37500],
  [15.43750, 22, 15.50000],
  [15.43750, 34, 15.50000],
  [15.50000, 41, 15.56250],
  [15.50000, 46, 15.56250],
  [15.50000, 51, 15.56250],
  [15.68750, 41, 15.87500],
  [15.68750, 45, 15.87500],
  [15.68750, 50, 15.84375],
  [15.81250, 26, 15.87500],
  [15.81250, 38, 15.87500],
  [15.90625, 26, 16.03125],
  [15.90625, 38, 16.03125],
  [16.03125, 41, 16.12500],
  [16.03125, 45, 16.15625],
  [16.03125, 50, 16.15625],
  [16.21875, 26, 16.46875],
  [16.21875, 38, 16.46875],
  [16.46875, 41, 16.65625],
  [16.46875, 45, 16.68750],
  [16.46875, 50, 16.65625],
  [16.68750, 26, 16.81250],
  [16.68750, 38, 16.81250],
  [16.81250, 41, 16.93750],
  [16.81250, 45, 16.96875],
  [16.81250, 50, 16.93750],
  [17.00000, 26, 17.31250],
  [17.00000, 38, 17.18750],
  [17.12500, 51, 17.25000],
  [17.31250, 45, 17.56250],
  [17.31250, 48, 17.53125],
  [17.31250, 53, 17.53125],
  [17.50000, 17, 17.56250],
  [17.50000, 29, 17.56250],
  [17.59375, 17, 17.71875],
  [17.59375, 29, 17.71875],
  [17.71875, 45, 17.84375],
  [17.71875, 48, 17.87500],
  [17.71875, 53, 17.87500],
  [17.90625, 17, 18.21875],
  [17.90625, 29, 18.21875],
  [18.09375, 45, 18.25000],
  [18.09375, 48, 18.28125],
  [18.09375, 53, 18.28125],
  [18.34375, 17, 18.40625],
  [18.34375, 29, 18.40625],
  [18.40625, 45, 18.53125],
  [18.40625, 48, 18.56250],
  [18.40625, 53, 18.56250],
  [18.62500, 17, 18.87500],
  [18.62500, 29, 19.00000],
  [18.75000, 45, 18.81250],
  [18.75000, 48, 18.84375],
  [18.75000, 53, 18.81250],
  [18.96875, 43, 19.21875],
  [18.96875, 46, 19.21875],
  [18.96875, 50, 19.21875],
  [19.15625, 19, 19.21875],
  [19.15625, 31, 19.21875],
  [19.25000, 19, 19.31250],
  [19.25000, 31, 19.31250],
  [19.34375, 43, 19.46875],
  [19.34375, 46, 19.53125],
  [19.34375, 50, 19.46875],
  [19.56250, 19, 19.87500],
  [19.56250, 31, 19.87500],
  [19.87500, 43, 20.00000],
  [19.87500, 46, 20.06250],
  [19.87500, 50, 20.00000],
  [20.06250, 19, 20.12500],
  [20.06250, 31, 20.12500],
  [20.18750, 43, 20.31250],
  [20.18750, 46, 20.37500],
  [20.18750, 50, 20.31250],
  [20.37500, 19, 20.56250],
  [20.37500, 31, 20.68750],
  [20.50000, 41, 20.56250],
  [20.50000, 46, 20.59375],
  [20.50000, 51, 20.56250],
  [20.68750, 41, 20.93750],
  [20.68750, 46, 20.93750],
  [20.68750, 50, 20.90625],
  [20.93750, 22, 21.00000],
  [20.93750, 34, 21.00000],
  [21.00000, 22, 21.06250],
  [21.00000, 34, 21.06250],
  [21.06250, 41, 21.18750],
  [21.06250, 46, 21.21875],
  [21.06250, 50, 21.18750],
  [21.25000, 22, 21.50000],
  [21.25000, 34, 21.50000],
  [21.50000, 41, 21.65625],
  [21.50000, 46, 21.68750],
  [21.50000, 50, 21.65625],
];

let index = 0;
const total = testNotes[testNotes.length - 1][2];

loop(() => {
  let t = 0;
  const step = 0.03125;
  while (t <= total) {
    while (index < testNotes.length && Math.abs(testNotes[index][0] - t) < 1e-4) {
      const [s, m, e] = testNotes[index];
      sawlead.play(m+42, { duration: e - s, attack: 0.01, release: 0.2, amp: 0.6 });
      index++;
    }
    sleep(step);
    t += step;
  }
  index = 0;
}, { name: 'Haddaway-What is love_v1' });


//referencia funciones --nabr
// utilities
const { random, PI, floor, sin, abs, max, min, exp, cos, tanh, pow, tan } = Math;
const env_d = (t, d) => exp(-t * 5.436563 / d);
const env_ad = (t, a, d) => min(t / max(1e-5, a), env_d((t - a), d));
const env_adc = (t, a, d) => clamp(min(t / max(1e-5, a), env_d((t - a), d)), 0, 1);
const msat = (x, a) => 0.5 * (abs(x + a) - abs(x - a));
const softkn = (x, kn) => x / (kn * abs(x) + 1.0);
const softkna = (x, kn, ad) => x / (kn * msat(x, ad) + 1.0);
const fract = (x) => (x - floor(x));
const mod = (x, y) => (x - floor(x / y) * y);
const tau = (PI * 2.0);
const int = (x) => (x | 0);
const smoothstep = (e0, e1, value) => {const x = max(0, min(1, (value - e0) / (e1 - e0))); return x * x * (3 - 2 * x); };
const fadein = (s, e, t) => smoothstep(s, e, t);