title: create wav file without running out of ram
body: <p>Hi i am trying to record from a board and i have successfully record 4 seconds.
  Problem is when i try to record for more time, i got an error telling me that there not enough memory. my target is to record a 5 minutes file.
  Until now i have create a buffer named snIn[256] where are the samples.
  i send it to a big buffer of [16K * 4sec] and when it is full, i create the wav file.</p>
  
  <pre><code>#define WAVFILE_SAMPLES_PER_SECOND 16000
  #define REC_TIME 4
  
  const int NUM_SAMPLES = WAVFILE_SAMPLES_PER_SECOND * REC_TIME;
  Array&lt;int16_t&gt; my_buffer(NUM_SAMPLES);
  
  int rec(const char *filename, Array&lt;int16_t&gt; my_buffer) {   
  
      WavFileResult result;
      wavfile_info_t info;
      wavfile_data_t data;
  
      // code for filling the info of the wav file: sample rate, byte rate , channels etc..
  
      WAVFILE *wf = wavfile_open(filename, WavFileModeWrite, &amp;result);
      WAVFILE_DATA_NUM_CHANNELS(&amp;data) = 1; rp = 0;
      wavfile_write_info(wf, &amp;info);
  
  
      while ( rp &lt; NUM_SAMPLES ) {
          WAVFILE_DATA_CHANNEL_DATA(&amp;data, 0) = my_buffer[rp];//fill the data of the wav file       
          wavfile_write_data(wf, &amp;data);
          rp += 1;
      }
      wavfile_close(wf);
      return 0;
  }
  
  void fill_buffer (Array&lt;int16_t&gt; snIn , int &amp;j) {
  
          for (int i=0 ; i &lt; SEG_SIZE ; i++) {
              my_buffer[j] = snIn[i]; //puts all the 256 values in my_buffer
              j++; }
  
              if (sent_array == ((int)NUM_SAMPLES/SEG_SIZE)){ // if my_buffer is full, go to rec and make a wav file
                  rec (target_filename , my_buffer ); }
  }
  
  int main()
  {
          Array&lt;int16_t&gt; snIn(256);
  
              for (int n=0; n&lt;256 ; n++)
              { //snIn gets new 256 values }
          sent_array ++;
          fill_buffer (snIn , j);
  }
  </code></pre>
  
  <p>I thought about a possible solution, to fill directly the "data field" of the wavefile with the snIn[256] buffer (instead of using my_buffer) again and again and at the end close the wavfile.
  Please let me know what you think about that and other solutions.</p>