Skip to content

Commit

Permalink
setting minValue for harmonicity
Browse files Browse the repository at this point in the history
  • Loading branch information
tambien committed Dec 15, 2019
1 parent caf58ff commit ed93e67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions Tone/instrument/ModulationSynth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export abstract class ModulationSynth<Options extends ModulationSynthOptions> ex
this.harmonicity = new Multiply({
context: this.context,
value: options.harmonicity,
minValue: 0,
});
this._modulationNode = new Gain({
context: this.context,
Expand Down
13 changes: 10 additions & 3 deletions Tone/signal/Multiply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Gain } from "../core/context/Gain";
import { Param } from "../core/context/Param";
import { optionsFromArguments } from "../core/util/Defaults";
import { Signal, SignalOptions } from "./Signal";
import { InputNode, OutputNode } from "../core/context/ToneAudioNode";

/**
* Multiply two incoming signals. Or, if a number is given in the constructor,
Expand Down Expand Up @@ -36,17 +37,17 @@ export class Multiply<TypeName extends "number" | "positive" = "number"> extends
/**
* the input gain node
*/
private _mult: Gain = new Gain({ context: this.context });
private _mult: Gain;

/**
* The multiplicand input.
*/
input = this._mult;
input: InputNode;

/**
* The product of the input and {@link factor}
*/
output = this._mult;
output: OutputNode;

/**
* The multiplication factor. Can be set directly or a signal can be connected to it.
Expand All @@ -62,6 +63,12 @@ export class Multiply<TypeName extends "number" | "positive" = "number"> extends
super(Object.assign(optionsFromArguments(Multiply.getDefaults(), arguments, ["value"])));
const options = optionsFromArguments(Multiply.getDefaults(), arguments, ["value"]);

this._mult = this.input = this.output = new Gain({
context: this.context,
minValue: options.minValue,
maxValue: options.maxValue,
});

this.factor = this._param = this._mult.gain as unknown as Param<TypeName>;
this.factor.setValueAtTime(options.value, 0);
}
Expand Down

0 comments on commit ed93e67

Please sign in to comment.