Studies - DBC-Works/live-tone GitHub Wiki
20240713
Tone.Transport.bpm.value = 134
const right = new Tone.Panner(0.5).toDestination()
const left = new Tone.Panner(-0.5).toDestination()
const kick = new Tone.MembraneSynth({
pitchDecay: 0.07,
envelope: {
attack: 0.1,
decay: 0.01,
sustain: 0,
release: 0.01
},
volume: 10
}).toDestination()
const hh = new Tone.NoiseSynth({
envelope: {
attack: 0.01,
decay: 0.04,
sustain: 0
},
volume: -12
}).toDestination()
const bass = new Tone.MonoSynth({
oscillator: {
type: 'fatsawtooth'
},
envelope: {
atack: 0,
decay: 0.2,
sustain: 0.5,
release: 0.1,
},
volume: 4
}).toDestination();
const itb = LiveTone.Itr.shuffle(LiveTone.Chr.chord('d2', 'sus4'))
const itc = LiveTone.Itr.shuffle(LiveTone.Chr.majorDiatonicChords('g3'))
const sc = new Tone.PolySynth({
volume: 2
}).connect(left)
const its = LiveTone.Itr.shuffle(LiveTone.Scale.Lydian.notes('d', 4))
const ss = new Tone.MonoSynth({
oscillator: {
type: 'square'
},
envelope: {
atack: 0.5,
decay: 0.02,
sustain: 0.5,
release: 1,
},
volume:0
}).connect(right)
let count = 0
LiveTone.registerPlaying(
new Tone.Loop((t) => {
const pos = (count % 4)
if (pos === 0) {
kick.triggerAttackRelease('c1', '16n', t)
}
if (pos === 2 || pos === 3) {
hh.triggerAttackRelease('16n', t)
}
if (32 <= count) {
bass.triggerAttackRelease(itb.next().value, '16n', t)
}
if (160 <= count) {
if (LiveTone.Nmb.oneIn(16) === false) {
ss.triggerAttackRelease(its.next().value, '16n', t)
}
if ((count % 2) === 0) {
if (LiveTone.Nmb.oneIn(8) === false) {
sc.triggerAttackRelease(itc.next().value, '8n', t)
}
}
}
++count
}, '16n').start(0)
)
Tone.getTransport().start()