How to use the tonal.Note.pc 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 generative-music / pieces-alex-bainter / packages / piece-substrate / src / piece.js View on Github external
const playAndScheduleNext = () => {
          const next = noteGenerator.next();
          if (!next.done) {
            playNote(next.value);
            const pc = Note.pc(next.value);
            const oct = Note.oct(next.value);
            if (Math.random() < 0.5) {
              const delay = Math.random() < 0.5 ? 0 : Math.random() * 2;
              playSecondaryNote(`${pc}${oct + 1}`, delay);
            }

            Tone.Transport.scheduleOnce(() => {
              playAndScheduleNext();
            }, `+${3 + Math.random()}`);
          } else {
            noteGenerator = makeNoteGenerator(swapTwo(notes));
            Tone.Transport.scheduleOnce(() => {
              playAndScheduleNext();
            }, `+${Math.random() + 4}`);
          }
        };
github generative-music / pieces-alex-bainter / packages / piece-spring-again / src / piece.js View on Github external
repeat(() => {
        if (Math.random() < 0.9) {
          const note = phrase[Math.floor(Math.random() * phrase.length)];
          violins.triggerAttack(note);
          const pc = Note.pc(note);
          if (Math.random() < 0.2) {
            cello.triggerAttack(`${pc}${1}`);
          }
        }
      }, (phrase.length * 5) / NOTES_PER_SECOND);
      return () => {
github generative-music / pieces-alex-bainter / packages / piece-otherness / src / piece.js View on Github external
const playNote = (instrument, sineSynth, lastNoteMidi) => {
  const newNotes = notes.filter(n => Note.midi(n) !== lastNoteMidi);
  const note = newNotes[Math.floor(Math.random() * newNotes.length)];
  instrument.triggerAttack(note, '+1.5');
  const pitchClass = Note.pc(note);
  sineSynth.triggerAttackRelease(`${pitchClass}1`, 5, '+1.5');
  Tone.Transport.scheduleOnce(() => {
    playNote(instrument, sineSynth, Note.midi(note));
  }, `+${Math.random() * 10 + 10}`);
};
github generative-music / pieces-alex-bainter / packages / piece-pulse-code-modulation / src / piece.js View on Github external
let primarySampler;
              let primaryOctaves;
              let secondarySampler;
              let secondaryOctaves;
              if (Math.random() < 0.5) {
                primarySampler = pianoSampler;
                primaryOctaves = PIANO_OCTAVES;
                secondarySampler = guitarSampler;
                secondaryOctaves = GUITAR_OCTAVES;
              } else {
                primarySampler = guitarSampler;
                primaryOctaves = GUITAR_OCTAVES;
                secondarySampler = pianoSampler;
                secondaryOctaves = PIANO_OCTAVES;
              }
              const firstPc = Note.pc(pickRandom(notes));
              const noteTime = 1 + Math.random();
              primarySampler.triggerAttack(
                `${firstPc}${pickRandom(primaryOctaves)}`,
                `+${noteTime}`
              );
              if (Math.random() < 0.5) {
                secondarySampler.triggerAttack(
                  `${firstPc}${pickRandom(secondaryOctaves)}`,
                  `+${noteTime * 3}`
                );
              }
              if (Math.random() < 0.5) {
                const otherNoteTime = 3 + Math.random() * 2;
                const secondPc = Note.pc(
                  pickRandom(notes.filter(note => Note.pc(note) !== firstPc))
                );
github generative-music / generative.fm / src / pieces / otherness.js View on Github external
const playNote = (instrument, sineSynth, onTimeoutCreated, lastNoteMidi) => {
  const newNotes = notes.filter(n => Note.midi(n) !== lastNoteMidi);
  const note = newNotes[Math.floor(Math.random() * newNotes.length)];
  instrument.triggerAttack(note, '+1.5');
  const pitchClass = Note.pc(note);
  sineSynth.triggerAttackRelease(`${pitchClass}1`, 5, '+1.5');
  const timeout = setTimeout(() => {
    playNote(instrument, sineSynth, onTimeoutCreated, Note.midi(note));
  }, Math.random() * 10000 + 10000);
  onTimeoutCreated(timeout);
};
github felixroos / harmonical / src / util.ts View on Github external
export function isPitchClass(note) {
  return Note.pc(note) === note;
}