# HG changeset patch # User Robert McIntyre # Date 1319974960 25200 # Node ID 5f616cc420dd5e00e0863fdc8b0864c97ae9ecac # Parent b643413c3abae10d121f2fcbdebd5129546f4293 improved WaveFileWriter using tritonus diff -r b643413c3aba -r 5f616cc420dd build.xml --- a/build.xml Sun Oct 30 04:22:14 2011 -0700 +++ b/build.xml Sun Oct 30 04:42:40 2011 -0700 @@ -19,6 +19,8 @@ + + diff -r b643413c3aba -r 5f616cc420dd src/com/aurellem/capture/Capture.java --- a/src/com/aurellem/capture/Capture.java Sun Oct 30 04:22:14 2011 -0700 +++ b/src/com/aurellem/capture/Capture.java Sun Oct 30 04:42:40 2011 -0700 @@ -56,13 +56,14 @@ AppSettings settings = new AppSettings(true); settings.setAudioRenderer("Send"); app.setSettings(settings); + final WaveFileWriter writer = new WaveFileWriter(file); Callable thunk = new Callable(){ public Object call(){ AudioRenderer ar = app.getAudioRenderer(); if (ar instanceof MultiListener){ MultiListener ml = (MultiListener)ar; - ml.registerSoundProcessor(new WaveFileWriter(file)); + ml.registerSoundProcessor(writer); } return null; } diff -r b643413c3aba -r 5f616cc420dd src/com/aurellem/capture/audio/WaveFileWriter.java --- a/src/com/aurellem/capture/audio/WaveFileWriter.java Sun Oct 30 04:22:14 2011 -0700 +++ b/src/com/aurellem/capture/audio/WaveFileWriter.java Sun Oct 30 04:42:40 2011 -0700 @@ -1,51 +1,41 @@ package com.aurellem.capture.audio; -import java.io.ByteArrayInputStream; import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.util.Vector; -import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import org.tritonus.sampled.file.WaveAudioOutputStream; +import org.tritonus.share.sampled.file.TDataOutputStream; +import org.tritonus.share.sampled.file.TNonSeekableDataOutputStream; public class WaveFileWriter implements SoundProcessor { - public Vector fullWaveData = new Vector(); public File targetFile; - - public WaveFileWriter(File targetFile){ - this.targetFile = targetFile; - } - - - WaveAudioOutputStream wao; - - - public void cleanup() { - byte[] data = new byte[this.fullWaveData.size()]; - - for (int i = 0; i < this.fullWaveData.size(); i++){ - data[i] = this.fullWaveData.get(i);} - - ByteArrayInputStream input = new ByteArrayInputStream(data); - AudioFormat format = new AudioFormat(44100.0f, 32, 1, true, false); - AudioInputStream audioInput = new AudioInputStream(input, format, data.length / 4 ); - try {AudioSystem.write(audioInput, AudioFileFormat.Type.WAVE, targetFile);} - catch (IOException e) {e.printStackTrace();} + private WaveAudioOutputStream wao; + public WaveFileWriter(File targetFile) throws FileNotFoundException{ + wao = new WaveAudioOutputStream(new AudioFormat(44100.0f, 32, 1, true, false), + AudioSystem.NOT_SPECIFIED, + (TDataOutputStream) new TNonSeekableDataOutputStream(new FileOutputStream(targetFile))); } - - public void process(ByteBuffer audioSamples, int numSamples) { - for (int i = 0; i