Package eu.bandm.sig.adlib2.lib
Class IntJreOut
java.lang.Object
eu.bandm.sig.adlib2.lib.IntJreOut
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
IntJreOut_sgnPCM_16bit_BigEndian
Output driver from the single-signal-pull sig world into the block-push java runtime system.
(based on /sig/sub/organ/src/main/java/eu/bandm/sig/organ/Player.java
and /sig/src/eu/bandm/sig/adlib/DataLineSink.java
-
Field Summary
Modifier and TypeFieldDescriptionprotected final int
protected final int
"Frames" used in this class exclusively for "sample times channels".protected final int
protected final int[][]
protected final byte[]
-
Constructor Summary
ModifierConstructorDescriptionprotected
IntJreOut
(int minLatency, int maxLatency, int threadPriority, IntBufferedProducer sources) Only constructor. -
Method Summary
Modifier and TypeMethodDescriptionabstract AudioFormat
audioFormat
(int sampleRate) Callback, must be overridden by an implementing sub-class.abstract int
Callback, must be overridden by an implementing sub-class.void
close()
Direct access to the "close" operation,Line.close()
.boolean
isOpen()
Return the open/close state.void
open
(SourceDataLine peer, int sampleRate) The jre requires an "open" operation, which must specify the format and the buffer size.void
void
start()
Direct access to the "start" operationDataLine.start()
void
stop()
Direct access to the "stop" operationDataLine.stop()
protected abstract void
uncook
(int samples) Encodes the cooked buffers into the raw buffer, always starting both at position 0.
-
Field Details
-
channels
protected final int channels -
bytesPerFrame
protected final int bytesPerFrame"Frames" used in this class exclusively for "sample times channels". -
bufferSize
protected final int bufferSize -
cooked
protected final int[][] cooked -
raw
protected final byte[] raw
-
-
Constructor Details
-
IntJreOut
protected IntJreOut(int minLatency, int maxLatency, int threadPriority, IntBufferedProducer sources) Only constructor. The subclasses of this class realize different output formats. The instances are subsequentlyopen(javax.sound.sampled.SourceDataLine, int)
ed with an argument of typeSourceDataLine
which realizes the (multi channel) "physical" output, and one particular sampling rate. The combination of all these format parameters must be checked in advance for feasibility---the negotiation and planning level is not contained in this code, because it can imply very different heuristics, interactions, configuration mechanisms, etc.- Parameters:
minLatency
- in samplesmaxLatency
- in samplessources
- will be assigned to the output channels in this particular sequential order. (The encoding bytes of the single samples of multiple output channels simply follow each other in the written output block. Remarkably, this is totally undocumented in the Jre API doc.)
-
-
Method Details
-
setLineCloseListener
-
open
The jre requires an "open" operation, which must specify the format and the buffer size. Therefore this method must be called before expecting any hearable output.- Throws:
IllegalStateException
- if the channel has already been opened.LineUnavailableException
-
start
public void start()Direct access to the "start" operationDataLine.start()
- Throws:
IllegalStateException
- if the channel has not been opened byopen(SourceDataLine,int)
.
-
stop
public void stop()Direct access to the "stop" operationDataLine.stop()
- Throws:
IllegalStateException
- if the channel has not been opened byopen(SourceDataLine,int)
.
-
close
public void close()Direct access to the "close" operation,Line.close()
. Callsstop()
before, so that we assume thatDataLine.stop()
is idempotent.- Specified by:
close
in interfaceAutoCloseable
- Throws:
IllegalStateException
- if the channel has not been opened byopen(SourceDataLine,int)
.
-
isOpen
public boolean isOpen()Return the open/close state.- See Also:
-
uncook
protected abstract void uncook(int samples) Encodes the cooked buffers into the raw buffer, always starting both at position 0. -
bytesPerSample
public abstract int bytesPerSample()Callback, must be overridden by an implementing sub-class. -
audioFormat
Callback, must be overridden by an implementing sub-class. Delivers an object which is required by the java environment for an "open()" of the physical line.
-