FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Tools
(Moderator: REAS)
   wave to raw conversion
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: wave to raw conversion  (Read 582 times)
mrb

WWW
wave to raw conversion
« on: Nov 5th, 2003, 4:33am »

hey --  
 
i needed a quick app to take wave files and make them into raw data files i could read in c++.  i am using these files for granular synthesis, and it is much more straightforward to do it in java/processing then to go through the trouble of loading files in in the c++ framework when i don't want to do it in real time anyway.  this is what rules about having this type of prototyping, etc. environment around -- i tooled for hours in c++ trying to load in a dumb wave file with a framework that wasn't compatible with the one i had already been programming in.  processing was the first thing i thought of when i considered an outside tool to generate the raw files for me.  i may write a small "header" for these files which contains the length, etc., but for now this is good enough.
 
mrb
 
Code:

BSound samp;
 
void setup()
{
  samp = loadSound("dre.wav");
  byte[] samps = new byte[samp.length];
  println(samp.length);
 
  for (int i=0; i<samp.length; i++) {
    byte a;
    a = (byte)((samp.samples[i])+127);
    samps[i] = a;
  }
 
  saveBytes("numbers.txt", samps);
 
}
 
void loop() {
  repeat(samp);
}
 
Pages: 1 

« Previous topic | Next topic »