home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / audio / SoundTime.lzh / SoundTime / src / explanation.txt next >
Encoding:
Text File  |  1991-12-08  |  1.7 KB  |  40 lines

  1.   I discovered, after some time, how the samples per second was saved into
  2. a standard IFF 8SVX sound.  It all has to do with two bytes in the file.
  3. Byte 32 and 33 (given that byte 0 is the first byte in the file).  You take
  4. the ASCII values of those two bytes.  A 28000 sample-per-second sound would
  5. have the two bytes 109 and 96, at positions 32 and 33, respectively.  To
  6. get the sps value, you merely multiply 109 and 256, and add the second byte
  7. to that product.  To get those two bytes given an sps value, you take the
  8. sps, divide by 256, which gives you the first byte, then modulus (%) it for
  9. the second byte.  Summarily:
  10.  
  11.         sps = byte1 * 256 + byte2
  12.  
  13.         byte1 = sps / 256
  14.         byte2 = sps % 256
  15.  
  16.   For those non-programmer types, modulus, indicated by a % sign, merely
  17. gives the remainder of two numbers.  For instance, 20 % 8 is approximately
  18. 4.
  19.   That's the difficult part, if difficult at all.  The easy part is
  20. figuring two things: how big the sound will be, and how many seconds it
  21. plays.
  22.   To figure the size:
  23.  
  24.         size = secs * sps
  25.  
  26. So if you digitize music for 21 seconds at 17000 samples per second, you're
  27. going to get approximately a 357000-byte sound.  I say approximately
  28. because of the extraneous data included in the final sound file.  If you'll
  29. edit the sound, you'll see strings like "FORM" and "VHDR."  NOTE THAT THIS
  30. ALSO MAKES SOUNDTIME ITSELF APPROXIMATE IN ITS CALCULATIONS.
  31.   Of course, it's just a mere reversal to figure out the seconds of play.
  32.  
  33.         secs = size / sps
  34.  
  35.   That's all there is to it.  Have fun, and if you have any neat
  36. implementation ideas or such, e-mail me at the address given in
  37. SoundTime.doc, included in this archive.
  38.  
  39.  - T
  40.