Constructor
new WaveFileCreator(wavBufferopt, nullable, samplesopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
wavBuffer |
Uint8Array |
<optional> <nullable> |
null
|
A wave file buffer. |
samples |
boolean |
<optional> |
true
|
True if the samples should be loaded. |
Throws:
-
-
If container is not RIFF, RIFX or RF64.
- Type
- Error
-
-
-
If format is not WAVE.
- Type
- Error
-
-
-
If no 'fmt ' chunk is found.
- Type
- Error
-
-
-
If no 'data' chunk is found.
- Type
- Error
-
Extends
- WaveFileParser
Members
bitDepth :string
The bit depth code according to the samples.
Type:
- string
(protected) dataType :Object
Type:
- Object
(protected) WAV_AUDIO_FORMATS :number
Properties:
Name | Type | Description |
---|---|---|
4 |
number | |
8 |
number | |
8a |
number | |
8m |
number | |
16 |
number | |
24 |
number | |
32 |
number | |
32f |
number | |
64 |
number |
Audio formats.
Formats not listed here should be set to 65534,
the code for WAVE_FORMAT_EXTENSIBLE
Type:
- number
Methods
fromBuffer(wavBuffernon-null, samplesopt)
Set up the WaveFileCreator object from a byte buffer.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
wavBuffer |
Uint8Array | The buffer. | ||
samples |
boolean |
<optional> |
true
|
True if the samples should be loaded. |
Throws:
-
-
If container is not RIFF, RIFX or RF64.
- Type
- Error
-
-
-
If format is not WAVE.
- Type
- Error
-
-
-
If no 'fmt ' chunk is found.
- Type
- Error
-
-
-
If no 'data' chunk is found.
- Type
- Error
-
fromScratch(numChannels, sampleRate, bitDepthCode, samples, optionsnullable)
Set up the WaveFileCreator object based on the arguments passed.
Existing chunks are reset.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
numChannels |
number | The number of channels (Integer numbers: 1 for mono, 2 stereo and so on). | |
sampleRate |
number | The sample rate. Integer numbers like 8000, 44100, 48000, 96000, 192000. | |
bitDepthCode |
string | The audio bit depth code. One of '4', '8', '8a', '8m', '16', '24', '32', '32f', '64' or any value between '8' and '32' (like '12'). | |
samples |
!Array.<number> | !Array.<!Array.<number>> | TypedArray | The samples. Must be in the correct range according to the bit depth. | |
options |
Object |
<nullable> |
Optional. Used to force the container as RIFX with {'container': 'RIFX'} |
Throws:
-
If any argument does not meet the criteria.
- Type
- Error
toBuffer() → (non-null) {Uint8Array}
Return a byte buffer representig the WaveFileCreator object as a .wav file.
The return value of this method can be written straight to disk.
Throws:
-
-
If bit depth is invalid.
- Type
- Error
-
-
-
If the number of channels is invalid.
- Type
- Error
-
-
-
If the sample rate is invalid.
- Type
- Error
-
Returns:
A wav file.
- Type
- Uint8Array