Tree-Axis ``` Processing  


Back  
Class   AudioFile
   
Name  

outputBufferGrowSize()

   
Examples  
// Example by Krister Olsson

import krister.Ess.*;

AudioStream myStream;
SineWave myWave;

boolean recording=false;
AudioFile myFile;
int bytesWritten;

void setup() {
  size(256,200);

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

  // create a new AudioStream
  myStream=new AudioStream();

  // our wave
  myWave=new SineWave(240,.33);
  
  // our AudioFile
  myFile=new AudioFile();
  
  // we wont be recording that much, so set our buffer 
  // grow size to two seconds
  //
  // outputBufferGrowSize can be set to the estimated
  // size of sample data being stored in the file
  myFile.outputBufferGrowSize(myStream.frames(2000));

  // start
  myStream.start();
}

void draw() {
}

void audioStreamWrite(AudioStream theStream) {
  // next wave
  myWave.generate(myStream);

  // adjust our phase
  myWave.phase+=myStream.size;
  myWave.phase%=myStream.sampleRate; 
  
  // record
  if (recording) {
    myFile.write(myStream);
    bytesWritten+=myStream.size*2;
  }
}

void keyPressed() {
  if (recording) {
    // stop
    myFile.close();
    
    println("Finished recording. "+bytesWritten+" bytes written.");
  } else {
    // start
    myFile.open("out.aif",myStream.sampleRate,Ess.WRITE);
    bytesWritten=0;
    
    println("Recording started.");
  }
  
  recording=!recording;
}

// we are done, clean up Ess

public void stop() {
  Ess.stop();
  super.stop();
}


Description   Sets the number of sample frames an AudioFile's output buffer grows by when it is full. When write() is called sound is not actually written to disk. Rather, it is written to an internal array that grows as necessary. Sound is actually written when close() is called
   
Syntax  
file.outputBufferGrowSize(size)
   
Parameters  
file   any instance of AudioFile

size   float: the size to grow the buffer when full in sample frames

   
Returns   nothing
   
Usage   Web & Application
   
 
 






   
 
Updated: Tue May 31 04:52:43 PDT 2006


 
  Questions, comments, corrections: e-mail Krister Olsson.