How to use the tone.Player 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 vibertthio / musical-ml-web-demo-minimal-template / src / drum-machine / audio-manager.js View on Github external
this.currentIndex = 0;
    this.samples = [];
    this.loadingStatus = 0;
    this.loadingSamplesCallback = loadingSamplesCallback;
    this.drumUrls = drumUrls;
    this.beat = 0;

    this.initParameters();
    this.loadSamples();

    // Set BPM
    Transport.bpm.value = 120;

    // Init Effects
    this.effects = [];
    this.effects[0] = new Tone.Player(effectUrls[0]).toMaster();

    this.sequence = new Sequence((time, col) => {
      this.beat = col;
      const column = this.matrix[col];
      for (let i = 0; i < 9; i += 1) {
        if (column[i] === 1) {
          this.samples[i].start(time);
        }
      }
    }, Array.from(Array(96).keys()), '96n');
    Transport.start();
  }
github vibertthio / musical-ml-web-demo-minimal-template / src / drum-machine / audio-manager.js View on Github external
loadSamples() {
    console.log('start loading samples..');
    this.samples = [];
    for (let i = 0; i < 9; i += 1) {
      this.samples[i] = new Player(this.drumUrls[i], () => {
        this.loadingStatus += 1;
        this.loadingSamplesCallback(this.loadingStatus);
      }).toMaster();
      this.samples[i].volume.value = this.mixing[i];
    }
  }
github googlecreativelab / creatability-seeing-music / src / piano / Model.js View on Github external
await wait(100)
			this.loading = true
			try {
				let buffer
				try {
					buffer = await Buffer.fromUrl(url)
				} catch (e){
					throw new Error('could not load file.')
				}
				if (buffer.duration > 30){
					throw new Error('audio file must be under 30 seconds long.')
				}
				const fetchResponse = await fetch(url)
				const blob = await fetchResponse.blob()
				const transcription = await this.model.transcribeFromAudioFile(blob)
				this.player = new Player()
				if (FILE_PLAYS_SOUND){
					this.player.toMaster()
				}
				this.player.buffer = buffer
				this.player.sync().start(0)
				this.addNotes(transcription.notes)
				Transport.loopEnd = buffer.duration
				Transport.start()
			} catch (e){
				this.emit('clear')
				document.querySelector('acc-snackbar').setAttribute('message', e)
				document.querySelector('acc-snackbar').show()
			}
			this.loading = false
		}
	}
github vibertthio / runn / src / three / kare / index.js View on Github external
function initSound() {
  const p1 = new Player(woodenFish).toMaster();
  p1.autostart = true;
  p1.loop = true;

  const p2 = new Player(meditation).toMaster();
  p2.autostart = true;
  p2.loop = true;
  p2.fadeOut = '1.0';
  p2.fadeIn = '45.0';

  meditationPlayer = p2;
}
github vibertthio / runn / src / music / sound.js View on Github external
initEffects() {
    this.effects = [];
    this.effects[0] = new Tone.Player(beepSound).toMaster();
    this.effects[1] = new Tone.Player(wrongSound).toMaster();
    this.effects[2] = new Tone.Player(correctSound).toMaster();
    this.effects[3] = new Tone.Player(endSound).toMaster();
    this.effects[4] = new Tone.Player(transitionSound).toMaster();
  }
github vibertthio / runn / src / music / sound.js View on Github external
initEffects() {
    this.effects = [];
    this.effects[0] = new Tone.Player(beepSound).toMaster();
    this.effects[1] = new Tone.Player(wrongSound).toMaster();
    this.effects[2] = new Tone.Player(correctSound).toMaster();
    this.effects[3] = new Tone.Player(endSound).toMaster();
    this.effects[4] = new Tone.Player(transitionSound).toMaster();
  }
github marklundin / touchscreen / js / sounds.js View on Github external
synth.envelope.release = 1.5;


	let openSound = new Tone.Player({
		"url" : "./audio/open-puck.mp3",
		retrigger: true,
		"loop" : false
	}).toMaster();

	let closeSound = new Tone.Player({
		"url" : "./audio/close-puck.mp3",
		retrigger: true,
		"loop" : false
	}).toMaster();

	let tapSound = new Tone.Player({
		"url" : "./audio/tap.mp3",
		retrigger: true,
		"loop" : false
	}).toMaster();


	api = {
	
		triggerInteraction: () => synth.triggerAttack("G4"),
		stopInteraction: () => synth.triggerRelease(),

		openSound: () => openSound.start(),
		closeSound: () => closeSound.start(),
		tapSound: () => tapSound.start()

	}
github vibertthio / runn / src / music / sound.js View on Github external
initEffects() {
    this.effects = [];
    this.effects[0] = new Tone.Player(beepSound).toMaster();
    this.effects[1] = new Tone.Player(wrongSound).toMaster();
    this.effects[2] = new Tone.Player(correctSound).toMaster();
    this.effects[3] = new Tone.Player(endSound).toMaster();
    this.effects[4] = new Tone.Player(transitionSound).toMaster();
  }
github scribbletune / scribbletune / src / webaudio.js View on Github external
constructor(params) {
		var player;
		this.idx = params.idx,
		this.activeClipIdx = -1;
		if (params.sound) {
			player = new Tone.Player(params.sound);
		}
		this._clips = params.loops.map((loop, i) => {
			if (loop.pattern) {
				return sequence({
					player,
					pattern: loop.pattern
				});
			} else {
				return null;
			}
		});
	}