How to use the tone.Gain 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 dawg / vusic / src / schemas.ts View on Github external
export class Channel {
  public static create(num: number) {
    const channel = new Channel();
    channel.number = num;
    channel.name = `Channel ${num}`;
    return channel;
  }

  @autoserialize public number!: number;
  @autoserialize public name!: string;
  @autoserializeAs(Effect) public effects: AnyEffect[] = [];
  public left = new Tone.Meter();
  public right = new Tone.Meter();
  public split = new Tone.Split();
  private panner = new Tone.Panner().toMaster().connect(this.split);
  private gain = new Tone.Gain().connect(this.panner);
  // tslint:disable-next-line:member-ordering
  public destination = this.gain;
  private connected = true;
  private muted = false;

  constructor() {
    this.split.left.connect(this.left);
    this.split.right.connect(this.right);
  }

  @autoserialize
  get pan() {
    return this.panner.pan.value;
  }
  set pan(pan: number) {
    this.panner.pan.value = pan;
github dawg / vusic / src / core / channel.ts View on Github external
public effects: AnyEffect[];
  public id: string;

  public left = new Tone.Meter();
  public right = new Tone.Meter();
  public split = new Tone.Split();

  private pannerNode = new Tone.Panner().toMaster().connect(this.split);

  /**
   * The panner for the channel.
   */
  // tslint:disable-next-line:member-ordering
  public panner = new Audio.Signal(this.pannerNode.pan, -1, 1);

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

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

  // tslint:disable-next-line:member-ordering
  public destination = this.gainNode;
  private connected = true;
  private muted: boolean;

  constructor(i: IChannel) {
    this.number = i.number;
    this.name = i.name;
    this.id = i.id;
github LLK / scratch-audio / src / vocoder.js View on Github external
// create a post-filtering gain to bump the levels up.
        var modulatorFilterPostGain = new Tone.Gain(6);
        modulatorFilter.connect(modulatorFilterPostGain);

        // add a rectifier with a lowpass filter to turn the bandpass filtered signal
        // into a smoothed control signal for the carrier filter
        var rectifier = new Tone.WaveShaper([1,0,1]);
        modulatorFilterPostGain.connect(rectifier);
        var rectifierLowPass = new Tone.Filter(50, 'lowpass');
        rectifier.connect(rectifierLowPass);

        // Create the bandpass filter in the carrier chain
        var carrierFilter = new Tone.Filter(this.vocoderBands[i].frequency, 'bandpass', -24);
        carrierFilter.Q.value = FILTER_QUALITY;
        this.carrierInput.connect(carrierFilter);
        var carrierFilterPostGain = new Tone.Gain(10);
        carrierFilter.connect(carrierFilterPostGain);

        // Create the carrier band gain node
        var bandGain = new Tone.Gain(0);
        carrierFilterPostGain.connect(bandGain);

        // the modulator band filter output controls the gain of the carrier band
        rectifierLowPass.connect(bandGain.gain);

        bandGain.connect(this.outputGain);
    }
};
github LLK / scratch-audio / src / vocoder.js View on Github external
// Set up a high-pass filter to add back in the fricatives, etc.
    var hpFilter = new Tone.Filter(8000, 'highpass');
    this.modulatorInput.connect(hpFilter);
    hpFilter.connect(this.outputGain);

    for (var i=0; i
github vibertthio / jazz-rnn / src / jazz-rnn.js View on Github external
const melodySound = await Soundfont.instrument(
        ac,
        "acoustic_grand_piano",
        {
          soundfont: "MusyngKite",
          destination: melodyEQ,
          adsr: [0.02, 0.3, 0.9, 1.5]
        }
      );

      melodyEQ.chain(melodyGain, sendReverb, sendReverbGain, Master);
      melodyEQ.chain(melodyGain, Master);
      console.log("Melody sounds loaded!");

      const chordsEQ = new Tone.EQ3(-10, -2, -5);
      const chordsGain = new Tone.Gain(1.0);
      const chordsSound = await Soundfont.instrument(ac, "electric_piano_1", {
        soundfont: "MusyngKite",
        destination: chordsEQ
      });

      chordsEQ.chain(chordsGain, sendReverb, sendReverbGain, Master);
      chordsEQ.chain(chordsGain, Master);
      console.log("Chords sounds loaded!");

      const bassEQ = new Tone.EQ3(0, 0, 0);
      const bassGain = new Tone.Gain(0.4);
      const bassSound = await Soundfont.instrument(ac, "acoustic_bass", {
        soundfont: "MusyngKite",
        destination: bassEQ
      });
github ejarzo / Shape-Your-Music / src / components / Shape / Container.jsx View on Github external
this.synth = new synthObj.baseSynth(synthObj.params);
    this.synth.volume.exponentialRampToValueAtTime(
      this.props.volume,
      Tone.now() + 0.2
    );

    knobVals.forEach((val, i) => {
      if (synthObj.dynamicParams[i].target === 'instrument') {
        synthObj.dynamicParams[i].func(this, val);
      }
    });

    this.panner = new Tone.Panner(0);
    this.solo = new Tone.Solo();
    this.gain = new Tone.Gain().send(
      `${SEND_CHANNELS.FX_PREFIX}${colorIndex}`,
      0
    );

    this.synth.chain(this.panner, this.solo, this.gain);
  }
github LLK / scratch-audio / src / vocoder.js View on Github external
function Vocoder () {
    Tone.Effect.call(this);

    this.modulatorInput = new Tone.Gain();
    this.carrierInput = new Tone.Gain();
    this.outputGain = new Tone.Gain();

    this.oscillatorNode;

    this.vocoderBands = this.generateVocoderBands(55, 7040, 8);
    this.initBandpassFilters();
    this.createCarrier();

    this.effectSend.connect(this.modulatorInput);
    this.outputGain.connect(this.effectReturn);
}
github LLK / scratch-audio / src / vocoder.js View on Github external
function Vocoder () {
    Tone.Effect.call(this);

    this.modulatorInput = new Tone.Gain();
    this.carrierInput = new Tone.Gain();
    this.outputGain = new Tone.Gain();

    this.oscillatorNode;

    this.vocoderBands = this.generateVocoderBands(55, 7040, 8);
    this.initBandpassFilters();
    this.createCarrier();

    this.effectSend.connect(this.modulatorInput);
    this.outputGain.connect(this.effectReturn);
}
github ejarzo / Shape-Your-Music / src / components / ColorControllerPanel / ColorController / Container.jsx View on Github external
constructor(props) {
    super(props);
    const { synthType, receiveChannel } = props;
    const { effects } = SYNTH_PRESETS[synthType];

    this.fxList = [];
    this.fxBus = new Tone.Gain(0.8);
    this.fxBus.receive(receiveChannel);

    this.output = new Tone.Gain(1);
    this.output.send(SEND_CHANNELS.MASTER_OUTPUT, 0);
    this.connectEffects(effects);

    this.disposeEffects = this.disposeEffects.bind(this);

    this.handleInstChange = this.handleInstChange.bind(this);
    this.handleIncrementClick = this.handleIncrementClick.bind(this);
  }