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 5:23


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#define DO   262
#define RE   294
#define MI   330
#define FA   349
#define SOL  392
#define LA   440
#define SI   494
#define DO2  523
#define RE2  587
#define MI2  660
#define FA2  698
#define SOL2 784
#define LA2  880

#define RATE 8000
#define SIZE 8
#define LENGTH 0.3

char *buf;
int satori[] = {FA, SOL, LA, DO2, SI, SI, RE2, DO2, DO2, FA2, MI2, FA2, DO2, LA, FA, SOL, LA, SI, DO2, RE2, DO2, SI, LA, SOL, LA, FA, MI, FA, SOL, DO, MI, FA, 0};

int main(void){

  int i,j,k;
  int dsp;
  int len = RATE*LENGTH;

  buf = (char*)malloc(sizeof(char)*len);

  dsp = open("/dev/dsp", O_RDWR);
  if(dsp < 0){
    fprintf(stderr, "lol\n");
    exit(1);
  }

  printf("HAVE YOU READ YOUR SICP TODAY ?\n");

  for(j=0; satori[j] != 0; j++){

    for(i=0; i<len; i++){
      buf[i] = 127*sin(satori[j]*2*M_PI*(i)/RATE)+127;
    }
   
    write(dsp, buf, len);
  }
  return 0;
}

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