How to use the tone.Part 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 SonyCSLParis / NONOTO / src / renderer / playback.ts View on Github external
//schedule the pedal
    let sustain = new Tone.Part((time, event) => {
        if (event.value){
            Instruments.getCurrentInstrument().pedalDown(time);
        } else {
            Instruments.getCurrentInstrument().pedalUp(time);
        }
    }, midiTrack.controlChanges[64]).start(0);

    let noteOffEvents = new Tone.Part((time, event) => {
        Instruments.getCurrentInstrument().keyUp(
            event.midi, time, event.velocity);
    }, midiTrack.noteOffs).start(0);

    let noteOnEvents = new Tone.Part((time, event) => {
        Instruments.getCurrentInstrument().keyDown(
            event.midi, time, event.velocity);
    }, midiTrack.notes).start(0);

    log.trace('Midi track content');
    log.trace(midiTrack.noteOffs);
    log.trace(midiTrack.notes);

    // set correct loop points for all tracks and activate infinite looping
    for (let part of [sustain, noteOffEvents, noteOnEvents]) {
        part.loop = true;
        part.loopEnd = sequenceDuration_toneTime;
    }
}
github SonyCSLParis / NONOTO / src / renderer / playback.ts View on Github external
function scheduleTrackToInstrument(sequenceDuration_toneTime: Tone.Time,
    midiTrack, midiChannel=1) {
    const notes = midiTrack.notes;

    let playNote_callback;
    playNote_callback = getPlayNoteByMidiChannel(midiChannel);

    let part = new Tone.Part(playNote_callback, notes);
    part.start(0)  // schedule events on the Tone timeline
    part.loop = true;
    part.loopEnd = sequenceDuration_toneTime;

    //schedule the pedal
    let sustain = new Tone.Part((time, event) => {
        if (event.value){
            Instruments.getCurrentInstrument().pedalDown(time);
        } else {
            Instruments.getCurrentInstrument().pedalUp(time);
        }
    }, midiTrack.controlChanges[64]).start(0);

    let noteOffEvents = new Tone.Part((time, event) => {
        Instruments.getCurrentInstrument().keyUp(
            event.midi, time, event.velocity);
github comorebi-notes / rechord / app / frontend / components / Score / SoundControl / index.js View on Github external
break
        case STREAK_NOTE:
          this.releaseNotes(currentNotes, time)
          this.attackNotes(currentNotes, time, index)
          break
        case END_MARKER:
          this.releaseNotes(currentNotes, time)
          this.handleStop()
          break
        default:
          this.releaseNotes(currentNotes, time)
          this.attackNotes(capoNotes, time, index)
          this.setState({ currentNotes: capoNotes })
      }
    }
    const part = new Part(triggerInstrument, score)
    part.loop = false
    part.start()
  }
  setClickSchedule = (score) => {
github comorebi-notes / rechord / app / frontend / utils / sound.js View on Github external
  const setSchedule = () => new Tone.Part(triggerSynth, score).start()
github vibertthio / jazz-rnn / src / jazz-rnn.js View on Github external
dataToNotes(
            data2.Data[0].Chord.Notes,
            data.Data[0].Chord.BeatResolutions,
            0,
            1
          )
        )
        .concat(
          dataToNotes(
            data3.Data[0].Chord.Notes,
            data.Data[0].Chord.BeatResolutions,
            0,
            2
          )
        );
      const chordsPart = new Part((time, values) => {
        const { note, duration, vel } = values;
        this.sounds.chordsSound.play(note, time, { gain: vel, duration });
      }, chordsNotes);
      chordsPart.loop = true;
      chordsPart.loopEnd = 48;

      this.parts = {
        data,
        datas: [data, data2, data3],
        bassPart,
        chordsPart,
        melodyPart
      };
    };
github googlecreativelab / creatability-seeing-music / src / piano / Model.js View on Github external
constructor(){

		super()

		this._enabled = false

		/**
		 * The part which plays the transcription
		 */
		this.part = new Part(this._playNote.bind(this)).start(0)

		/**
		 * The loaidng indicator
		 */
		this.loader = document.querySelector('acc-loader')

		this.notes = null

		this._wasPlaying = false

		this.piano = new Piano()

	}
github tambien / Piano / Demo.js View on Github external
piano.keyDown(event.note, event.velocity, time).keyUp(event.note, time + event.duration)
	}

	Transport.bpm.value = midi.bpm
	Transport.timeSignature = midi.timeSignature

	//schedule the pedal
	let sustain = new Part((time, event) => {
		if (event.value){
			piano.pedalDown(time)
		} else {
			piano.pedalUp(time)
		}
	}, midi.tracks[0].controlChanges[64]).start(0)

	let noteOffEvents = new Part((time, event) => {
		piano.keyUp(event.midi, time, event.velocity)
	}, midi.tracks[0].noteOffs).start(0)

	let noteOnEvents = new Part((time, event) => {
		piano.keyDown(event.midi, time, event.velocity)
	}, midi.tracks[0].notes).start(0)

})
github tambien / Piano / Demo.js View on Github external
Transport.timeSignature = midi.timeSignature

	//schedule the pedal
	let sustain = new Part((time, event) => {
		if (event.value){
			piano.pedalDown(time)
		} else {
			piano.pedalUp(time)
		}
	}, midi.tracks[0].controlChanges[64]).start(0)

	let noteOffEvents = new Part((time, event) => {
		piano.keyUp(event.midi, time, event.velocity)
	}, midi.tracks[0].noteOffs).start(0)

	let noteOnEvents = new Part((time, event) => {
		piano.keyDown(event.midi, time, event.velocity)
	}, midi.tracks[0].notes).start(0)

})
github vibertthio / jazz-rnn / src / jazz-rnn.js View on Github external
data.Bass.Notes,
        data.Bass.BeatResolutions,
        -1
      );
      const bassPart = new Part((time, values) => {
        const { note, duration, vel } = values;
        this.sounds.bassSound.play(note, time, { gain: vel, duration });
      }, bassNotes);
      bassPart.loop = true;
      bassPart.loopEnd = 16;

      const melodyNotes = dataToNotes(
        data.Melody.Notes,
        data.Melody.BeatResolutions
      );
      const melodyPart = new Part((time, values) => {
        const { note, duration, vel } = values;
        this.sounds.melodySound.play(note, time, { gain: vel, duration });
      }, melodyNotes);
      melodyPart.loop = true;
      melodyPart.loopEnd = 16;

      const chordsNotes = dataToNotes(
        data.Chord.Notes,
        data.Chord.BeatResolutions
      );
      const chordsPart = new Part((time, values) => {
        const { note, duration, vel } = values;
        this.sounds.chordsSound.play(note, time, { gain: vel, duration });
      }, chordsNotes);
      chordsPart.loop = true;
      chordsPart.loopEnd = 16;