title: writing to a wav file using libsndfile
body: <p>I'm having trouble writing a short buffer into a wav file on my HD.
  I followed a few tutorials, but they all give different ways of doing it.
  Anyway, this is the way I implemented it but for some reason it doesn't work. When I try to print out the result of <code>outfile</code>, I get a <code>0</code>, and nothing is written to disk.
  Also, I tried different paths, sometimes with and sometimes without a file name.</p>
  
  <p><strong>UPDATE:</strong> When I change the path to only a file name (e.g. <code>hello.wav</code> and not <code>~/Documents/hello.wav</code>), printing out the <code>outfile</code> returns a memory location such as <code>0x2194000</code>.</p>
  
  <pre><code>void gilbertAnalysis::writeWAV(float * buffer, int bufferSize){
      SF_INFO sfinfo ;
      sfinfo.channels = 1;
      sfinfo.samplerate = 44100;
      sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
  
      const char* path = "~/Documents/hello.wav";
  
      SNDFILE * outfile = sf_open(path, SFM_WRITE, &amp;sfinfo);
      sf_count_t count = sf_write_float(outfile, &amp;buffer[0], bufferSize) ;
      sf_write_sync(outfile);
      sf_close(outfile);
  }
  </code></pre>