How to use the tone.Transport function in tone

To help you get started, we’ve selected a few tone 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 dotgreg / XinDaw / imports / client / components / old / Test1music.jsx View on Github external
componentDidMount () {
    // synth.triggerAttackRelease('E4', 3.5, 0)
    // synth.triggerAttackRelease('E4', 0.5, 1)
    // synth.triggerAttackRelease('G4', 0.5, 2)
    // synth.triggerAttackRelease('B4', 0.5, 3)
    console.log(`componentDidMount ${this.uuid}`)
    Tone.Transport.start('+0.1')
    this.rs()
    window.Tone = Tone
    // this.s(2)
    // this.s(4)
    // this.s(6)
    Tone.Transport.loopEnd = '1m'
    Tone.Transport.loop = true


    // TONE
    // Tone.Transport.bpm.value = 120
    // Tone.Transport.loopEnd = '4m'
    // Tone.Transport.loop = true
    // Tone.Transport.start('+0.1')
    // window.Tone = Tone

  }
github SonyCSLParis / NONOTO / src / renderer / playback.ts View on Github external
Tone.context.resume().then(() => {
            if (!(LinkClient.isEnabled())) {
                // start the normal way
                Tone.Transport.start("+0.2");
                resolve();
            }
            else {
                log.info('LINK: Waiting for `downbeat` message...');
                // wait for Link-socket to give downbeat signal
                LinkClient.once('downbeat', () => {
                    downbeatStartCallback();
                    log.info('LINK: Received `downbeat` message, starting playback');
                    resolve();
                });
            }
        })
    })
github dawg / vusic / src / utils.ts View on Github external
export function toTickTime(time: number) {
  // FIXME(3) is ceil right?
  return `${Math.ceil(time * Tone.Transport.PPQ)}i`;
}
github KTH / ci-hackathon / participants / kai-chu / roaming / src / index.js View on Github external
gui.add(text, 'audio', false).onChange(value => {
  if (value) {
    Tone.Transport.toggle();
    //sound1.play();
    audioInterval = setInterval(function () {
      if(!soundQueue.isEmpty()) {
        const newSoundJob = soundQueue.dequeue();
        console.log(newSoundJob)
        if (newSoundJob) {
          Tone.Transport.schedule (function(time){
            synth.triggerAttackRelease(newSoundJob.tone,newSoundJob.pace, time);
          },
          Tone.context.currentTime.toFixed(2)
          )
        }
      }
    }, 400);
  } else {
    if (audioInterval) {
github dabit3 / hype-beats / src / DrumMachine.js View on Github external
() => {
      Tone.Transport.bpm.value = bpm;
    },
    [bpm]
github generative-music / pieces-alex-bainter / packages / piece-lemniscate / src / piece.js View on Github external
notes.forEach(note => {
    const interval = timing.value;
    const delay = timing.value - MIN_REPEAT_S;
    Tone.Transport.scheduleRepeat(
      () => {
        const random = Math.random();
        const probability = getPlayProbability();
        if (random <= probability) {
          instruments.forEach(instrument =>
            instrument.triggerAttackRelease(note, '+1')
          );
        }
      },
      interval,
      delay
    );
  });
};
github generative-music / pieces-alex-bainter / packages / piece-day-dream / src / piece.js View on Github external
const play = time => {
            Tone.Transport.scheduleOnce(() => {
              const semitoneChange = playNote(note);
              play(Math.random() * (semitoneChange + 12) + 3);
            }, `+${time}`);
          };
          play(firstDelays[i] - minFirstDelay);
github generative-music / pieces-alex-bainter / packages / piece-didgeridoobeats / src / piece.js View on Github external
].forEach(([inst, pattern], i) => {
            if (i > 0 || Math.random() < 0.25) {
              Tone.Transport.scheduleRepeat(
                () => {
                  pattern.forEach(beat => {
                    inst.play(`+${beat * sixteenthTime + 0.05}`);
                  });
                },
                BEAT_SIXTEETHS_COUNT * sixteenthTime,
                '+0.05',
                DRUM_LOOP_LENGTH_S - BEAT_SIXTEETHS_COUNT * sixteenthTime + 0.5
              );
            }
          });

          Tone.Transport.scheduleOnce(() => {
            playDrumLoop();
          }, `+${DRUM_LOOP_LENGTH_S + 3}`);
        };
github generative-music / pieces-alex-bainter / packages / piece-apoapsis / src / piece.js View on Github external
notes.forEach(note => {
              Tone.Transport.scheduleRepeat(
                () => violins.triggerAttack(note, '+1'),
                Math.random() * 120 + 60,
                30
              );
            });
          },
github generative-music / pieces-alex-bainter / packages / piece-above-the-rain / src / piece.js View on Github external
const i = activeSources.indexOf(source);
                if (i > -1) {
                  activeSources.splice(i, 1);
                }
              },
            })
            .connect(vol);
          source.start('+1', 0, buf.duration / playbackRate);
          activeSources.push(source);

          if (Math.random() < 0.15) {
            const [pc] = note;
            trumpet.triggerAttack(`${pc}3`, `${1 + Math.random() * 5}`);
          }

          Tone.Transport.scheduleOnce(() => {
            play(notes);
          }, `+${buf.duration / playbackRate - 4 + Math.random() * 5 - 2.5}`);
        };