externs/wavefile-reader.js   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 274
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 117
mnd 0
bc 0
fnc 2
dl 0
loc 274
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
/*
2
 * Copyright (c) 2019 Rafael da Silva Rocha.
3
 *
4
 * Permission is hereby granted, free of charge, to any person obtaining
5
 * a copy of this software and associated documentation files (the
6
 * "Software"), to deal in the Software without restriction, including
7
 * without limitation the rights to use, copy, modify, merge, publish,
8
 * distribute, sublicense, and/or sell copies of the Software, and to
9
 * permit persons to whom the Software is furnished to do so, subject to
10
 * the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be
13
 * included in all copies or substantial portions of the Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
 *
23
 */
24
25
/**
26
 * @fileoverview Externs for wavefile-reader 1.0
27
 * @see https://github.com/rochars/wavefile-reader
28
 * @externs
29
 */
30
31
// wavefile-reader module
32
var wavefileReader = {};
33
34
// WaveFileReader class
35
var WaveFileReader = {};
36
37
/**
38
 * The container identifier.
39
 * RIFF, RIFX and RF64 are supported.
40
 * @type {string}
41
 */
42
WaveFileReader.prototype.container = '';
43
/**
44
 * @type {number}
45
 */
46
WaveFileReader.prototype.chunkSize = 0;
47
/**
48
 * The format.
49
 * Always WAVE.
50
 * @type {string}
51
 */
52
WaveFileReader.prototype.format = '';
53
/**
54
 * The data of the fmt chunk.
55
 * @type {!Object<string, *>}
56
 */
57
WaveFileReader.prototype.fmt = {
58
  /** @type {string} */
59
  chunkId: '',
60
  /** @type {number} */
61
  chunkSize: 0,
62
  /** @type {number} */
63
  audioFormat: 0,
64
  /** @type {number} */
65
  numChannels: 0,
66
  /** @type {number} */
67
  sampleRate: 0,
68
  /** @type {number} */
69
  byteRate: 0,
70
  /** @type {number} */
71
  blockAlign: 0,
72
  /** @type {number} */
73
  bitsPerSample: 0,
74
  /** @type {number} */
75
  cbSize: 0,
76
  /** @type {number} */
77
  validBitsPerSample: 0,
78
  /** @type {number} */
79
  dwChannelMask: 0,
80
  /**
81
   * 4 32-bit values representing a 128-bit ID
82
   * @type {!Array<number>}
83
   */
84
  subformat: []
85
};
86
/**
87
 * The data of the fact chunk.
88
 * @type {!Object<string, *>}
89
 */
90
WaveFileReader.prototype.fact = {
91
  /** @type {string} */
92
  chunkId: '',
93
  /** @type {number} */
94
  chunkSize: 0,
95
  /** @type {number} */
96
  dwSampleLength: 0
97
};
98
/**
99
 * The data of the cue  chunk.
100
 * @type {!Object<string, *>}
101
 */
102
WaveFileReader.prototype.cue = {
103
  /** @type {string} */
104
  chunkId: '',
105
  /** @type {number} */
106
  chunkSize: 0,
107
  /** @type {number} */
108
  dwCuePoints: 0,
109
  /** @type {!Array<!Object>} */
110
  points: [{
111
    dwName: 0, // a cue point ID
112
    dwPosition: 0,
113
    fccChunk: 0,
114
    dwChunkStart: 0,
115
    dwBlockStart: 0,
116
    dwSampleOffset: 0,
117
    milliseconds: 0
118
  }],
119
};
120
/**
121
 * The data of the smpl chunk.
122
 * @type {!Object<string, *>}
123
 */
124
WaveFileReader.prototype.smpl = {
125
  /** @type {string} */
126
  chunkId: '',
127
  /** @type {number} */
128
  chunkSize: 0,
129
  /** @type {number} */
130
  dwManufacturer: 0,
131
  /** @type {number} */
132
  dwProduct: 0,
133
  /** @type {number} */
134
  dwSamplePeriod: 0,
135
  /** @type {number} */
136
  dwMIDIUnityNote: 0,
137
  /** @type {number} */
138
  dwMIDIPitchFraction: 0,
139
  /** @type {number} */
140
  dwSMPTEFormat: 0,
141
  /** @type {number} */
142
  dwSMPTEOffset: 0,
143
  /** @type {number} */
144
  dwNumSampleLoops: 0,
145
  /** @type {number} */
146
  dwSamplerData: 0,
147
  /** @type {!Array<!Object>} */
148
  loops: [
149
    {
150
      dwName: '', // a cue point ID
151
      dwType: 0,
152
      dwStart: 0,
153
      dwEnd: 0,
154
      dwFraction: 0,
155
      dwPlayCount: 0
156
    }
157
  ],
158
};
159
/**
160
 * The data of the bext chunk.
161
 * @type {!Object<string, *>}
162
 */
163
WaveFileReader.prototype.bext = {
164
  /** @type {string} */
165
  chunkId: '',
166
  /** @type {number} */
167
  chunkSize: 0,
168
  /** @type {string} */
169
  description: '',
170
  /** @type {string} */
171
  originator: '',
172
  /** @type {string} */
173
  originatorReference: '',
174
  /** @type {string} */
175
  originationDate: '',
176
  /** @type {string} */
177
  originationTime: '',
178
  /**
179
   * 2 32-bit values, timeReference high and low
180
   * @type {!Array<number>}
181
   */
182
  timeReference: [0, 0],
183
  /** @type {number} */
184
  version: 0,
185
  /** @type {string} */
186
  UMID: '',
187
  /** @type {number} */
188
  loudnessValue: 0,
189
  /** @type {number} */
190
  loudnessRange: 0,
191
  /** @type {number} */
192
  maxTruePeakLevel: 0,
193
  /** @type {number} */
194
  maxMomentaryLoudness: 0,
195
  /** @type {number} */
196
  maxShortTermLoudness: 0,
197
  /** @type {string} */
198
  reserved: '',
199
  /** @type {string} */
200
  codingHistory: ''
201
};
202
/**
203
 * The data of the ds64 chunk.
204
 * Used only with RF64 files.
205
 * @type {!Object<string, *>}
206
 */
207
WaveFileReader.prototype.ds64 = {
208
  /** @type {string} */
209
  chunkId: '',
210
  /** @type {number} */
211
  chunkSize: 0,
212
  /** @type {number} */
213
  riffSizeHigh: 0,
214
  /** @type {number} */
215
  riffSizeLow: 0,
216
  /** @type {number} */
217
  dataSizeHigh: 0,
218
  /** @type {number} */
219
  dataSizeLow: 0,
220
  /** @type {number} */
221
  originationTime: 0,
222
  /** @type {number} */
223
  sampleCountHigh: 0,
224
  /** @type {number} */
225
  sampleCountLow: 0
226
};
227
/**
228
 * The data of the data chunk.
229
 * @type {!Object<string, *>}
230
 */
231
WaveFileReader.prototype.data = {
232
  /** @type {string} */
233
  chunkId: '',
234
  /** @type {number} */
235
  chunkSize: 0,
236
  /** @type {!Uint8Array} */
237
  samples: null //
238
};
239
/**
240
 * The data of the LIST chunks.
241
 * @type {!Array<!Object>}
242
 */
243
WaveFileReader.prototype.LIST = [
244
  {
245
    chunkId: '',
246
    chunkSize: 0,
247
    format: '',
248
    subChunks: [
249
      // For format 'INFO'
250
      {
251
        chunkId: '',
252
        chunkSize: 0,
253
        value: ''
254
      },
255
      // For format 'adtl' types 'labl' or 'note'
256
      {
257
        chunkId: '',
258
        chunkSize: 0,
259
        dwName: 0,
260
        value: ''
261
      },
262
      // For format 'adtl' type 'ltxt'
263
      {
264
        chunkId: '',
265
        value: 0,
266
        dwName: 0,
267
        dwSampleLength: 0,
268
        dwPurposeID: 0,
269
        dwCountry: 0,
270
        dwLanguage: 0,
271
        dwDialect: 0,
272
        dwCodePage: 0
273
      }
274
    ]
275
  }
276
];
277
/**
278
 * The data of the junk chunk.
279
 * @type {!Object<string, *>}
280
 */
281
WaveFileReader.prototype.junk = {
282
  /** @type {string} */
283
  chunkId: '',
284
  /** @type {number} */
285
  chunkSize: 0,
286
  /** @type {!Array<number>} */
287
  chunkData: []
288
};
289
290
/**
291
 * Set up the WaveFile object from a byte buffer.
292
 * @param {!Uint8Array} bytes The buffer.
293
 * @param {boolean=} samples True if the samples should be loaded.
294
 * @throws {Error} If container is not RIFF, RIFX or RF64.
295
 * @throws {Error} If no fmt  chunk is found.
296
 * @throws {Error} If no data chunk is found.
297
 */
298
WaveFileReader.prototype.fromBuffer = function(bytes, samples=true) {};
299
300
/**
301
 * Reset the chunks of the WaveFileReader instance.
302
 * @protected
303
 * @ignore
304
 */
305
WaveFileReader.prototype.clearHeaders = function() {};
306