Tone.js/Tone/component/analysis/DCMeter.ts

39 lines
1,014 B
TypeScript
Raw Normal View History

import { optionsFromArguments } from "../../core/util/Defaults";
import { MeterBase, MeterBaseOptions } from "./MeterBase";
export type DCMeterOptions = MeterBaseOptions;
/**
* DCMeter gets the raw value of the input signal at the current time.
*
* @example
2019-10-23 03:04:52 +00:00
* const meter = new DCMeter();
* const signal = new UserMedia().open();
* // connect signal to the meter
* signal.connect(meter);
2019-10-23 03:04:52 +00:00
* // the current level of the signal
* const level = meter.getValue();
2019-09-16 14:15:23 +00:00
* @category Component
*/
export class DCMeter extends MeterBase<DCMeterOptions> {
readonly name: string = "DCMeter";
constructor(options?: Partial<DCMeterOptions>);
constructor() {
super(optionsFromArguments(DCMeter.getDefaults(), arguments));
const options = optionsFromArguments(DCMeter.getDefaults(), arguments);
this._analyser.type = "waveform";
this._analyser.size = 256;
}
/**
2019-09-14 20:39:18 +00:00
* Get the signal value of the incoming signal
*/
getValue(): number {
const value = this._analyser.getValue();
return value[0];
}
}