Writing Wave files
SpessaSynth has a helper function for writing wave files.
audioToWav
Converts PCM audio data into a fully valid wave file.
audioData- anArrayofFloat32Arrays representing the data. For stereo, pass[leftData, rightData].sampleRate-numberthe sample rate, in Hertz.options- an optionalObject, described below:normalizeAudio- optionalboolean- if true, the gain of the entire song will be adjusted, so the max sample is always 32,767 or min is always -32,768 (whichever is greater). Recommended.metadata- optionalObjectdescribed below. All options are string and are optional:title- the song’s titleartist- the song’s artistalbum- the song’s albumgenre- the song’s genre
loop- optionalObjectthat will write loop points to the file (using thecuechunk)start- start time in secondsend- end time in seconds
The metadata uses the INFO chunk to write the information. It is encoded with utf-8
Example code
Refer to examples/midi_to_wav_node.ts for an example of rendering audio data to a wav file.