Newsgroups: alt.music.nin
Subject: Sound Sample Speed (like in Eraser(denial:realization) )
Summary: slowing and speeding up those pesky sound samples...  ;)
Followup-To: alt.music.nin
Distribution: 
Organization: Computer Science House @ Rochester Institute of Technology
Keywords: Alliteration Long But Informative
Cc: 


I'm trying to make this as plain-worded and explain as much as possible for
those people who are interested to learn, but do not have a degree in 
Computer Science. :)


  Howdy all.  I had posted about the samples in this song, and i said that
i could go into detail if anyone wanted.  Someone wanted.  :)  I figured i'd
post it here, rather than mailing it out to many many people...

  Okay.  You all have that awesome NIN cd, Further Down The Spiral, or maybe
have Information Society's first cd..  You'll need them for reference... :)

  There are a few ways of slowing down or speeding up a sample.  2 that i 
can think of off hand. I'll try and explain each of them.. 

  A sound sample that you'd hear is made of many samplings.  On cds, 88,200 
samples come through every second (that's 44,100 per each left and right). 
each of these samples has a resolution of 16 bits.  That is, it takes 16 ones
and zeroes to describe each of the above mentioned samples.  That works
out to be roughly 10 megabytes per minute.  So, your favorite mix of Head
Like a Hole (the 10 minute long one) takes about as much space to store as
Windows 95.  ;)  ANYWAY...   By manipulating how these samples are ordered,
you can change the way it sounds.

  One simple thing to do is to change the rate at which they are played back,
or the rate at which they are sampled.  This will cause the recording to 
sound slowed down or sped up.  This will also change the pitch at which you 
hear it.  For an example, pop your favorite Michael Bolton single on your
phonograph, and play it at 33rpm instead of 45.  It will sound deeper and
slower.  This is in fact illegal in some states, at least with Michael Bolton
singles.   If you do the same with your favorite DEVO album, playing it at 45
instead of 33, it will sound sped up and higher.  This of course, makes 
"whip it" completely undancable, but humorous to listen to. ;)

  In the beginning of Denial;Realization, the first 8.5 seconds (that's US 
seconds, not metric seconds) as well as near the beginning in the background 
of Physical, the sound sample has been slowed down.  This can be accompished
easily with digital recordings.  If you have the music or whatever sampled, 
and the sequence of samples is as follows:

   abcdefghijklmnopqrstuvwxyz ... 

  And you want to slow it down by a factor of 2, (half as fast) you could
double every sample like this:
 
   aabbccddeeffgghhiijjkkllmmnnoopp ... you get the idea...

  This will change the rate and the pitch.  It will take twice as long to
play back, and sound much deeper.  If you wanted to go some amount between
regular and a factor of 2 (say a factor of 1.5), you might do this:

   abbcddeffghhijjkllmnnoppqrr ... and so on...

  Speeding it up requires dropping samples.  so 2 times faster would look like:

   acegikmoqsuwy ... etc..

  There are other ways of doing this, but they require lots of math, and 
quite frankly, i can't explain them, as i don't understand them myself. :)


  Another way of doing this, slowing down or speeding up a sample, but keeping
the original pitch intact, that is, making it twice as fast, but have it sound
neither deeper or higher is as follows:

  Note: there is a proper way of doing this, but it requires doing complex
mathematics on the sample.  The below is a technique that is very very cheesy,
but sounds awesome, as i have proved to myself. :)

  If you play enough of a sample, enough to convey the tone/pitch of the
original, then skip over a certain number of samples, you can speed up
the sample.  Like if you play 1000 samples, then skip 100 samples, the 
overall sample will be 10% faster, but the pitch will be intact.  (if you 
have a sample of someone talking, and you speed it up using the first 
technique described, they will sound like a chipmunk, whereas, with this 
technique, they will just sound like they are talking faster.  

original sample (each letter represents 100 samples)

   a b c d e f g h i j k l m n o p q r s t ...

sped up sample:

   a b c d f g h i k l m n p q r s ....

(notice sample groups e,j,o, and s were dropped)

  To slow down a sample, you loop on a set number of samples for a set amount
of time.  For example, play 1000 samples twice then play the next 1000 
samples twice, and so on.

original sample (each letter represents 100 samples)

   a b c d e f g h i j k l m n o p q r s t ...

slowed down sample:

   a b a b c d c d e f e f g h g h i j i j k l k l m n m n .... 

  This is exactly what was done in the FDTS tracks where you hear trent 
screaming "eeeeeerraaassee mmeeeeeeee" in the background.  It is also used in 
the beginning of Information Society's "Come with me"; the sample of a guy 
saying "what is the meaning" in the beginning of the track.

   That's basically it.  I'm working on a remix of Something I Can Never Have,
which will be faster than the original, so i have written a cheesy little
program (for MS-DOS, although i can compile it for other systems if need be)
which speeds up a sample.  I ran into a few problems though. 
   I tried at first to copy x number of samples, then skip over y number of
samples, as i have explained above, but i got lots of annoying pops and clicks.
This is caused by the following.  The samples are representing a waveform.  If
you think of a simple sine wave, going from low to high, then back down to low,
then up to high, and so on.  Now, if you start to skip on a point on that 
waveform that is not at the center, and then you finish skipping at a point 
that is also not exactly at that center, the waveform will have a sudden 
movement in it, which you hear as a pop or a click.  I resolved this by first
waiting for the waveform to be going through that center point (in an 
upwards direction), then skipping for y number of samples then continuing to
skip until the waveform was going through the center point in an upwards 
direction.  The results were beautiful.  The sound samples sound great.  :)

  Sorry for going into detail a bit in the end there, but i figured i'd throw
it in for those of you i haven't lost.  :)

	-j 

ps. I also can explain how dolby surround encoding works too if you want.  :)
