Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
new Promise(resolve => {
const buffers = new Tone.Buffers(instrumentSamples, () => resolve(buffers));
});
new Promise(resolve => {
const activeSources = [];
const buffers = new Tone.Buffers(samplesByNote, {
onload: () =>
resolve({
triggerAttack: (note, time = '+1') => {
const closestSample = findClosest(samplesByNote, note);
const difference = Distance.semitones(closestSample, note);
const buffer = buffers.get(closestSample);
const playbackRate = Tone.intervalToFrequencyRatio(
difference + semitoneChange
);
const source = new Tone.BufferSource(buffer)
.set({
playbackRate,
onended: () => {
const i = activeSources.indexOf(buffer);
if (i >= 0) {
activeSources.splice(i, 1);
new Promise(resolve => {
const buffers = new Tone.Buffers(samplesByNote, {
onload: () => resolve(buffers),
});
});
new Promise(resolve => {
const buffers = new Tone.Buffers(samplesByNote, {
onload: () => resolve(buffers),
});
});
new Promise(resolve => {
const buffers = new Tone.Buffers(samplesByNote, {
onload: () => resolve(buffers),
baseUrl,
});
});
new Promise(resolve => {
const buffers = new Tone.Buffers(samplesByNote, {
onload: () => resolve(buffers),
});
});
new Promise(resolve => {
const activeSources = [];
const buffers = new Tone.Buffers(samplesByNote, {
onload: () => {
resolve({
triggerAttack: (note, time = Tone.now()) => {
const closestSample = findClosest(note, samplesByNote);
const difference = Distance.semitones(closestSample, note);
const buffer = buffers.get(closestSample);
const playbackRate = Tone.intervalToFrequencyRatio(
difference - semitoneChange + Math.random() * 0.1 - 0.05
);
const bufferSource = new Tone.BufferSource(buffer)
.set({
playbackRate,
onended: () => {
const i = activeSources.indexOf(bufferSource);
if (i >= 0) {
activeSources.splice(i, 1);