Mercurial > hg > jslab
view src/samer/units/LineOut.java @ 8:5e3cbbf173aa tip
Reorganise some more
author | samer |
---|---|
date | Fri, 05 Apr 2019 22:41:58 +0100 |
parents | bf79fb79ee13 |
children |
line wrap: on
line source
/* * Copyright (c) 2000, Samer Abdallah, King's College London. * All rights reserved. * * This software is provided AS iS and WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. */ package samer.units; import samer.maths.*; import samer.core.*; import samer.core.types.*; import samer.audio.*; import samer.tools.*; import javax.sound.sampled.*; /** A class which takes real valued samples from a VVector, converts them to 16 bit integer samples, and writes them to an audio device. <p> Can optionally output only a sub-window of input vector This window is adjustable on the fly, so, for example, we can output the last M samples of a sliding window. */ public class LineOut implements Task { AudioSink sink; Task writer=new NullTask(); Vec vec; int i0, i1; public LineOut(Vec buf, AudioSink sink) throws Exception { this.sink=sink; setInput(buf); } public Vec input() { return vec; } public AudioSink getSink() { return sink; } public void setSink(AudioSink sink) { this.sink=sink; setWindow(i0,i1); } public void setInput(Vec vec) { this.vec=vec; setWindow(0,vec.size()); } public void setWindow(int a,int b) { i0=a; i1=b; writer=sink.writer(vec.array(),i0,i1-i0); } public void dispose() { writer.dispose(); sink.dispose(); } public void starting() { writer.starting(); } public void stopping() { writer.stopping(); } public void run() throws Exception { writer.run(); } }