Merge pull request #31341 from kirbysayshi/ksh/pseudo-audio-param

Add types for pseudo-audio-param
This commit is contained in:
Sheetal Nandi
2019-01-02 11:34:43 -08:00
committed by GitHub
4 changed files with 82 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
// Type definitions for pseudo-audio-param 1.3
// Project: https://github.com/mohayonao/pseudo-audio-param/
// Definitions by: Drew Petersen <https://github.com/kirbysayshi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
export = PseudoAudioParam;
export as namespace PseudoAudioParam;
interface PseudoAudioParamEvent {
type: string;
time: number;
}
/** Simulate scheduled AudioParam values */
declare class PseudoAudioParam {
events: PseudoAudioParamEvent[];
constructor(defaultValue: number);
/**
* Return scheduled value at time
*/
getValueAtTime(time: number): number;
/**
* Apply scheduled methods to the provided audioParam. If reset is `true`,
* cancel all events of AudioParam before applying
*/
applyTo(audioParam: AudioParam, reset?: boolean): PseudoAudioParam;
setValueAtTime(value: number, time: number): PseudoAudioParam;
linearRampToValueAtTime(value: number, time: number): PseudoAudioParam;
exponentialRampToValueAtTime(value: number, time: number): PseudoAudioParam;
setTargetAtTime(
value: number,
time: number,
timeConstant: number
): PseudoAudioParam;
setValueCurveAtTime(
values: number[],
time: number,
duration: number
): PseudoAudioParam;
cancelScheduledValues(time: number): PseudoAudioParam;
cancelAndHoldAtTime(time: number): PseudoAudioParam;
}
@@ -0,0 +1,9 @@
import PseudoAudioParam = require('pseudo-audio-param');
const p = new PseudoAudioParam(1);
const v: number = p.getValueAtTime(0.1);
const ctx = new AudioContext();
const gain = new GainNode(ctx);
p.applyTo(gain.gain, false);
p.setValueAtTime(0, 1);
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6", "dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"pseudo-audio-param-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}