Adapter.js is used to create an audio file header.
-
I create my variables :
var monhexa, NbPtTotal = 0;
var raw = [];
var raw1 = [];
var leraw = [];
-
As the audio format is 2 bytes per position information, I multiply by 2 my number :
var durerentete = NbPtTotal * 2; -
I add the weight of the header to the weight of the audio file generate, to get the total weight :
var longueurentete = durerentete + 44 - 8; -
I create a function to convert the write of each value to 2 bytes :
var convertisseur = function swap16(val) { return ((val & 0xFF) << 8) | ((val >> 8) & 0xFF); } -
I indicate that there is 44100 position information per second in the generated audio file :
samples = durerentete*0.0625; - I create my functions to automatically generate the file header, details are in the code.