/* * Audio */ public void writeAudio() { ArrayList segments = fract.getSegments(); int numSegments = segments.size(); mySound = new AudioChannel(); mySound.initChannel(numSegments); // grab sample values from the fractal float[] buffer = new float[numSegments]; for(int i = 0; i < numSegments; i++) { Double curVal = (Double)segments.get(i); buffer[i] = curVal.floatValue(); } mySound.samples = buffer; waveDirty = false; } public void writeSoundFile(String filename) { AudioFile myFile = new AudioFile(); myFile.open(filename, (float)SR, Ess.WRITE); myFile.write(mySound.samples); myFile.close(); } // sound buffer can be invalid, but the system // is still trying to play. this basically says // we need to regenerate the audio public void invalidateAudio() { if (mySound != null) mySound.stop(); waveDirty = true; } void stopAudio() { if (mySound != null) mySound.stop(); audioPlaying = false; } public void playAudio() { audioPlaying = true; if(waveDirty) return; if (mySound == null) { mySound = new AudioChannel(); } else { mySound.stop(); } mySound.play(Ess.FOREVER); }