the code contained in adapter.js



Adapter.js is used to create an audio file header.

  1. I create my variables :
    var monhexa, NbPtTotal = 0;
    var raw = [];
    var raw1 = [];
    var leraw = [];
  2. As the audio format is 2 bytes per position information, I multiply by 2 my number :
    var durerentete = NbPtTotal * 2;
  3. 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;
  4. 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); }
  5. I indicate that there is 44100 position information per second in the generated audio file :
    samples = durerentete*0.0625;
  6. I create my functions to automatically generate the file header, details are in the code.