Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could try streaming it into/from a byte array (as described at MSDN's <a href="http://msdn.microsoft.com/en-us/library/ff827591.aspx" rel="nofollow">Streaming Data from a WAV File</a>).</p> <p>Basically, use <code>TitleContainer.OpenStream(@"soundfile.wav")</code> in your <code>LoadContent()</code> function to create a <code>System.IO.Stream</code> object. Then to a <code>BinaryReader</code> with <code>new BinaryReader(wavStream)</code>.</p> <p>Read the header:</p> <pre><code>int chunkID = reader.ReadInt32(); int fileSize = reader.ReadInt32(); int riffType = reader.ReadInt32(); int fmtID = reader.ReadInt32(); int fmtSize = reader.ReadInt32(); int fmtCode = reader.ReadInt16(); int channels = reader.ReadInt16(); int sampleRate = reader.ReadInt32(); int fmtAvgBPS = reader.ReadInt32(); int fmtBlockAlign = reader.ReadInt16(); int bitDepth = reader.ReadInt16(); if (fmtSize == 18) { // Read any extra values int fmtExtraSize = reader.ReadInt16(); reader.ReadBytes(fmtExtraSize); } int dataID = reader.ReadInt32(); int dataSize = reader.ReadInt32(); </code></pre> <p>Read the actual sound data:</p> <pre><code>byteArray = reader.ReadBytes(dataSize); </code></pre> <p>Then a whole bunch of complicated code to set up the <code>DynamicSoundEffect</code> object (detailed at the link above)</p> <p>Then you can just use <code>dynamicSound.Play()</code> and <code>dynamicSound.Stop()</code> to play and stop your sound!</p> <p><em>Disclaimer: I haven't tested this method of playing sounds, but it's from MSDN so it's probably accurate</em></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload