Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li><p>This problem is basically about mapping functions to arrays of numbers. A language that supports first-class functions would come in really handy here.</p></li> <li><p>Check out <a href="http://www.harmony-central.com/Computer/Programming" rel="nofollow noreferrer">http://www.harmony-central.com/Computer/Programming</a> and <a href="http://www.developer.com/java/other/article.php/3071021" rel="nofollow noreferrer">http://www.developer.com/java/other/article.php/3071021</a> for some Java-related info.</p></li> <li><p>If you don't know the basic concepts of encoding sound data, then read <a href="http://en.wikipedia.org/wiki/Sampling_rate" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Sampling_rate</a></p></li> <li><p>The canonical WAVE format is very simple, see <a href="http://www.lightlink.com/tjweber/StripWav/Canon.html" rel="nofollow noreferrer">http://www.lightlink.com/tjweber/StripWav/Canon.html</a>. A header (first 44 bytes) + the wave-data. You don't need any library to implement that.</p></li> </ol> <p>In C/C++, the corresponding data structure would look something like this:</p> <pre class="lang-cpp prettyprint-override"><code>typedef struct _WAVstruct { char headertag[4]; unsigned int remnantlength; char fileid[4]; char fmtchunktag[4]; unsigned int fmtlength; unsigned short fmttag; unsigned short channels; unsigned int samplerate; unsigned int bypse; unsigned short ba; unsigned short bipsa; char datatag[4]; unsigned int datalength; void* data; //&lt;--- that's where the raw sound-data goes }* WAVstruct; </code></pre> <p>I'm not sure about Java. I guess you'll have to substitute "struct" with "class" and "void* data" with "char[] data" or "short[] data" or "int[] data", corresponding to the number of bits per sample, as defined in the field bipsa.</p> <p>To fill it with data, you would use something like that in C/C++:</p> <pre class="lang-cpp prettyprint-override"><code>int data2WAVstruct(unsigned short channels, unsigned short bipsa, unsigned int samplerate, unsigned int datalength, void* data, WAVstruct result) { result-&gt;headertag[0] = 'R'; result-&gt;headertag[1] = 'I'; result-&gt;headertag[2] = 'F'; result-&gt;headertag[3] = 'F'; result-&gt;remnantlength = 44 + datalength - 8; result-&gt;fileid[0] = 'W'; result-&gt;fileid[1] = 'A'; result-&gt;fileid[2] = 'V'; result-&gt;fileid[3] = 'E'; result-&gt;fmtchunktag[0] = 'f'; result-&gt;fmtchunktag[1] = 'm'; result-&gt;fmtchunktag[2] = 't'; result-&gt;fmtchunktag[3] = ' '; result-&gt;fmtlength = 0x00000010; result-&gt;fmttag = 1; result-&gt;channels = channels; result-&gt;samplerate = samplerate; result-&gt;bipsa = bipsa; result-&gt;ba = channels*bipsa / 8; result-&gt;bypse = samplerate*result-&gt;ba; result-&gt;datatag[0] = 'd'; result-&gt;datatag[1] = 'a'; result-&gt;datatag[2] = 't'; result-&gt;datatag[3] = 'a'; result-&gt;datalength = datalength; result-&gt;data = data; // &lt;--- that's were the data comes in return 0; // an error code, not implemented, yet ...; in Java: return result } </code></pre> <p>Again, I'm not sure about Java but the conversion should be straightforward if you convert the void-pointer to an array corresponding to the bitrate. </p> <p>Then simply write the entire structure to a file to get a playable wave file.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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