How to use pick-random - 5 common examples

To help you get started, we’ve selected a few pick-random examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github generative-music / pieces-alex-bainter / packages / piece-sevenths / src / piece.js View on Github external
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(() => {
github generative-music / pieces-alex-bainter / packages / piece-sevenths / src / piece.js View on Github external
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({
github generative-music / pieces-alex-bainter / packages / piece-pinwheels / src / piece.js View on Github external
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,
    });
github generative-music / pieces-alex-bainter / packages / piece-sevenths / src / piece.js View on Github external
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,
github generative-music / pieces-alex-bainter / packages / piece-pinwheels / src / piece.js View on Github external
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();
              }

pick-random

Pick random items from a list

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular pick-random functions