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