How to use the tone.Master 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 youphonic / youphonic / src / tone / masterBuss.js View on Github external
attack: 0.3,
	release: 0.6
});

//give a little boost to the lows
const lowBump = new Tone.Filter(210, 'lowshelf');

// a volume fader
// maybe this value passed in here could be retrieved from
// a redux store for values used by Tone
const masterGain = new Tone.Volume(-1);

//route everything through the filter
//and compressor before going to the speakers
export default masterGain.receive('masterBuss')
	.chain(lowBump, masterCompressor, Tone.Master);
github dawg / vusic / src / core / instrument / instrument.ts View on Github external
public id: string;

  /**
   * A type variable. For example, oscillator or soundfont.
   */
  public abstract type: V;

  /**
   * All of the possible options.
   */
  public abstract types: V[];

  public channel?: number;

  protected source: Audio.Source | null;
  private destination: Tone.AudioNode | null = Tone.Master;
  private muted: boolean;
  // tslint:disable-next-line:member-ordering
  private panner = new Tone.Panner().toMaster();
  private connected = true;

  // tslint:disable-next-line:member-ordering
  public pan = new Audio.Signal(this.panner.pan, -1, 1);

  private gainNode = new Tone.Gain().connect(this.panner);

  // tslint:disable-next-line:member-ordering
  public volume = new Audio.Signal(this.gainNode.gain, 0, 1);

  constructor(source: Audio.Source | null, destination: Tone.AudioNode, i: IInstrument) {
    this.source = source;
    if (source) {
github taekyunggg / react_machine / frontend / components / sequencer.jsx View on Github external
this[`sampler${i}`] = new Tone.Sampler(samplePacks.eightZeroEight[i - 1]).toMaster();
      this.state[`s${i}Volume`] = -5;
      this.state[`sampler${i}Solo`] = false;
      this.state[`sampler${i}Disable`] = false;
      this[`sampler${i}`].volume.value = this.state[`s${i}Volume`];
      this[`channelSequence${i}`] = new Tone.Sequence(
        this.triggerSample.bind(this, `sampler${i}`),
        this[`channel${i}`],
        "16n").start(0);
    }

    Tone.Transport.setLoopPoints(0, "1m");
    Tone.Transport.loop = true;
    Tone.Transport.scheduleRepeat(this.positionHighlight, "16n");
    Tone.Transport.bpm.value = this.state.bpm;
    Tone.Master.volume.value = this.state.volume;
  }
github dawg / vusic / src / project.ts View on Github external
let channel = payload.channel;
    if (instrument.channel === channel) {
      return;
    }

    if (channel === undefined) {
      channel = instrument.channel;
    }

    instrument.channel = channel;
    instrument.disconnect();


    let destination: Tone.AudioNode;
    if (channel === undefined) {
      destination = Tone.Master;
    } else {
      const c = this.channels[channel];
      destination = c.effects.length ? c.effects[0].effect : c.destination;
    }

    instrument.connect(destination);
  }
github dawg / vusic / src / project.ts View on Github external
const instruments = (i.instruments || []).map((iInstrument) => {
      let destination: Tone.AudioNode = Tone.Master;
      if (iInstrument.channel !== null && iInstrument.channel !== undefined) {
        if (iInstrument.channel >= channels.length) {
          throw Error(
            `Channel of instrument ${iInstrument.id} (${iInstrument.channel}) ` +
            `exceeds channel count ${channels.length}.`,
          );
        }

        const channel = channels[iInstrument.channel];
        destination = channel.input;
      }

      switch (iInstrument.instrument) {
        case 'soundfont':
          return new Soundfont(Audio.Soundfont.load(iInstrument.soundfont), destination, iInstrument);
        case 'synth':
github abagames / rj-10 / src / sound.ts View on Github external
import { range } from "./util/math";

export const synths = [
  new Tone.Synth(getSynthParams("pulse")).chain(
    new Tone.Volume(-32),
    Tone.Master
  ),
  new Tone.Synth(getSynthParams("square")).chain(
    new Tone.Volume(-32),
    Tone.Master
  ),
  new Tone.Synth(getSynthParams("triangle")).chain(
    new Tone.Volume(-16),
    Tone.Master
  ),
  new Tone.NoiseSynth().chain(new Tone.Volume(-16), Tone.Master)
];
const mmls: string[] = range(4).map(() => undefined);
const parts: Tone.Part[] = range(4).map(() => undefined);
const tempo = 200;
const defaultOctave = 4;
const defaultLength = 32;

Tone.Transport.start();

export function play(synthNumber: number, mml: string) {
  if (mmls[synthNumber] != null && mml.length < mmls[synthNumber].length) {
    return;
  }
  mmls[synthNumber] = mml;
}
github dawg / vusic / src / core / instrument / synth.ts View on Github external
public static create(name: string) {
    return new Synth(Tone.Master, {
      instrument: 'synth',
      type: 'fatsawtooth',
      name,
    });
  }
github dawg / vusic / src / schemas.ts View on Github external
set mute(mute: boolean) {
    this.muted = mute;
    if (mute && this.connected) {
      this.panner.disconnect(Tone.Master);
      this.connected = false;
    } else if (!mute && !this.connected) {
      this.panner.connect(Tone.Master);
      this.connected = true;
    }
  }
}