User Tools

Site Tools


cs276:extremities
// Example by Krister Olsson, modified by spc
// NOTE: saveSound always saves to Applications folder (oddly enough) 
// unless given a full pathname

import krister.Ess.*;

AudioChannel myChannel;

void setup() {
  size(256,200);
  background(0, 0, 50);

  // start up Ess
  Ess.start(this);

  // load fileinto a new AudioChannel
  myChannel=new AudioChannel("thisisatest.wav");

  for (int i=0;i<myChannel.size;i++) {
    set(i, (int) (height/2 - myChannel.samples[i]*(height/2-1)), 0);
  }

  extreme(myChannel);
  myChannel.saveSound("/home/scarl/sketchbook/Audio/extreme/extreme.wav");
  
  // start the sound 
  myChannel.play();
}
  
void extreme(AudioChannel chan) {
  for (int i = 0; i < chan.size; i++) {
    if (chan.samples[i] < 0) { // negative 
      chan.samples[i] = -1.0;
    } else {
      chan.samples[i] = 1.0;
    }
  }
}

void draw() { /* nothing to do */ }

// we are done, clean up Ess
public void stop() {
  Ess.stop();
  super.stop();
}
cs276/extremities.txt · Last modified: 2012/11/07 16:19 by scarl