Frère Jacques

Just for test

Log in to post a comment.

ditty.bpm = 120;

// =======================
// OUTILS
// =======================
sine.attack = 0;
sine.release = 0.1;

function note(n, d) {
  sine.play(n);
  sleep(d);
}

// =======================
// VOIX 1 — MÉLODIE
// =======================
loop(() => {

  // Frère Jacques (x2)
  note(c4,0.5); note(d4,0.5); note(e4,0.5); note(c4,0.5);
  note(c4,0.5); note(d4,0.5); note(e4,0.5); note(c4,0.5);

  // Dormez-vous ?
  note(e4,0.5); note(f4,0.5); note(g4,1);
  note(e4,0.5); note(f4,0.5); note(g4,1);

  // Sonnez les matines
  note(g4,0.25); note(a4,0.25); note(g4,0.25); note(f4,0.25);
  note(e4,0.5); note(c4,0.5);

  // Ding dang dong
  note(g3,0.5); note(c4,0.5); note(g3,1);

}, { name: "Melody" });


// =======================
// VOIX 2 — CANON (retardée)
// =======================
loop(() => {

  sleep(4); // entrée du canon

  note(c4,0.5); note(d4,0.5); note(e4,0.5); note(c4,0.5);
  note(c4,0.5); note(d4,0.5); note(e4,0.5); note(c4,0.5);

  note(e4,0.5); note(f4,0.5); note(g4,1);
  note(e4,0.5); note(f4,0.5); note(g4,1);

  note(g4,0.25); note(a4,0.25); note(g4,0.25); note(f4,0.25);
  note(e4,0.5); note(c4,0.5);

  note(g3,0.5); note(c4,0.5); note(g3,1);

}, { name: "Canon" });


// =======================
// BASSE
// =======================
const bass = synth.def(
  (phase, env) => Math.sin(phase * Math.PI * 2) * env.value,
  { attack: 0, release: 0.3 }
);

loop(() => {
  bass.play(c2); sleep(1);
  bass.play(g1); sleep(1);
  bass.play(c2); sleep(1);
  bass.play(g1); sleep(1);
}, { name: "Bass" });


// =======================
// RYTHME (pulsation)
// =======================
const pulse = synth.def(
  (phase, env) => Math.sin(phase * 30) * env.value,
  { attack: 0, release: 0.05 }
);

loop(() => {
  pulse.play(c3);
  sleep(1);
}, { name: "Pulse" });