tags

chaos ow wtf

 
favorites
 
 
None yet! =D/
 
awk
Level 7 Mixist
 
Detroit Luv 
30th Σ3.013

 
Dong Factor 
29th Σ3.617

 
Huggable 
30th Σ2.846

 
Curliness 
26th Σ4.077

 
Shot in Pants 
19th Σ4.183

 
Roar
 
  29th/32   Σ17.735   Jun 15th 2007 12:54am
 
/player/EntryPlay/1187/
1187
 
#define CYCLES 6

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h>
#include <string.h>

typedef float sample;

#define REALFILES 25
#define FILES REALFILES

// perl -e 'for (`ls IN`) {chomp; $a = "IN/$_"; s/(.+?)\.mp3$/OUT\/$1.wav/; `lame --decode -t $a $_`; }'
char *all[REALFILES] =
{"OUT/botb_0379.wav",
"OUT/botb_0411.wav",
"OUT/botb_0429.wav",
"OUT/botb_0442.wav",
"OUT/botb_0460.wav",
"OUT/botb_0386.wav",
"OUT/botb_0416.wav",
"OUT/botb_0431.wav",
"OUT/botb_0449.wav",
"OUT/botb_0463.wav",
"OUT/botb_0388.wav",
"OUT/botb_0417.wav",
"OUT/botb_0432.wav",
"OUT/botb_0450.wav",
"OUT/botb_0464.wav",
"OUT/botb_0389.wav",
"OUT/botb_0419.wav",
"OUT/botb_0433.wav",
"OUT/botb_0453.wav",
"OUT/botb_0465.wav",
"OUT/botb_0393.wav",
"OUT/botb_0428.wav",
"OUT/botb_0439.wav",
"OUT/botb_0459.wav",
"OUT/botb_0466.wav"
};

#define BASE (M_PI*2/44100*8.1757989156)
#define SEMITONE (pow(2,1.0/12.0))

sample *load(char *file, int &size) {
struct stat sb;
stat(file, &sb);
FILE *in = fopen(file, "r");
size = sb.st_size;
short *out = (short *)malloc(size);
fread(out, size/sizeof(short), sizeof(short), in);
fclose(in);
size /= sizeof(short);
int undersize = size;
//for (size = 1; size < undersize; size *= 2);
sample *vals = (sample *)malloc(size*sizeof(sample));
for(int c = 0; c < undersize; c++)
vals[c] = ((sample)out[c])/SHRT_MAX;
for(int c = undersize; c < size; c++)
vals[c] = 0;
free(out);
return vals;
}

#define UPH(z) ((z)/2 + (z)%2)

struct haar {
sample *sig;
sample *noi;
int len;
haar() : sig(0), noi(0), len(0) {}
};

const sample sqrt2 = sqrt(2);

void haarFromTo (haar &a, haar &b) {
b.len = UPH(a.len);
b.sig = (sample *)malloc(sizeof(sample)*b.len);
b.noi = (sample *)malloc(sizeof(sample)*b.len);
for(int c = 0; c < a.len; c+=2) {
b.sig[c/2] = (a.sig[c] + a.sig[c+1])/sqrt2;
b.noi[c/2] = (a.sig[c] - a.sig[c+1])/sqrt2;
}
printf("haar from %d to %d\n", a.len, b.len);
}

struct file { haar contents[2][CYCLES]; };

void allocFile(file &f, int qsongl) {
qsongl = UPH(qsongl);
for (int s = 0; s < 2; s++) {
f.contents[s][0].sig = (sample *)malloc(sizeof(sample)*qsongl);
f.contents[s][0].noi = (sample *)malloc(sizeof(sample)*qsongl);
f.contents[s][0].len = qsongl;
for(int c = 0; c < f.contents[s][0].len; c++) {
f.contents[s][0].sig[c] = 0;
f.contents[s][0].noi[c] = 0;
}
}
}

void fillFile(file &f, char *name) {
int qsongl;
sample *qsong = load(name, qsongl);
allocFile(f, qsongl);

// DESTEREO, DECOMPOSE:
for(int c = 0; c < qsongl; c++) {
f.contents[c%2][0].sig[c/2] = qsong[c];
}

free(qsong);
}

void decompose(file &f) {
for(int s = 0; s < 2; s++) {
for(int c = 0; c < CYCLES-1; c++) {
haarFromTo(f.contents[s][c], f.contents[s][c+1]);
}
}
}

void recompose(file &f) {
for(int s = 0; s < 2; s++) {
for(int c = CYCLES-2; c >= 0; c--) {
for(int d = 0; d < f.contents[s][c].len; d++) {
f.contents[s][c].sig[d] = (f.contents[s][c+1].sig[d/2]
+ f.contents[s][c+1].noi[d/2] * (d%2?-1:1))
/ sqrt2;
}
}
}
}

#define OUTS (44100 * 60)

int main() {
int outp = 0;
sample *out = (sample *)malloc(OUTS*sizeof(sample)*2);
short *sout = (short *)malloc(OUTS*sizeof(short)*2);

printf("...doomed...\n");

file in[FILES];
for(int c = 0; c < FILES; c++) {
printf("File %d of %d, %s:\n", c, FILES, all[c]);
fillFile(in[c], all[c]);
decompose(in[c]);
}

file final;
allocFile(final, OUTS);
decompose(final);

printf("DOOMED!\n");

// SET THE STAGE:

#define CIL(a, b) if (fabs(a) < fabs(b)) a = b

for(int z = 0; z < FILES; z++) {
for(int s = 0; s < 2; s++) {
for(int c = 1; c < CYCLES; c++) { // Go from the bottom up. Why? I dunno.
for(int d = 0; d < final.contents[s][c].len && d < in[z].contents[s][c].len; d++) {
CIL(final.contents[s][c].sig[d], in[z].contents[s][c].sig[d]);
CIL(final.contents[s][c].noi[d], in[z].contents[s][c].noi[d]);
}
}
}
}

printf("...done\n");

// HAAR:

recompose(final);

outp = 0;

// RESTEREO:
{ int c = 0;
for(int d = 0; d < final.contents[0][c].len; d++) {
for(int s = 0; s < 2; s++) {
out[outp++] = final.contents[s][c].sig[d];
}
}
}

// FLATTEN:
sample roof = 0;
for(int c = 0; c < outp; c++)
if (fabs(out[c]) > roof)
roof = fabs(out[c]);
printf("...%f\n", roof);

for(int c = 0; c < outp; c++)
sout[c] = (out[c]/roof)*SHRT_MAX;

// ------------------ SAVE ------------------

FILE *fout = fopen("haar.out", "w");
fwrite(sout, outp, sizeof(short), fout);
#endif

return 0;
}
Creative Commons License
58
0
627
11
27
 


previous entry
mixman - Dr Djs RenCen Boogie


nextious entry
dj_snksonaplane - dj snakes on a plane - that bitch from babylon 5 wont stop calling me
 
6082
Level 30 Chipist
post #6082 :: 2007.06.15 6:58am
HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAA
 
 
6083
Level 12 Mixist
post #6083 :: 2007.06.15 3:34pm
Ker-hazy.
 
 
6084
Level 16 Mixist
post #6084 :: 2007.06.16 2:10pm
sesame seed gun
 
 
6085
Level 14 Criticist
post #6085 :: 2007.06.16 6:58pm
Crazy is right!
 
 
6086
Level 22 Mixist
post #6086 :: 2007.06.19 1:08am
:D
 
 
6087
Level 27 Mixist
ui
post #6087 :: 2007.06.20 4:46pm
i guess, you get all the samples then just mixing all in 1 and the long samples just x2 the speed =X.... and all with a "program" or something?... =X... i want a video, of how you do this! =X
 
 
6088
Level 27 Renderist
post #6088 :: 2007.06.20 5:07pm
damn, dude... try running the same code with a bunch of other audio samples or something.
 
 
6089
Level 12 Mixist
post #6089 :: 2007.06.20 5:58pm
this is good, but short. what is that code for?
 
 
6090
Level 11 Mixist
post #6090 :: 2007.06.20 8:00pm
hate your sound, love your process
 
 
6091
Level 15 Chipist
post #6091 :: 2007.06.21 4:45am
@Hasewn, the code is what created this track

@awk, you get extra points for that process :)
 
 
6092
Level 6 Criticist
post #6092 :: 2007.06.21 6:19am
Hahaha, funny tune! Nice code! :D
 
 

LOGIN or REGISTER to add your own comments!