mirror of
https://github.com/nippur72/apple1-videocard-lib.git
synced 2024-11-15 17:05:33 +00:00
16 lines
444 B
JavaScript
16 lines
444 B
JavaScript
const WavEncoder = require("wav-encoder");
|
|
|
|
// turns the samples into an actual WAV file
|
|
// returns the array of bytes to be written to file
|
|
|
|
function samples2wav(samples, samplerate) {
|
|
const wavData = {
|
|
sampleRate: samplerate,
|
|
channelData: [ new Float32Array(samples) ]
|
|
};
|
|
const buffer = WavEncoder.encode.sync(wavData, { bitDepth: 16, float: false });
|
|
return Buffer.from(buffer)
|
|
}
|
|
|
|
module.exports = { samples2wav };
|