Skip to content

chdh/wav-file-encoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wav-file-encoder

A simple encoder for WAV audio files.

NPM package: wav-file-encoder
Online demo: www.source-code.biz/snippets/typescript/wavFileEncoder
Example of how to use it: github.com/chdh/wav-file-encoder/tree/master/example
Compagnion package: wav-file-decoder

API

Create a WAV file from an AudioBuffer

encodeWavFileFromAudioBuffer(audioBuffer: AudioBuffer, wavFileType: WavFileType) : ArrayBuffer
  • audioBuffer: An AudioBuffer that contains the audio data.
  • wavFileType: WavFileType.int16 (0) for 16 bit signed integer, WavFileType.float32 (1) for 32 bit float.
  • Return value: An ArrayBuffer that contains the raw data bytes of the generated WAV file.

Create a WAV file from arrays

encodeWavFileFromArrays(channelData: ArrayLike<number>[], sampleRate: number, wavFileType: WavFileType) : ArrayBuffer
  • channelData: Arrays containing the audio samples (PCM data). One array per channel.
  • sampleRate: Sample rate (samples per second).
  • wavFileType: WavFileType.int16 (0) for 16 bit signed integer, WavFileType.float32 (1) for 32 bit float.
  • Return value: An ArrayBuffer that contains the raw data bytes of the generated WAV file.