annotate audio/java/StreamSink.java @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 63cefb01cbab
children
rev   line source
samer@0 1 /*
samer@0 2 * StreamSink.java
samer@0 3 *
samer@0 4 * Copyright (c) 2000, Samer Abdallah, King's College London.
samer@0 5 * All rights reserved.
samer@0 6 *
samer@0 7 * This software is provided AS iS and WITHOUT ANY WARRANTY;
samer@0 8 * without even the implied warranty of MERCHANTABILITY or
samer@0 9 * FITNESS FOR A PARTICULAR PURPOSE.
samer@0 10 */
samer@0 11
samer@46 12 package ishara.audio;
samer@0 13
samer@0 14 import javax.sound.sampled.*;
samer@0 15 import java.io.*;
samer@0 16
samer@0 17 import org.tritonus.share.sampled.AudioSystemShadow;
samer@0 18 import org.tritonus.share.sampled.file.AudioOutputStream;
samer@0 19
samer@0 20 /**
samer@0 21 An AudioSink that writes to an OutputStream
samer@0 22 */
samer@0 23
samer@0 24 public class StreamSink extends AudioSink
samer@0 25 {
samer@0 26 AudioOutputStream out;
samer@0 27
samer@0 28 public StreamSink(AudioOutputStream stream) { super(stream.getFormat()); out=stream; }
samer@0 29
samer@0 30 public void dispose() {
samer@0 31 try { out.close(); }
samer@0 32 catch (IOException ex) { print("*** Error closing: "+ex); }
samer@0 33 }
samer@0 34
samer@0 35 public void stop() {}
samer@0 36 public void start() {}
samer@0 37 public int bwrite(byte []buf, int off, int n) throws Exception { return out.write(buf, off, n); }
samer@0 38
samer@0 39 public String toString() { return "StreamSink: "+getFormat(); }
samer@0 40
samer@0 41 public static AudioOutputStream wavOutputStream(OutputStream stream, AudioFormat fmt) throws Exception {
samer@0 42 // could alse have raw output stream
samer@0 43 return AudioSystemShadow.getAudioOutputStream(
samer@0 44 AudioFileFormat.Type.WAVE,fmt,AudioSystem.NOT_SPECIFIED,stream);
samer@0 45 }
samer@0 46 }