Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount () {
// synth.triggerAttackRelease('E4', 3.5, 0)
// synth.triggerAttackRelease('E4', 0.5, 1)
// synth.triggerAttackRelease('G4', 0.5, 2)
// synth.triggerAttackRelease('B4', 0.5, 3)
console.log(`componentDidMount ${this.uuid}`)
Tone.Transport.start('+0.1')
this.rs()
window.Tone = Tone
// this.s(2)
// this.s(4)
// this.s(6)
Tone.Transport.loopEnd = '1m'
Tone.Transport.loop = true
// TONE
// Tone.Transport.bpm.value = 120
// Tone.Transport.loopEnd = '4m'
// Tone.Transport.loop = true
// Tone.Transport.start('+0.1')
// window.Tone = Tone
}
Tone.context.resume().then(() => {
if (!(LinkClient.isEnabled())) {
// start the normal way
Tone.Transport.start("+0.2");
resolve();
}
else {
log.info('LINK: Waiting for `downbeat` message...');
// wait for Link-socket to give downbeat signal
LinkClient.once('downbeat', () => {
downbeatStartCallback();
log.info('LINK: Received `downbeat` message, starting playback');
resolve();
});
}
})
})
export function toTickTime(time: number) {
// FIXME(3) is ceil right?
return `${Math.ceil(time * Tone.Transport.PPQ)}i`;
}
gui.add(text, 'audio', false).onChange(value => {
if (value) {
Tone.Transport.toggle();
//sound1.play();
audioInterval = setInterval(function () {
if(!soundQueue.isEmpty()) {
const newSoundJob = soundQueue.dequeue();
console.log(newSoundJob)
if (newSoundJob) {
Tone.Transport.schedule (function(time){
synth.triggerAttackRelease(newSoundJob.tone,newSoundJob.pace, time);
},
Tone.context.currentTime.toFixed(2)
)
}
}
}, 400);
} else {
if (audioInterval) {
() => {
Tone.Transport.bpm.value = bpm;
},
[bpm]
notes.forEach(note => {
const interval = timing.value;
const delay = timing.value - MIN_REPEAT_S;
Tone.Transport.scheduleRepeat(
() => {
const random = Math.random();
const probability = getPlayProbability();
if (random <= probability) {
instruments.forEach(instrument =>
instrument.triggerAttackRelease(note, '+1')
);
}
},
interval,
delay
);
});
};
const play = time => {
Tone.Transport.scheduleOnce(() => {
const semitoneChange = playNote(note);
play(Math.random() * (semitoneChange + 12) + 3);
}, `+${time}`);
};
play(firstDelays[i] - minFirstDelay);
].forEach(([inst, pattern], i) => {
if (i > 0 || Math.random() < 0.25) {
Tone.Transport.scheduleRepeat(
() => {
pattern.forEach(beat => {
inst.play(`+${beat * sixteenthTime + 0.05}`);
});
},
BEAT_SIXTEETHS_COUNT * sixteenthTime,
'+0.05',
DRUM_LOOP_LENGTH_S - BEAT_SIXTEETHS_COUNT * sixteenthTime + 0.5
);
}
});
Tone.Transport.scheduleOnce(() => {
playDrumLoop();
}, `+${DRUM_LOOP_LENGTH_S + 3}`);
};
notes.forEach(note => {
Tone.Transport.scheduleRepeat(
() => violins.triggerAttack(note, '+1'),
Math.random() * 120 + 60,
30
);
});
},
const i = activeSources.indexOf(source);
if (i > -1) {
activeSources.splice(i, 1);
}
},
})
.connect(vol);
source.start('+1', 0, buf.duration / playbackRate);
activeSources.push(source);
if (Math.random() < 0.15) {
const [pc] = note;
trumpet.triggerAttack(`${pc}3`, `${1 + Math.random() * 5}`);
}
Tone.Transport.scheduleOnce(() => {
play(notes);
}, `+${buf.duration / playbackRate - 4 + Math.random() * 5 - 2.5}`);
};