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-24 14:11

>>10
The meaning of this 8000hz
Number of samples read per second.
how endianness affects interpretation of sound
Each sample is one byte in this format, so it doesn't matter.
what does each byte (in 8bit pcm) mean
Simply the attenuation, 127 is 0, 0 is negative maximum, and 255 maximum.

For a pure tone, use a sine wave scaled to 0-255.  Figure out a way of calculating the frequency (it has to do with 8000Hz) and you can generate any tone.

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