title: How can I convert a .wav file to a float array ( edit the float array e.g. adding two signals) and back to a .wav file without whitenoise
body: <p>I am trying to program an auralization via Ray-Tracing in processing. To edit a sample over the information from the Ray Tracer, i need to convert a .wav File (File-Format: PCM-signed,16bit,stereo,2 bytes/frame, little endian) to an Float Array.</p>
  
  <p>I converted the audio via an audioInputStream and a DataInputStream, where I am loading the audio into an byte Array. </p>
  
  <p>Then I convert the byte Array to a float array like this.</p>
  
  <pre class="lang-java prettyprint-override"><code>byte[] samples;
  float[] audio_data = float(samples); 
  </code></pre>
  
  <p>When I convert the float Array back to a .wav File, I'm getting the sound of the original Audio-File.</p>
  
  <p>But when I'm adding another Float Array to the Original signal and convert it back to a. wav file via the method above(even if I'm adding the same signal), i get a white noise signal instead of the wanted signal (I can hear the original signal under the white noise modulated, but very very silent). </p>
  
  <p>I read about this problem before, that there can be problems by the conversion from the float array to a byte array. That's because float is a 32bit datatype and byte (in java) is only 16 bits and somehow the bytes get mixed together wrong so the white noise is the result. In Processing there is a data type with signed 16bit integers (named: "short") but i can't modify the amplitude anymore, because therefore i need float values, which i can't convert to short.</p>
  
  <p>I also tried to handle the overflow (amplitude) in the float array by modulating the signal from 16 bit values (-32768/32767) to values from -1/1 and back again after mixing (adding) the signals. The result gave me white noise. When i added more than 2 signals it gaves me nothing (nothing to hear).</p>
  
  <p>The concrete Problem I want to solve is to add many signals (more than 1000 with a decent delay to create a kind of reverbation) in the form of float Arrays. Then I want to combine them to one Float Array that i want to save as an audio file without white noise.</p>
  
  <p>I hope you guys can help me.</p>