<commit_before>import { Param } from "../../core/context/Param";
import { ToneAudioNode, ToneAudioNodeOptions } from "../../core/context/ToneAudioNode";
import { AudioRange } from "../../core/type/Units";
import { optionsFromArguments } from "../../core/util/Defaults";
import { readOnly } from "../../core/util/Interface";

interface TonePannerOptions extends ToneAudioNodeOptions {
	pan: AudioRange;
}

/**
 * Panner is an equal power Left/Right Panner. It is a wrapper around the StereoPannerNode.
 * @example
 * import { Oscillator, Panner } from "tone";
 * // pan the input signal hard right.
 * const panner = new Panner(1).toDestination();
 * const osc = new Oscillator().connect(panner).start();
 * @category Component
 */
export class Panner extends ToneAudioNode<TonePannerOptions> {

	readonly name: string = "Panner";

	/**
	 * the panner node
	 */
	private _panner: StereoPannerNode = this.context.createStereoPanner();
	readonly input: StereoPannerNode = this._panner;
	readonly output: StereoPannerNode = this._panner;

	/**
	 * The pan control. -1 = hard left, 1 = hard right.
	 */
	readonly pan: Param<"audioRange">;

	constructor(options?: Partial<TonePannerOptions>);
	/**
	 * @param pan The initial panner value (Defaults to 0 = "center").
	 */
	constructor(pan?: AudioRange);
	constructor() {
		super(Object.assign(optionsFromArguments(Panner.getDefaults(), arguments, ["pan"])));
		const options = optionsFromArguments(Panner.getDefaults(), arguments, ["pan"]);

		this.pan = new Param({
			context: this.context,
			param: this._panner.pan,
			value: options.pan,
		});

		// this is necessary for standardized-audio-context
		// doesn't make any difference for the native AudioContext
		// https://github.com/chrisguttandin/standardized-audio-context/issues/647
		this._panner.channelCount = 1;
		this._panner.channelCountMode = "explicit";

		// initial value
		readOnly(this, "pan");
	}

	static getDefaults(): TonePannerOptions {
		return Object.assign(ToneAudioNode.getDefaults(), {
			pan: 0,
		});
	}

	dispose(): this {
		super.dispose();
		this._panner.disconnect();
		this.pan.dispose();
		return this;
	}
}
<commit_msg>make sure the panner stays in the specific range<commit_after>import { Param } from "../../core/context/Param";
import { ToneAudioNode, ToneAudioNodeOptions } from "../../core/context/ToneAudioNode";
import { AudioRange } from "../../core/type/Units";
import { optionsFromArguments } from "../../core/util/Defaults";
import { readOnly } from "../../core/util/Interface";

interface TonePannerOptions extends ToneAudioNodeOptions {
	pan: AudioRange;
}

/**
 * Panner is an equal power Left/Right Panner. It is a wrapper around the StereoPannerNode.
 * @example
 * import { Oscillator, Panner } from "tone";
 * // pan the input signal hard right.
 * const panner = new Panner(1).toDestination();
 * const osc = new Oscillator().connect(panner).start();
 * @category Component
 */
export class Panner extends ToneAudioNode<TonePannerOptions> {

	readonly name: string = "Panner";

	/**
	 * the panner node
	 */
	private _panner: StereoPannerNode = this.context.createStereoPanner();
	readonly input: StereoPannerNode = this._panner;
	readonly output: StereoPannerNode = this._panner;

	/**
	 * The pan control. -1 = hard left, 1 = hard right.
	 * @min -1
	 * @max 1
	 */
	readonly pan: Param<"audioRange">;

	constructor(options?: Partial<TonePannerOptions>);
	/**
	 * @param pan The initial panner value (Defaults to 0 = "center").
	 */
	constructor(pan?: AudioRange);
	constructor() {
		super(Object.assign(optionsFromArguments(Panner.getDefaults(), arguments, ["pan"])));
		const options = optionsFromArguments(Panner.getDefaults(), arguments, ["pan"]);

		this.pan = new Param({
			context: this.context,
			param: this._panner.pan,
			value: options.pan,
			minValue: -1,
			maxValue: 1,
		});

		// this is necessary for standardized-audio-context
		// doesn't make any difference for the native AudioContext
		// https://github.com/chrisguttandin/standardized-audio-context/issues/647
		this._panner.channelCount = 1;
		this._panner.channelCountMode = "explicit";

		// initial value
		readOnly(this, "pan");
	}

	static getDefaults(): TonePannerOptions {
		return Object.assign(ToneAudioNode.getDefaults(), {
			pan: 0,
		});
	}

	dispose(): this {
		super.dispose();
		this._panner.disconnect();
		this.pan.dispose();
		return this;
	}
}

{'fraction_non_alphanumeric': 0.14509893108937913, 'fraction_numerical': 0.005003411416875142, 'mean_word_length': 3.99205448354143, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6063745', 'n_tokens_mistral': 1478, 'n_tokens_neox': 1363, 'n_words': 350}