|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectpaulscode.sound.Channel
public class Channel
The Channel class is the base class which can be extended for
library-specific channels. It is also used in the "no-sound" library.
A channel is a reserved sound-card voice through which sources are played
back. Channels can be either streaming channels or normal (non-streaming)
ones. For consistant naming conventions, each sub-class should have the
name prefix "Channel".
SoundSystem 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 | |
|---|---|
Source |
attachedSource
Whatever source is attached to this channel. |
int |
buffersUnqueued
Cumulative counter of the buffers played then unqued. |
int |
channelType
Global identifier for the type of channel (normal or streaming). |
protected java.lang.Class |
libraryType
The library class associated with this type of channel. |
| Constructor Summary | |
|---|---|
Channel(int type)
Constructor: Takes channelType identifier as a paramater. |
|
| Method Summary | |
|---|---|
int |
buffersProcessed()
Returns the number of queued byte[] buffers that have finished playing. |
void |
cleanup()
Shuts the channel down and removes references to all instantiated objects. |
void |
close()
Stops the channel, dequeues any queued data, and closes the channel. |
protected boolean |
errorCheck(boolean error,
java.lang.String message)
Prints the specified message if error is true. |
protected void |
errorMessage(java.lang.String message)
Prints an error message. |
int |
feedRawAudioData(byte[] buffer)
Feeds raw data to the stream. |
void |
flush()
Dequeues all previously queued data. |
java.lang.String |
getClassName()
Returns the name of the class. |
protected void |
importantMessage(java.lang.String message)
Prints an important message. |
protected void |
message(java.lang.String message)
Prints a message. |
float |
millisecondsPlayed()
Calculates the number of milliseconds since the channel began playing. |
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. |
protected void |
printStackTrace(java.lang.Exception e)
Prints an exception's error message followed by the stack trace. |
boolean |
processBuffer()
Plays the next queued byte[] buffer. |
boolean |
queueBuffer(byte[] buffer)
Queues up a byte[] buffer of data to be streamed. |
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 |
stop()
Stops playback for this channel and rewinds the attached source to the beginning. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.Class libraryType
public int channelType
SoundSystemConfig class.
public Source attachedSource
public int buffersUnqueued
| Constructor Detail |
|---|
public Channel(int type)
SoundSystemConfig class.
type - Type of channel (normal or streaming).| Method Detail |
|---|
public void cleanup()
public boolean preLoadBuffers(java.util.LinkedList<byte[]> bufferList)
bufferList - List of the first buffers to be played for a streaming source.
public boolean queueBuffer(byte[] buffer)
buffer - The next buffer to be played for a streaming source.
public int feedRawAudioData(byte[] buffer)
buffer - Buffer containing raw audio data to stream.
public int buffersProcessed()
public float millisecondsPlayed()
public boolean processBuffer()
StreamThread.
public void setAudioFormat(javax.sound.sampled.AudioFormat audioFormat)
public void flush()
public void close()
public void play()
public void pause()
public void stop()
public void rewind()
public boolean playing()
public java.lang.String getClassName()
protected void message(java.lang.String message)
message - Message to print.protected void importantMessage(java.lang.String message)
message - Message to print.
protected boolean errorCheck(boolean error,
java.lang.String message)
error - True or False.message - Message to print if error is true.
protected void errorMessage(java.lang.String message)
message - Message to print.protected void printStackTrace(java.lang.Exception e)
e - Exception containing the information to print.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||