<?
// write values to a file.

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

int main()
{
  
int value[1] = {255};
  
char filename[] = "sil.wav";
  
int file_descriptorclose_err;
  
int incrementcurend;
  
int passes 1;
  
int volcontrol 10;
  
  
srand((unsigned inttime (NULL));

  
file_descriptor open (filenameO_RDWR);

  
int i;
  
end lseek(file_descriptor0SEEK_END) - 10;        // detect end of file
  
cur lseek(file_descriptor54SEEK_SET);            // start from beginning of file, but after header
  
float pitch 0.01;
  
/* write until file ends */
  
while(cur end/2)
  {
    
value[0] = (int) 256 sin(pitch*((float) cur));
    
value[0] = value[0] / volcontrol;
    
write (file_descriptor, (void *) value1);
    
cur lseek(file_descriptor0SEEK_CUR);
    
pitch *= 1.00001;
  }
  
pitch 1024;
  
int cutoff;
  while(
cur end)
  {
    
value[0] = cur%((int) pitch);
    
cutoff = (int) (pitch 2);
    if (
value[0] > cutoff)
    {
      
value[0] = 255;
    }
    else
    {
      
value[0] = 0;
    }
    
value[0] = value[0] / volcontrol;
    
write (file_descriptor, (void *) value1);
    
pitch /= 1.00001;
    
cur lseek(file_descriptor0SEEK_CUR);
  }
  
  
printf("Done \n");
  
close (file_descriptor);

  return 
0;
}
?>
Databending - TranceAddict Forums - Production Studio
return to tranceaddict TranceAddict Forums Archive > DJing / Production / Promotion > Production Studio

 
Databending
View this Thread in Original format
Vector A
"Databending" is taking files that were meant to be interpreted by your computer in one way and editing or interpreting them in another way. For example, you could take an image or text or executable file, and load it into a WAV editor as sound. This generally leads to some pretty crazy (and mostly very noisy) results.

For example, my post so far, copied a thousand times, sounds like this when imported into Audacity as raw data (File > Import > Raw Data > signed 8 bit stereo PCM):

http://dl.dropbox.com/u/27221906/TA/post.mp3

It's kind of hard to predict just by looking at a file how a WAV editor will interpret it. The sound will also change depending on the bit rate and other options you select when loading the data. But for me the unpredictability is part of the fun. I've found that large DOC and PDF files can give some good results, while JPGs usually seem to end up as just white noise. If you're into programming, you can also try generating large files of your own within some parameters (for example, write random numbers or letters, or paste randomly chosen text blocks from a pre-defined set to a file) and see how your WAV editor interprets them. With bigger and more varied files, you generally get more sounds and have a better chance of finding something interesting.

Here are some neat noises I got by loading different kinds of files into Audacity, plus some trial and error with programming random output (make sure your volume is reasonable before listening):

http://dl.dropbox.com/u/27221906/TA/datab.wav

There are also other things you can do, like opening a sound file in a hex or text editor, replacing or altering large portions of it, then trying to play it. Of course, you can also databend with other types of files in mind for the end product, like images, though I haven't really looked into that yet.

Anyway, a lot of the fun of this kind of thing is seeing what you can come up with on your own. So if you mess with some files yourself and find something you enjoy, I'd like to hear it.

:thepirate
Vector A
Here's a basic example of how you can use a program that makes random text. This Ruby program makes a new file, prints a random character in it, and inserts a random number of spaces after the character. It does this 50,000 times. As the program goes on, the maximum for the random number of spaces increases (so the characters tend to get sparser):
code:
1.times do |x| f = File.new("rand1", "w") 50000.times do |y| ch = (33+rand(45)).chr f.print ch, " "*rand(y/10) end f.close end

A normal text file full of random characters (no spaces) will sound something like this when loaded in Audacity:

http://dl.dropbox.com/u/27221906/TA/rand0txt.wav

But the one created by the program above is a bit more interesting:

http://dl.dropbox.com/u/27221906/TA/rand1txt.wav

You can hear the little "static bits" getting further apart as the file plays.
dj_alfi
cool stuff. sounds SIDy :)
Vector A
So, I've figured out how to make some basic waveforms by writing numbers to files.
PHP:



If you compile and run the C program (with appropriate filename entered), this is what you get:

http://dl.dropbox.com/u/27221906/TA/sil.wav

The pitch-bending sounds really screwed up on the square wave, not sure why yet, lol. You can also make a saw wave with the modulus operator (something like "value[0] = cur % 256;", with higher values for lower frequencies). I am a n00b at C so I'm sure there are tons of things that could be done better.

:thepirate
KilldaDJ
lol a lot of it is mostly noise !
Vector A
quote:
Originally posted by KilldaDJ
lol a lot of it is mostly noise !

http://dl.dropbox.com/u/27221906/TA/hello.wav
CLICK TO RETURN TO TOP OF PAGE
 
Privacy Statement