Sample: chord - DBC-Works/live-tone GitHub Wiki

Tone.Transport.bpm.value = 144
const right = new Tone.Panner(0.3).toDestination()
const left = new Tone.Panner(-0.3).toDestination()

const ita = LiveTone.Itr.fromFirst(LiveTone.Chr.chord('G4', 'M7'))
const sa = new Tone.AMSynth({
  envelope: {
    atack: 0,
    decay: 0,
    release: 0.2,
  },
}).connect(right)
sa.volume.value = -4
LiveTone.registerPlaying(
  new Tone.Loop((time) => {
    sa.triggerAttackRelease(ita.next().value, `16n`, time)
  }, '16n').start(0)
)

const itc = LiveTone.Itr.shuffle(LiveTone.Chr.majorDiatonicChords('G3'))
const sc = new Tone.PolySynth().connect(left)
sc.volume.value = -2
LiveTone.registerPlaying(
  new Tone.Loop((time) => {
    if (LiveTone.Nmb.oneIn(8) === false) {
      sc.triggerAttackRelease(itc.next().value, `8n`, time)
    }
  }, '8n').start(0)
)

const itb = LiveTone.Itr.shuffle(LiveTone.Chr.chord('G2', 'sus4'))
const sb = new Tone.MonoSynth().toDestination()
LiveTone.registerPlaying(
  new Tone.Loop((time) => {
    sb.triggerAttackRelease(itb.next().value, `32n`, time)
  }, '16n').start(0)
)

const kick = new Tone.MonoSynth({
  oscillator: { type: 'fatsawtooth' },
  envelope: {
    atack: 0,
    decay: 0,
    release: 0.2,
  },
}).toDestination()
kick.volume.value = 20
LiveTone.registerPlaying(
  new Tone.Loop((time) => {
    kick.triggerAttackRelease('C0', `32n`, time)
  }, '4n').start(0)
)

Tone.Transport.start()