title: Java audio... getting from byte[] of raw waveform to playable Clip
body: <p>I'm trying to figure out how to play a raw 8-bit (signed) waveform using Java, and struggling because it seems like every API example I find assumes media playback from a file. Here's what I have so far (shortened for clarity):</p>
  <pre><code>// Assume waveform array has 480 bytes, and consists of 24 periods of a 1000hz sine wave.
  byte[] waveform = WaveformGenerator.generateWaveform();
  
  Clip clip = AudioSystem.getClip();
  ByteArrayInputStream fakeInputStream= new ByteArrayInputStream(waveform);
  AudioInputStream inputStream = AudioSystem.getAudioInputStream(fakeInputStream);
  clip.open(inputStream);
  clip.start();
  </code></pre>
  <p>When it runs, AudioSystem.getAudioInputStream(fakeInputStream) throws
  <code>javax.sound.sampled.UnsupportedAudioFileException: Stream of unsupported format</code>
  before it even <em>makes</em> it to clip.open(inputStream);</p>
  <p>ok, fair enough... I guess I need to tell it that it's a mono 8-bit PCM waveform. So, I created an AudioFormat to let it know that it's 48khz 8-bit PCM...</p>
  <pre><code>AudioFormat audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 48000, 8, 1, 1, 48000, false);
  </code></pre>
  <p>... then realized (too late) that the variant of AudioSystem.getAudioInputStream() that allows you to specify the format requires that you <em>already have</em> an AudioInputStream. As far as I can tell, there's no variant of getAudioInputStream that allows you to SIMULTANEOUSLY specify its type <em>and</em> content.</p>
  <p>Obviously, I'm going down the wrong track here. So... what <em>is</em> the correct way to get from a byte array containing a raw 8-bit signed PCM waveform to an audio object that can be play()'ed?</p>