How to use the tonal.Distance.transpose function in tonal

To help you get started, we’ve selected a few tonal 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 felixroos / harmonical / src / util.ts View on Github external
export function getDegreeInChord(degree, chord) {
  chord = Harmony.getTonalChord(chord);
  const intervals = Chord.intervals(chord);
  const tokens = Chord.tokenize(chord);
  return Distance.transpose(tokens[0], findDegree(degree, intervals));
}
github felixroos / harmonical / src / util_old.ts View on Github external
return notes.reduce((absolute, current, index, notes) => {
    if (index === 0) {
      return [current + octave];
    }
    let interval = Distance.interval(notes[index - 1], current);
    interval = Harmony.minInterval(interval, direction);
    if (interval === '1P') {
      interval = direction === 'down' ? '-8P' : '8P';
    }
    absolute.push(Distance.transpose(absolute[index - 1], interval + ''));
    return absolute;
  }, []);
}
github felixroos / harmonical / src / util_old.ts View on Github external
export function getDegreeInChord(degree, chord) {
  chord = Harmony.getTonalChord(chord);
  const intervals = Chord.intervals(chord);
  const tokens = Chord.tokenize(chord);
  return Distance.transpose(tokens[0], findDegree(degree, intervals));
}
github comorebi-notes / rechord / app / frontend / utils / scoreMaker.js View on Github external
const upOctave = (note) => Distance.transpose(note, "8M")
const addNewRootToNotes = (notes, denominator, baseKey) => {
github generative-music / pieces-alex-bainter / packages / piece-meditation / src / piece.js View on Github external
const tonicPitchClasses = Note.names().slice(
  0,
  NUM_POTENTIAL_TONIC_PITCH_CLASSES
);
const tonicPitchClass = pickRandomFromArray(tonicPitchClasses);

const pitchClassesOverOctaves = (pitchClasses, octaves) =>
  pitchClasses.reduce(
    (notes, pitchClass) =>
      notes.concat(octaves.map(octave => `${pitchClass}${octave}`)),
    []
  );

const lowPitchClasses = [
  tonicPitchClass,
  Distance.transpose(tonicPitchClass, 'P5'),
];
const highPitchClasses = lowPitchClasses.concat(
  ['M2', 'P4'].map(interval => Distance.transpose(tonicPitchClass, interval))
);
const lowNotes = pitchClassesOverOctaves(lowPitchClasses, LOWER_OCTAVES);
const highNotes = pitchClassesOverOctaves(highPitchClasses, HIGHER_OCTAVES);

const startInterval = (
  notes,
  minIntervalInSeconds,
  minDelayInSeconds,
  instrument
) => {
  const playNotes = () => {
    instrument.triggerAttack(pickRandomFromArray(notes), '+1');
    if (Math.random() > P_SECOND_NOTE) {
github generative-music / pieces-alex-bainter / packages / piece-bhairav / src / piece.js View on Github external
const playNextNote = () => {
          const { value } = ragaGenerator.next();
          const [interval, time] = value;
          const note = Distance.transpose(
            tonic,
            Interval.fromSemitones(interval)
          );
          playNote(note);
          if (Math.random() < (interval === 0 || interval === 12 ? 0.5 : 0.1)) {
            const lowNote =
              Math.random() < 0.5
                ? 'C#3'
                : Distance.transpose(note, Interval.fromSemitones(-12));
            playNote(lowNote);
          }
          Tone.Transport.scheduleOnce(() => {
            if (time > 8 && Math.random() < 0.4) {
              tonic = tonic === 'C#4' ? 'C#5' : 'C#4';
            }
            playNextNote();
github felixroos / harmonical / src / util_old.ts View on Github external
  return notes.map(note => Distance.transpose(note, interval));
}
github generative-music / pieces-alex-bainter / packages / piece-bhairav / src / piece.js View on Github external
const playNextNote = () => {
          const { value } = ragaGenerator.next();
          const [interval, time] = value;
          const note = Distance.transpose(
            tonic,
            Interval.fromSemitones(interval)
          );
          playNote(note);
          if (Math.random() < (interval === 0 || interval === 12 ? 0.5 : 0.1)) {
            const lowNote =
              Math.random() < 0.5
                ? 'C#3'
                : Distance.transpose(note, Interval.fromSemitones(-12));
            playNote(lowNote);
          }
          Tone.Transport.scheduleOnce(() => {
            if (time > 8 && Math.random() < 0.4) {
              tonic = tonic === 'C#4' ? 'C#5' : 'C#4';
            }
            playNextNote();
          }, `+${time + Math.random() - 0.5}`);
        };
github felixroos / harmonical / src / util.ts View on Github external
return notes.reduce((absolute, current, index, notes) => {
    if (index === 0) {
      return [current + octave];
    }
    let interval = Distance.interval(notes[index - 1], current);
    interval = Harmony.minInterval(interval, direction);
    if (interval === '1P') {
      interval = direction === 'down' ? '-8P' : '8P';
    }
    absolute.push(Distance.transpose(absolute[index - 1], interval + ''));
    return absolute;
  }, []);
}