Skip to content

Commit

Permalink
Add Typescript types for fmt and data chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
rejc2 committed Jan 24, 2023
1 parent 075e220 commit b023873
Showing 1 changed file with 43 additions and 4 deletions.
47 changes: 43 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ declare module wavefile {
* 'RIFF', 'RIFX' and 'RF64' are supported.
* @type {string}
*/
container: string;
container: 'RIFF' | 'RIFX' | 'RF64';
/**
* @type {number}
*/
Expand All @@ -27,12 +27,12 @@ declare module wavefile {
* Always 'WAVE'.
* @type {string}
*/
format: string;
format: 'WAVE';
/**
* The data of the 'fmt' chunk.
* @type {!Object<string, *>}
*/
fmt: object;
fmt: WaveFileFmtChunk;
/**
* The data of the 'fact' chunk.
* @type {!Object<string, *>}
Expand Down Expand Up @@ -78,7 +78,7 @@ declare module wavefile {
* The data of the 'data' chunk.
* @type {!Object<string, *>}
*/
data: object;
data: WaveFileDataChunk;
/**
* The data of the 'LIST' chunks.
* Each item in this list look like this:
Expand Down Expand Up @@ -390,4 +390,43 @@ declare module wavefile {
*/
get_PMX(): string;
}

type WaveFileDataChunk = {
/** @type {string} */
chunkId: 'data';
/** @type {number} */
chunkSize: number;
/** @type {!Uint8Array} */
samples: Uint8Array;
};

type WaveFileFmtChunk = {
/** @type {string} */
chunkId: 'fmt ';
/** @type {number} */
chunkSize: number;
/** @type {number} */
audioFormat: number;
/** @type {number} */
numChannels: number;
/** @type {number} */
sampleRate: number;
/** @type {number} */
byteRate: number;
/** @type {number} */
blockAlign: number;
/** @type {number} */
bitsPerSample: number;
/** @type {number} */
cbSize: number;
/** @type {number} */
validBitsPerSample: number;
/** @type {number} */
dwChannelMask: number;
/**
* 4 32-bit values representing a 128-bit ID
* @type {!Array<number>}
*/
subformat: readonly [number,number,number,number];
};
}

0 comments on commit b023873

Please sign in to comment.