Passed
Push — master ( 533996...4cb80e )
by Rafael S.
02:03
created

T_CONST   A

Complexity

Total Complexity 22
Complexity/F 1

Size

Lines of Code 1
Function Count 22

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
dl 0
loc 1
rs 10
wmc 22
mnd 0
bc 22
fnc 22
bpm 1
cpm 1
noi 9
1
/**
2
 * @fileoverview Externs for wavefile 8.0
3
 *
4
 * @see https://github.com/rochars/wavefile
5
 * @externs
6
 */
7
8
// WaveFile class
9
const WaveFile = {};
10
11
/**
12
 * The container identifier.
13
 * RIFF, RIFX and RF64 are supported.
14
 * @type {string}
15
 */
16
WaveFile.container = '';
17
/**
18
 * @type {number}
19
 */
20
WaveFile.chunkSize = 0;
21
/**
22
 * The format.
23
 * Always WAVE.
24
 * @type {string}
25
 */
26
WaveFile.format = '';
27
/**
28
 * The data of the fmt chunk.
29
 * @type {!Object<string, *>}
30
 */
31
WaveFile.fmt = {
32
    /** @type {string} */
33
    chunkId: '',
34
    /** @type {number} */
35
    chunkSize: 0,
36
    /** @type {number} */
37
    audioFormat: 0,
38
    /** @type {number} */
39
    numChannels: 0,
40
    /** @type {number} */
41
    sampleRate: 0,
42
    /** @type {number} */
43
    byteRate: 0,
44
    /** @type {number} */
45
    blockAlign: 0,
46
    /** @type {number} */
47
    bitsPerSample: 0,
48
    /** @type {number} */
49
    cbSize: 0,
50
    /** @type {number} */
51
    validBitsPerSample: 0,
52
    /** @type {number} */
53
    dwChannelMask: 0,
54
    /**
55
     * 4 32-bit values representing a 128-bit ID
56
     * @type {!Array<number>}
57
     */
58
    subformat: []
59
};
60
/**
61
 * The data of the fact chunk.
62
 * @type {!Object<string, *>}
63
 */
64
WaveFile.fact = {
65
    /** @type {string} */
66
    chunkId: '',
67
    /** @type {number} */
68
    chunkSize: 0,
69
    /** @type {number} */
70
    dwSampleLength: 0
71
};
72
/**
73
 * The data of the cue  chunk.
74
 * @type {!Object<string, *>}
75
 */
76
WaveFile.cue = {
77
    /** @type {string} */
78
    chunkId: '',
79
    /** @type {number} */
80
    chunkSize: 0,
81
    /** @type {number} */
82
    dwCuePoints: 0,
83
    /** @type {!Array<!Object>} */
84
    points: [],
85
};
86
/**
87
 * The data of the smpl chunk.
88
 * @type {!Object<string, *>}
89
 */
90
WaveFile.smpl = {
91
    /** @type {string} */
92
    chunkId: '',
93
    /** @type {number} */
94
    chunkSize: 0,
95
    /** @type {number} */
96
    dwManufacturer: 0,
97
    /** @type {number} */
98
    dwProduct: 0,
99
    /** @type {number} */
100
    dwSamplePeriod: 0,
101
    /** @type {number} */
102
    dwMIDIUnityNote: 0,
103
    /** @type {number} */
104
    dwMIDIPitchFraction: 0,
105
    /** @type {number} */
106
    dwSMPTEFormat: 0,
107
    /** @type {number} */
108
    dwSMPTEOffset: 0,
109
    /** @type {number} */
110
    dwNumSampleLoops: 0,
111
    /** @type {number} */
112
    dwSamplerData: 0,
113
    /** @type {!Array<!Object>} */
114
    loops: [],
115
};
116
/**
117
 * The data of the bext chunk.
118
 * @type {!Object<string, *>}
119
 */
120
WaveFile.bext = {
121
    /** @type {string} */
122
    chunkId: '',
123
    /** @type {number} */
124
    chunkSize: 0,
125
    /** @type {string} */
126
    description: '',
127
    /** @type {string} */
128
    originator: '',
129
    /** @type {string} */
130
    originatorReference: '',
131
    /** @type {string} */
132
    originationDate: '',
133
    /** @type {string} */
134
    originationTime: '',
135
    /**
136
     * 2 32-bit values, timeReference high and low
137
     * @type {!Array<number>}
138
     */
139
    timeReference: [0, 0],
140
    /** @type {number} */
141
    version: 0,
142
    /** @type {string} */
143
    UMID: '',
144
    /** @type {number} */
145
    loudnessValue: 0,
146
    /** @type {number} */
147
    loudnessRange: 0,
148
    /** @type {number} */
149
    maxTruePeakLevel: 0,
150
    /** @type {number} */
151
    maxMomentaryLoudness: 0,
152
    /** @type {number} */
153
    maxShortTermLoudness: 0,
154
    /** @type {string} */
155
    reserved: '',
156
    /** @type {string} */
157
    codingHistory: ''
158
};
159
/**
160
 * The data of the ds64 chunk.
161
 * Used only with RF64 files.
162
 * @type {!Object<string, *>}
163
 */
164
WaveFile.ds64 = {
165
    /** @type {string} */
166
    chunkId: '',
167
    /** @type {number} */
168
    chunkSize: 0,
169
    /** @type {number} */
170
    riffSizeHigh: 0,
171
    /** @type {number} */
172
    riffSizeLow: 0,
173
    /** @type {number} */
174
    dataSizeHigh: 0,
175
    /** @type {number} */
176
    dataSizeLow: 0,
177
    /** @type {number} */
178
    originationTime: 0,
179
    /** @type {number} */
180
    sampleCountHigh: 0,
181
    /** @type {number} */
182
    sampleCountLow: 0,
183
};
184
/**
185
 * The data of the data chunk.
186
 * @type {!Object<string, *>}
187
 */
188
WaveFile.data = {
189
    /** @type {string} */
190
    chunkId: '',
191
    /** @type {number} */
192
    chunkSize: 0,
193
    /** @type {!Array<number>} */
194
    samples: []
195
};
196
/**
197
 * The data of the LIST chunks.
198
 * Each item in this list look like this:
199
 *  {
200
 *      chunkId: '',
201
 *      chunkSize: 0,
202
 *      format: '',
203
 *      subChunks: []
204
 *   }
205
 * @type {!Array<!Object>}
206
 */
207
WaveFile.LIST = [];
208
/**
209
 * The data of the junk chunk.
210
 * @type {!Object<string, *>}
211
 */
212
WaveFile.junk = {
213
    /** @type {string} */
214
    chunkId: '',
215
    /** @type {number} */
216
    chunkSize: 0,
217
    /** @type {!Array<number>} */
218
    chunkData: []
219
};
220
/**
221
 * The bit depth code according to the samples.
222
 * @type {string}
223
 */
224
WaveFile.bitDepth = '';
225
226
/**
227
 * Set up the WaveFile object based on the arguments passed.
228
 * @param {number} numChannels The number of channels
229
 *      (Integer numbers: 1 for mono, 2 stereo and so on).
230
 * @param {number} sampleRate The sample rate.
231
 *      Integer numbers like 8000, 44100, 48000, 96000, 192000.
232
 * @param {string} bitDepth The audio bit depth code.
233
 *      One of 4, 8, 8a, 8m, 16, 24, 32, 32f, 64
234
 *      or any value between 8 and 32 (like 12).
235
 * @param {!Array<number>} samples Array of samples to be written.
236
 *      The samples must be in the correct range according to the
237
 *      bit depth.
238
 * @param {?Object} options Optional. Used to force the container
239
 *      as RIFX with {container: RIFX}
240
 * @throws {Error} If any argument does not meet the criteria.
241
 */
242
WaveFile.fromScratch = function(
243
    numChannels, sampleRate, bitDepth, samples, options={}) {}
244
245
/**
246
 * Set up the WaveFile object from a byte buffer.
247
 * @param {!Uint8Array} bytes The buffer.
248
 * @param {boolean=} samples True if the samples should be loaded.
249
 * @throws {Error} If container is not RIFF, RIFX or RF64.
250
 * @throws {Error} If no fmt  chunk is found.
251
 * @throws {Error} If no data chunk is found.
252
 */
253
WaveFile.fromBuffer = function(bytes, samples=true) {}
254
255
/**
256
 * Return a byte buffer representig the WaveFile object as a .wav file.
257
 * The return value of this method can be written straight to disk.
258
 * @return {!Uint8Array} A .wav file.
259
 * @throws {Error} If any property of the object appears invalid.
260
 */
261
WaveFile.toBuffer = function() {}
262
263
/**
264
 * Use a .wav file encoded as a base64 string to load the WaveFile object.
265
 * @param {string} base64String A .wav file as a base64 string.
266
 * @throws {Error} If any property of the object appears invalid.
267
 */
268
WaveFile.fromBase64 = function(base64String) {}
0 ignored issues
show
Unused Code introduced by
The parameter base64String is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
269
270
/**
271
 * Return a base64 string representig the WaveFile object as a .wav file.
272
 * @return {string} A .wav file as a base64 string.
273
 * @throws {Error} If any property of the object appears invalid.
274
 */
275
WaveFile.toBase64 = function() {}
276
277
/**
278
 * Return a DataURI string representig the WaveFile object as a .wav file.
279
 * The return of this method can be used to load the audio in browsers.
280
 * @return {string} A .wav file as a DataURI.
281
 * @throws {Error} If any property of the object appears invalid.
282
 */
283
WaveFile.toDataURI = function() {}
284
285
/**
286
 * Use a .wav file encoded as a DataURI to load the WaveFile object.
287
 * @param {string} dataURI A .wav file as DataURI.
288
 * @throws {Error} If any property of the object appears invalid.
289
 */
290
WaveFile.fromDataURI = function(dataURI) {}
0 ignored issues
show
Unused Code introduced by
The parameter dataURI is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
291
292
/**
293
 * Force a file as RIFF.
294
 */
295
WaveFile.toRIFF = function() {}
296
297
/**
298
 * Force a file as RIFX.
299
 */
300
WaveFile.toRIFX = function() {}
301
302
/**
303
 * Change the bit depth of the samples.
304
 * @param {string} bitDepth The new bit depth of the samples.
305
 *      One of 8 ... 32 (integers), 32f or 64 (floats)
306
 * @param {boolean} changeResolution A boolean indicating if the
307
 *      resolution of samples should be actually changed or not.
308
 * @throws {Error} If the bit depth is not valid.
309
 */
310
WaveFile.toBitDepth = function(bitDepth, changeResolution=true) {}
311
312
/**
313
 * Encode a 16-bit wave file as 4-bit IMA ADPCM.
314
 * @throws {Error} If sample rate is not 8000.
315
 * @throws {Error} If number of channels is not 1.
316
 */
317
WaveFile.toIMAADPCM = function() {}
318
319
/**
320
 * Decode a 4-bit IMA ADPCM wave file as a 16-bit wave file.
321
 * @param {string} bitDepth The new bit depth of the samples.
322
 *      One of 8 ... 32 (integers), 32f or 64 (floats).
323
 *      Optional. Default is 16.
324
 */
325
WaveFile.fromIMAADPCM = function(bitDepth='16') {}
326
327
/**
328
 * Encode 16-bit wave file as 8-bit A-Law.
329
 */
330
WaveFile.toALaw = function() {}
331
332
/**
333
 * Decode a 8-bit A-Law wave file into a 16-bit wave file.
334
 * @param {string} bitDepth The new bit depth of the samples.
335
 *      One of 8 ... 32 (integers), 32f or 64 (floats).
336
 *      Optional. Default is 16.
337
 */
338
WaveFile.fromALaw = function(bitDepth='16') {}
339
340
/**
341
 * Encode 16-bit wave file as 8-bit mu-Law.
342
 */
343
WaveFile.toMuLaw = function() {}
344
345
/**
346
 * Decode a 8-bit mu-Law wave file into a 16-bit wave file.
347
 * @param {string} bitDepth The new bit depth of the samples.
348
 *      One of 8 ... 32 (integers), 32f or 64 (floats).
349
 *      Optional. Default is 16.
350
 */
351
WaveFile.fromMuLaw = function(bitDepth='16') {}
352
353
/**
354
 * Write a RIFF tag in the INFO chunk. If the tag do not exist,
355
 * then it is created. It if exists, it is overwritten.
356
 * @param {string} tag The tag name.
357
 * @param {string} value The tag value.
358
 * @throws {Error} If the tag name is not valid.
359
 */
360
WaveFile.setTag = function(tag, value) {}
0 ignored issues
show
Unused Code introduced by
The parameter tag is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter value is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
361
362
/**
363
 * Return the value of a RIFF tag in the INFO chunk.
364
 * @param {string} tag The tag name.
365
 * @return {?string} The value if the tag is found, null otherwise.
366
 */
367
WaveFile.getTag = function(tag) {}
0 ignored issues
show
Unused Code introduced by
The parameter tag is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
368
369
/**
370
 * Remove a RIFF tag in the INFO chunk.
371
 * @param {string} tag The tag name.
372
 * @return {boolean} True if a tag was deleted.
373
 */
374
WaveFile.deleteTag = function(tag) {}
0 ignored issues
show
Unused Code introduced by
The parameter tag is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
375
376
/**
377
 * Create a cue point in the wave file.
378
 * @param {number} position The cue point position in milliseconds.
379
 * @param {string} labl The LIST adtl labl text of the marker. Optional.
380
 */
381
WaveFile.setCuePoint = function(position, labl='') {}
382
383
/**
384
 * Remove a cue point from a wave file.
385
 * @param {number} index the index of the point. First is 1,
386
 *      second is 2, and so on.
387
 */
388
WaveFile.deleteCuePoint = function(index) {}
0 ignored issues
show
Unused Code introduced by
The parameter index is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
389
390
/**
391
 * Update the label of a cue point.
392
 * @param {number} pointIndex The ID of the cue point.
393
 * @param {string} label The new text for the label.
394
 */
395
WaveFile.updateLabel = function(pointIndex, label) {}
0 ignored issues
show
Unused Code introduced by
The parameter label is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter pointIndex is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
396