Lyoba

First Song 4 fun and test

Log in to post a comment.

ditty.bpm = 110;

// =======================
// INSTRUMENTS
// =======================

// LEAD
sine.attack = 0;
sine.release = 0.05;

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

// PAD
const pad = synth.def(
  (phase, env) => Math.sin(phase * Math.PI * 2) * env.value * 0.5,
  { attack: 0.4, release: 1.2 }
);

// KICK
const kick = synth.def(
  (phase, env) => Math.sin(phase * 40) * env.value,
  { attack: 0, release: 0.08 }
);

// SNARE
const snare = synth.def(
  () => (Math.random() * 2 - 1),
  { attack: 0, release: 0.06 }
);

// HIHAT
const hihat = synth.def(
  () => (Math.random() * 2 - 1),
  { attack: 0, release: 0.02 }
);

// =======================
// BATTERIE (continue)
// =======================
loop(() => {
  kick.play(c1); sleep(1);
  snare.play(c4); sleep(1);
}, { name: "KickSnare" });

loop(() => {
  hihat.play(c6); sleep(0.25);
}, { name: "HiHat" });

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

// =======================
// MORCEAU PRINCIPAL (TIMELINE)
// =======================
loop(() => {

  // ===== INTRO (pad seul)
  pad.play(c4); sleep(4);
  pad.play(a3); sleep(4);

  // ===== PARTIE A (lead simple)
  sine.play(c5); sleep(0.5);
  sine.play(e5); sleep(0.5);
  sine.play(g5); sleep(1);

  sine.play(e5); sleep(0.5);
  sine.play(d5); sleep(0.5);
  sine.play(c5); sleep(1);

  // ===== PARTIE B (variation)
  sine.play(g5); sleep(0.5);
  sine.play(e5); sleep(0.5);
  sine.play(c5); sleep(1);

  sine.play(a4); sleep(0.5);
  sine.play(g4); sleep(0.5);
  sine.play(e4); sleep(1);

  // ===== BREAK (pad only)
  pad.play(f4); sleep(4);
  pad.play(g4); sleep(4);

}, { name: "Song" });