Class JDK13LongAudioClip
java.lang.Object
org.monte.media.eightsvx.JDK13LongAudioClip
- All Implemented Interfaces:
Runnable,AudioClip,LoopableAudioClip
JDK13AudioClip.
- Author:
- Werner Randelshofer, Hausmatt 10, CH-6405 Goldau, Switzerland
-
Field Summary
Fields inherited from interface org.monte.media.eightsvx.LoopableAudioClip
LOOP_CONTINUOUSLY -
Constructor Summary
ConstructorsConstructorDescriptionJDK13LongAudioClip(byte[] samples, int sampleRate, int volume, float pan) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionlongObtains the media duration in microsecondslongObtains the current position in the audio data, in microseconds.voidloop()Starts playing this audio clip in a loop.voidloop(int count) Starts looping playback from the current position.voidplay()Starts playing this audio clip.voidrun()When an object implementing interfaceRunnableis used to create a thread, starting the thread causes the object'srunmethod to be called in that separately executing thread.voidsetFramePosition(int param) Sets the media position in sample frames.voidsetLoopPoints(int start, int end) Sets the first and last sample frames that will be played in the loop.voidstart()Starts the audio clip.voidstop()Stops playing this audio clip.
-
Constructor Details
-
JDK13LongAudioClip
public JDK13LongAudioClip(byte[] samples, int sampleRate, int volume, float pan) Creates a new instance.- Parameters:
samples- Array of signed linear 8-bit encoded audio samples.sampleRate- sampleRate of the audio samples.volume- The volume setting controls the loudness of the sound. range 0 (mute) to 64 (maximal volume).pan- The relative pan of a stereo signal between two stereo speakers. The valid range of values is -1.0 (left channel only) to 1.0 (right channel only). The default is 0.0 (centered).
-
-
Method Details
-
loop
-
loop
public void loop(int count) Starts looping playback from the current position. Playback will continue to the loop's end point, then loop back to the loop start pointcounttimes, and finally continue playback to the end of the clip.If the current position when this method is invoked is greater than the loop end point, playback simply continues to the end of the clip without looping.
A
countvalue of 0 indicates that any current looping should cease and playback should continue to the end of the clip. The behavior is undefined when this method is invoked with any other value during a loop operation.If playback is stopped during looping, the current loop status is cleared; the behavior of subsequent loop and start requests is not affected by an interrupted loop operation.
- Specified by:
loopin interfaceLoopableAudioClip- Parameters:
count- the number of times playback should loop back from the loop's end position to the loop's start position, orto indicate that looping should continue until interruptedLoopableAudioClip.LOOP_CONTINUOUSLY
-
play
-
start
public void start()Starts the audio clip. -
stop
-
setFramePosition
public void setFramePosition(int param) Sets the media position in sample frames. The position is zero-based; the first frame is frame number zero. When the clip begins playing the next time, it will start by playing the frame at this position.To obtain the current position in sample frames, use the
method ofgetFramePositionDataLine.- Parameters:
param- the desired new media position, expressed in sample frames
-
getMicrosecondLength
public long getMicrosecondLength()Obtains the media duration in microseconds- Returns:
- the media duration, expressed in microseconds,
or
AudioSystem.NOT_SPECIFIEDif the line is not open. - See Also:
-
getMicrosecondPosition
public long getMicrosecondPosition()Obtains the current position in the audio data, in microseconds. The microsecond position measures the time corresponding to the number of sample frames captured by, or rendered from, the line since it was opened. The level of precision is not guaranteed. For example, an implementation might calculate the microsecond position from the current frame position and the audio sample frame rate. The precision in microseconds would then be limited to the number of microseconds per sample frame.- Returns:
- the number of microseconds of data processed since the line was opened
-
setLoopPoints
public void setLoopPoints(int start, int end) Sets the first and last sample frames that will be played in the loop. The ending point must be greater than or equal to the starting point, and both must fall within the the size of the loaded media. A value of 0 for the starting point means the beginning of the loaded media. Similarly, a value of -1 for the ending point indicates the last frame of the media.- Parameters:
start- the loop's starting position, in sample frames (zero-based)end- the loop's ending position, in sample frames (zero-based), or -1 to indicate the final frame- Throws:
IllegalArgumentException- if the requested loop points cannot be set, usually because one or both falls outside the media's duration or because the ending point is before the starting point
-
run
public void run()When an object implementing interfaceRunnableis used to create a thread, starting the thread causes the object'srunmethod to be called in that separately executing thread.The general contract of the method
runis that it may take any action whatsoever.
-