Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/prog/ AUDIO THREAD PART III

Name: Anonymous 2008-05-24 3:21

#include <stdio.h>
#include <stdlib.h>

main() {
 int i,j,k,l;
 while(1) {
  l=rand()%100;
  for(k=0;k<l;k++) {
   for(i=0;i<255;i+=128)
    for(j=0;j<k;j++)
     putchar(i);
   for(;i;i-=128)
    for(j=0;j<k;j++)
     putchar(i);
  }
 }
}


gcc -o lolsound lolsound.c
./lolsound > /dev/dsp


First one to hack this into saying "Have you read your SICP today?" gets an internet.

Name: Anonymous 2008-05-26 1:28

I'm not going to decipher your graph, but

Wave 1: 0  1  2  3  4  5  4  3  2  1  0 -1 -2
Wave 2: 0  2  4  2  0 -2 -4 -2  0  2  4  2  0
Combo : 0  3  6  5  4  3  0  1  2  3  4  1 -2

is how it works. The only thing to watch out for is that exceeding your maximum amplitude is very likely, and will result in distorted output. You can just let the numbers overflow if you want, or you can clip the waveform, what audio software usually dies. In my example, if the maximum amplitude is 5, that six needs to be made into a 5. This will also result in distorted output, but that's just how it is. If you're trying to produce nice sound, it's a matter of carefully picking levels that won't clip given the material you are mixing.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List