|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectpaulscode.sound.Channel
paulscode.sound.libraries.ChannelJavaSound
public class ChannelJavaSound
The ChannelJavaSound class is used to reserve a sound-card voice using
JavaSound. Channels can be either normal or streaming channels.
For more information about the JavaSound API, visit
http://java.sun.com/products/java-media/sound/
SoundSystem LibraryJavaSound License:
You are free to use this library for any purpose, commercial or otherwise.
You may modify this library or source code, and distribute it any way you
like, provided the following conditions are met:
1) You may not falsely claim to be the author of this library or any
unmodified portion of it.
2) You may not copyright this library or a modified version of it and then
sue me for copyright infringement.
3) If you modify the source code, you must clearly document the changes
made before redistributing the modified source code, so other users know
it is not the original code.
4) You are not required to give me credit for this library in any derived
work, but if you do, you must also mention my website:
http://www.paulscode.com
5) I the author will not be responsible for any damages (physical,
financial, or otherwise) caused by the use if this library or any part
of it.
6) I the author do not guarantee, warrant, or make any representations,
either expressed or implied, regarding the use of this library or any
part of it.
Author: Paul Lamb
http://www.paulscode.com
| Field Summary | |
|---|---|
javax.sound.sampled.Clip |
clip
Used to play back a normal source. |
javax.sound.sampled.SourceDataLine |
sourceDataLine
Used to play back a streaming source. |
| Fields inherited from class paulscode.sound.Channel |
|---|
attachedSource, buffersUnqueued, channelType, libraryType |
| Constructor Summary | |
|---|---|
ChannelJavaSound(int type,
javax.sound.sampled.Mixer mixer)
Constructor: takes channelType identifier and a handle to the Mixer as paramaters. |
|
| Method Summary | |
|---|---|
boolean |
attachBuffer(SoundBuffer buffer)
Attaches the SoundBuffer to be played back for a normal source. |
int |
buffersProcessed()
Returns the number of queued byte[] buffers that have finished playing. |
void |
cleanup()
Empties the streamBuffers list, shuts the channel down and removes references to all instantiated objects. |
void |
close()
Stops the channel, dequeues any queued data, and closes the channel. |
int |
feedRawAudioData(byte[] buffer)
Feeds raw data to the stream. |
void |
flush()
Dequeues all previously queued data. |
float |
millisecondsPlayed()
Calculates the number of milliseconds since the channel began playing. |
void |
newMixer(javax.sound.sampled.Mixer m)
Changes the current mixer |
void |
pause()
Temporarily stops playback for this channel. |
void |
play()
Plays the currently attached normal source, opens this channel up for streaming, or resumes playback if this channel was paused. |
boolean |
playing()
Used to determine if a channel is actively playing a source. |
boolean |
preLoadBuffers(java.util.LinkedList<byte[]> bufferList)
Queues up the initial byte[] buffers of data to be streamed. |
boolean |
processBuffer()
Plays the next queued byte[] buffer. |
boolean |
queueBuffer(byte[] buffer)
Queues up a byte[] buffer of data to be streamed. |
boolean |
resetStream(javax.sound.sampled.AudioFormat format)
Sets the channel up to be streamed using the specified AudioFormat. |
void |
rewind()
Rewinds the attached source to the beginning. |
void |
setAudioFormat(javax.sound.sampled.AudioFormat audioFormat)
Sets the channel up to receive the specified audio format. |
void |
setGain(float g)
Changes the volume. |
void |
setLooping(boolean value)
Defines whether playback should loop or just play once. |
void |
setPan(float p)
Changes the pan between left and right speaker to the specified value. |
void |
setPitch(float p)
Changes the pitch to the specified value. |
void |
stop()
Stops playback for this channel and rewinds the attached source to the beginning. |
| Methods inherited from class paulscode.sound.Channel |
|---|
errorCheck, errorMessage, getClassName, importantMessage, message, printStackTrace |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public javax.sound.sampled.Clip clip
public javax.sound.sampled.SourceDataLine sourceDataLine
| Constructor Detail |
|---|
public ChannelJavaSound(int type,
javax.sound.sampled.Mixer mixer)
SoundSystemConfig class.
type - Type of channel (normal or streaming).mixer - Handle to the JavaSound Mixer.| Method Detail |
|---|
public void cleanup()
cleanup in class Channelpublic void newMixer(javax.sound.sampled.Mixer m)
m - New mixer to use.public boolean attachBuffer(SoundBuffer buffer)
buffer - SoundBuffer containing the wave data and format to attach
public void setAudioFormat(javax.sound.sampled.AudioFormat audioFormat)
setAudioFormat in class ChannelaudioFormat - Format to use when playing the stream data.public boolean resetStream(javax.sound.sampled.AudioFormat format)
format - Format to use when playing the stream data.
public void setLooping(boolean value)
value - Loop or not.public void setPan(float p)
p - Pan value to use.public void setGain(float g)
g - Gain value to use.public void setPitch(float p)
p - Float value between 0.5f and 2.0f.public boolean preLoadBuffers(java.util.LinkedList<byte[]> bufferList)
preLoadBuffers in class ChannelbufferList - List of the first buffers to be played for a streaming source.
public boolean queueBuffer(byte[] buffer)
queueBuffer in class Channelbuffer - The next buffer to be played for a streaming source.
public boolean processBuffer()
StreamThread.
processBuffer in class Channelpublic int feedRawAudioData(byte[] buffer)
feedRawAudioData in class Channelbuffer - Buffer containing raw audio data to stream.
public int buffersProcessed()
buffersProcessed in class Channelpublic void flush()
flush in class Channelpublic void close()
close in class Channelpublic void play()
play in class Channelpublic void pause()
pause in class Channelpublic void stop()
stop in class Channelpublic void rewind()
rewind in class Channelpublic float millisecondsPlayed()
millisecondsPlayed in class Channelpublic boolean playing()
playing in class Channel
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||