How to use the tone.Sampler 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 LLK / scratch-vm / src / audio / AudioEngine.js View on Github external
AudioEngine.prototype.playSoundFromUrl = function (url) {
    if (url) {
        // if we've loaded it already, play it
        if (this.soundSamplers[url]) {
            // this.soundSamplers[url].triggerAttack();
            this.soundSamplers[url].player.start();
        } else {
        // else load, play, and store it
        // this results in a delay the first time you play the sound
            var sampler = new Tone.Sampler(url, function() {
                sampler.triggerAttack();
                this.soundSamplers[url] = sampler;
            }.bind(this)).toMaster();
        }
    }
};
github generative-music / pieces-alex-bainter / packages / piece-impact / src / piece.js View on Github external
return Promise.all(noteBuffers).then(buffers => {
          const bufferCopies = buffers.map(buffer =>
            new Tone.Buffer().fromArray(buffer.toArray())
          );
          const regularInstrument = new Sampler(
            buffersToObj(bufferCopies, notes)
          );
          buffers.forEach(buffer => {
            buffer.reverse = true;
          });
          const reverseInstrument = new Sampler(buffersToObj(buffers, notes));
          const durationsByMidi = {};
          const nextNote = makeNextNote(
            reverseInstrument,
            regularInstrument,
            durationsByMidi
          );
          nextNote();
          [reverseInstrument, regularInstrument].forEach(i =>
            i.connect(destination)
          );
github googlecreativelab / creatability-seeing-music / src / piano / Piano.js View on Github external
await new Promise(onload => {
			this._sampler = new Sampler({
				C1 : 'C1.mp3',
				'D#1' : 'Ds1.mp3',
				'F#1' : 'Fs1.mp3',
				A1 : 'A2.mp3',
				C2 : 'C2.mp3',
				'D#2' : 'Ds2.mp3',
				'F#2' : 'Fs2.mp3',
				A2 : 'A2.mp3',
				C3 : 'C3.mp3',
				'D#3' : 'Ds3.mp3',
				'F#3' : 'Fs3.mp3',
				A3 : 'A3.mp3',
				C4 : 'C4.mp3',
				'D#4' : 'Ds4.mp3',
				'F#4' : 'Fs4.mp3',
				A4 : 'A4.mp3',
github tambien / Piano / src / String.ts View on Github external
return new Promise(onload => {
			this._sampler = this.output = new Sampler({
				attack : 0,
				baseUrl: this.samples,
				curve : 'exponential',
				onload,
				release : 0.4,
				urls: this._urls,
				volume : 3,
			})
		})
	}
github generative-music / pieces-alex-bainter / packages / piece-apoapsis / src / piece.js View on Github external
.then(buffers =>
          new Tone.Sampler(
            Reflect.ownKeys(pianoSamples).reduce((reverseConfig, note, i) => {
              reverseConfig[note] = buffers[i];
              reverseConfig[note].reverse = true;
              return reverseConfig;
            }, {})
          ).chain(reverb)
        )
github generative-music / pieces-alex-bainter / packages / piece-above-the-rain / src / piece.js View on Github external
new Promise(resolve => {
    const sampler = new Tone.Sampler(
      samplesByNote,
      Object.assign(
        {
          onload: () => resolve(sampler),
        },
        opts
      )
    );
  });
github generative-music / pieces-alex-bainter / packages / piece-spring-again / src / piece.js View on Github external
new Promise(resolve => {
    const instrument = new Tone.Sampler(samplesByNote, {
      onload: () => resolve(instrument),
    });
  });
github generative-music / pieces-alex-bainter / packages / piece-apoapsis / src / piece.js View on Github external
const delay1 = new Tone.FeedbackDelay({
        feedback: 0.7,
        delayTime: 0.2,
        wet: 0.5,
      });
      const delay2 = new Tone.FeedbackDelay({
        feedback: 0.6,
        delayTime: Math.random() * 10 + 20,
        wet: 0.5,
      });
      const reverb = new Tone.Freeverb({ roomSize: 0.9, wet: 0.5 });
      reverb.chain(delay1, delay2, destination);

      const violinReverb = new Tone.Freeverb({ roomSize: 0.8, wet: 0.5 });
      const violins = new Tone.Sampler(
        samples['vsco2-violins-susvib'][preferredFormat],
        {
          release: 8,
          curve: 'linear',
          onload: () => {
            const notes = Chord.notes('C', 'maj7').reduce(
              (allNotes, pc) =>
                allNotes.concat([2, 3, 4].map(octave => `${pc}${octave}`)),
              []
            );
            notes.forEach(note => {
              Tone.Transport.scheduleRepeat(
                () => violins.triggerAttack(note, '+1'),
                Math.random() * 120 + 60,
                30
              );
github ritz078 / raaga / utils / Player.ts View on Github external
constructor({
    canvasWorker,
    range
  }: {
    canvasWorker: CanvasWorkerFallback;
    range: Range;
  }) {
    this.range = range;
    this.sampler = new Tone.Sampler({});
    this.sampler.connect(Tone.Master);
    this.canvasWorker = canvasWorker;
  }
github generative-music / pieces-alex-bainter / packages / piece-timbral-oscillations / src / piece.js View on Github external
new Promise(resolve => {
    const instrument = new Tone.Sampler(samplesByNote, {
      onload: () => resolve(instrument),
    });
  });