title: Performing piped operations on individual chunks (node-wav)
body: <p>I'm new to node and I'm working on an audio stream server. I'm trying to process / transform the chunks of a stream as they come out of each pipe. </p>
  
  <p>So, <code>file = fs.createReadStream(path)</code> <em>(filestream)</em> is piped into <code>file.pipe(wavy)</code> <em>(remove headers and output raw PCM)</em> gets piped in to <code>.pipe(waver)</code> <em>(add proper wav header to chunk)</em> which is piped into <code>.pipe(spark)</code> <em>(ouput chunk to client)</em>.</p>
  
  <p>The idea is that each filestream chunk has headers removed if any (only applies to first chunk), then using the node-wav Writer that chunk is endowed with headers and then sent to the client. As I'm sure you guessed this doesn't work. </p>
  
  <p>The pipe operations into node-wav are acting on the entire filestream, not the individual chunks. To confirm I've checked the output client side and it is effectively dropping the headers and re-adding them to the entire data stream.</p>
  
  <p>From what I've read of the Node Stream docs it seems like what I'm trying to do should be possible, just not the way I'm doing it. I just can't pin down how to accomplish this.</p>
  
  <p>Is it possible, and if so what am I missing?</p>
  
  <p>Complete function:</p>
  
  <pre><code>processAudio = (path, spark) -&gt;
    wavy = new wav.Reader()
    waver = new wav.Writer()
    file = fs.createReadStream(path)
    file.pipe(wavy).pipe(waver).pipe(spark)
  </code></pre>