Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const scheduleChord = () => {
const [tonic] = pickRandom(tonal.Note.names());
const [chordType] = pickRandom(CHORDS);
const [octave] = pickRandom(OCTAVES);
const octavedTonic = `${tonic}${octave}`;
const intervals = tonal.Chord.intervals(chordType);
const inversion = randomNumber({ min: 0, max: 3, integer: true });
const notes = intervals.map((interval, i) =>
tonal.Distance.transpose(
octavedTonic,
i < inversion ? tonal.Interval.invert(interval) : interval
)
);
const chordTime = randomNumber({
min: MIN_NEXT_CHORD_TIME_S,
max: MAX_NEXT_CHORD_TIME_S,
});
Tone.Transport.scheduleOnce(() => {
const scheduleChord = () => {
const [tonic] = pickRandom(tonal.Note.names());
const [chordType] = pickRandom(CHORDS);
const [octave] = pickRandom(OCTAVES);
const octavedTonic = `${tonic}${octave}`;
const intervals = tonal.Chord.intervals(chordType);
const inversion = randomNumber({ min: 0, max: 3, integer: true });
const notes = intervals.map((interval, i) =>
tonal.Distance.transpose(
octavedTonic,
i < inversion ? tonal.Interval.invert(interval) : interval
)
);
const chordTime = randomNumber({
min: MIN_NEXT_CHORD_TIME_S,
max: MAX_NEXT_CHORD_TIME_S,
});
Tone.Transport.scheduleOnce(() => {
const arpeggioTime = randomNumber({
const generatePinwheel = (
tonic = pickRandom(TONICS)[0],
maxDelay = getNewMaxDelay(),
spawnAnother = true
) => {
const inversion = randomBetween(0, MAX_INVERSION, true);
const intervals = tonal.Chord.intervals(CHORD_TYPE);
const notes = intervals.map((interval, i) =>
tonal.Distance.transpose(
tonic,
i < inversion ? tonal.Interval.invert(interval) : interval
)
);
const noteGenerator = makeArrayLooper(shuffle(notes));
const minDelay = randomNumber({
min: MIN_MIN_DELAY_S,
max: MAX_MIN_DELAY_S,
});
const scheduleChord = () => {
const [tonic] = pickRandom(tonal.Note.names());
const [chordType] = pickRandom(CHORDS);
const [octave] = pickRandom(OCTAVES);
const octavedTonic = `${tonic}${octave}`;
const intervals = tonal.Chord.intervals(chordType);
const inversion = randomNumber({ min: 0, max: 3, integer: true });
const notes = intervals.map((interval, i) =>
tonal.Distance.transpose(
octavedTonic,
i < inversion ? tonal.Interval.invert(interval) : interval
)
);
const chordTime = randomNumber({
min: MIN_NEXT_CHORD_TIME_S,
max: MAX_NEXT_CHORD_TIME_S,
});
Tone.Transport.scheduleOnce(() => {
const arpeggioTime = randomNumber({
min: MIN_ARPEGGIO_TIME_S,
Tone.Transport.scheduleOnce(() => {
if (Math.random() < P_SPAWN_TWO) {
const [nextLetter] = pickRandom(tonal.Note.names());
const shuffledOctaves = shuffle(OCTAVES.slice(0));
const delay1 = getNewMaxDelay();
const delay2 = getNewMaxDelay();
generatePinwheel(
`${nextLetter}${shuffledOctaves.pop()}`,
delay1,
delay1 >= delay2
);
generatePinwheel(
`${nextLetter}${shuffledOctaves.pop()}`,
delay2,
delay1 < delay2
);
} else {
generatePinwheel();
}