|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectpaulscode.sound.MidiChannel
public class MidiChannel
The MidiChannel class provides an interface for playing MIDI files, using
the JavaSound API. For more information about the JavaSound API, visit
http://java.sun.com/products/java-media/sound/
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 | |
|---|---|
protected float |
fadeInGain
Specifies the gain factor used for the fade-in effect, or 1 when playback is not currently fading in. |
protected long |
fadeInMilis
Specifies the number of miliseconds it should take to fade in. |
protected float |
fadeOutGain
Specifies the gain factor used for the fade-out effect, or -1 when playback is not currently fading out. |
protected long |
fadeOutMilis
Specifies the number of miliseconds it should take to fade out. |
protected long |
lastFadeCheck
System time in miliseconds when the last fade in/out volume check occurred. |
| Constructor Summary | |
|---|---|
MidiChannel(boolean toLoop,
java.lang.String sourcename,
FilenameURL midiFilenameURL)
Constructor: Defines the basic source information. |
|
MidiChannel(boolean toLoop,
java.lang.String sourcename,
java.lang.String filename)
Constructor: Defines the basic source information. |
|
MidiChannel(boolean toLoop,
java.lang.String sourcename,
java.net.URL midiFile,
java.lang.String identifier)
Constructor: Defines the basic source information. |
|
| Method Summary | |
|---|---|
void |
cleanup()
Shuts the channel down and removes references to all instantiated objects. |
void |
dequeueSound(java.lang.String filename)
Removes the first occurrence of the specified filename/identifier from the list of MIDI sequences to play when the previous sequence ends. |
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. |
void |
fadeOut(FilenameURL filenameURL,
long milis)
Fades out the volume of whatever sequence is currently playing, then begins playing the specified MIDI file at the previously assigned volume level. |
void |
fadeOutIn(FilenameURL filenameURL,
long milisOut,
long milisIn)
Fades out the volume of whatever sequence is currently playing, then fades the volume back in playing the specified MIDI file. |
java.lang.String |
getFilename()
Returns the filename/identifier of the MIDI file being played. |
FilenameURL |
getFilenameURL()
Returns the MIDI file being played. |
boolean |
getLooping()
Returns the value of boolean 'toLoop'. |
java.lang.String |
getSourcename()
Returns the unique identifier for this source. |
float |
getVolume()
Returns the current volume for the MIDI source. |
protected void |
importantMessage(java.lang.String message)
Prints an important message. |
boolean |
loading()
Check if a MIDI file is in the process of loading. |
protected void |
message(java.lang.String message)
Prints a message. |
void |
meta(javax.sound.midi.MetaMessage message)
Called when MIDI events occur. |
void |
pause()
Temporarily stops playback without rewinding. |
void |
play()
Plays the MIDI file from the beginning, or from where it left off if it was paused. |
protected void |
printStackTrace(java.lang.Exception e)
Prints an exception's error message followed by the stack trace. |
void |
queueSound(FilenameURL filenameURL)
Queues up the next MIDI sequence to play when the previous sequence ends. |
void |
resetGain()
Resets playback volume to the correct level. |
void |
rewind()
Returns playback to the beginning. |
void |
setFilenameURL(FilenameURL value)
Defines which MIDI file to play. |
void |
setLooping(boolean value)
Sets the value of boolean 'toLoop'. |
void |
setSourcename(java.lang.String value)
Defines the unique identifier for this source |
void |
setVolume(float value)
Changes the volume of MIDI playback. |
void |
stop()
Stops playback and rewinds to the beginning. |
void |
switchSource(boolean toLoop,
java.lang.String sourcename,
FilenameURL filenameURL)
Changes the basic information about the MIDI source. |
void |
switchSource(boolean toLoop,
java.lang.String sourcename,
java.lang.String filename)
Changes the basic information about the MIDI source. |
void |
switchSource(boolean toLoop,
java.lang.String sourcename,
java.net.URL midiFile,
java.lang.String identifier)
Changes the basic information about the MIDI source. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected float fadeOutGain
protected float fadeInGain
protected long fadeOutMilis
protected long fadeInMilis
protected long lastFadeCheck
| Constructor Detail |
|---|
public MidiChannel(boolean toLoop,
java.lang.String sourcename,
java.lang.String filename)
toLoop - Should playback loop or play only once?sourcename - Unique identifier for this source.filename - Name of the MIDI file to play.
public MidiChannel(boolean toLoop,
java.lang.String sourcename,
java.net.URL midiFile,
java.lang.String identifier)
toLoop - Should playback loop or play only once?sourcename - Unique identifier for this source.midiFile - URL to the MIDI file to play.identifier - Filename/identifier for the MIDI file.
public MidiChannel(boolean toLoop,
java.lang.String sourcename,
FilenameURL midiFilenameURL)
toLoop - Should playback loop or play only once?sourcename - Unique identifier for this source.midiFilenameURL - Filename/URL to the MIDI file to play.| Method Detail |
|---|
public void cleanup()
public void queueSound(FilenameURL filenameURL)
filenameURL - MIDI sequence to play next.public void dequeueSound(java.lang.String filename)
filename - Filename or identifier of a MIDI sequence to remove from the
queue.
public void fadeOut(FilenameURL filenameURL,
long milis)
filenameURL - MIDI file to play next, or null for none.milis - Number of miliseconds the fadeout should take.
public void fadeOutIn(FilenameURL filenameURL,
long milisOut,
long milisIn)
filenameURL - MIDI file to play next, or null for none.milisOut - Number of miliseconds the fadeout should take.milisIn - Number of miliseconds the fadein should take.public void play()
public void stop()
public void pause()
public void rewind()
public void setVolume(float value)
value - Float value (0.0f - 1.0f).public float getVolume()
public void switchSource(boolean toLoop,
java.lang.String sourcename,
java.lang.String filename)
toLoop - Should playback loop or play only once?sourcename - Unique identifier for this source.filename - Name of the MIDI file to play.
public void switchSource(boolean toLoop,
java.lang.String sourcename,
java.net.URL midiFile,
java.lang.String identifier)
toLoop - Should playback loop or play only once?sourcename - Unique identifier for this source.midiFile - URL to the MIDI file to play.identifier - Filename/identifier for the MIDI file.
public void switchSource(boolean toLoop,
java.lang.String sourcename,
FilenameURL filenameURL)
toLoop - Should playback loop or play only once?sourcename - Unique identifier for this source.filenameURL - Filename/URL of the MIDI file to play.public void setLooping(boolean value)
value - True or False.public boolean getLooping()
public boolean loading()
public void setSourcename(java.lang.String value)
value - New source name.public java.lang.String getSourcename()
public void setFilenameURL(FilenameURL value)
value - Path to the MIDI file.public java.lang.String getFilename()
public FilenameURL getFilenameURL()
public void meta(javax.sound.midi.MetaMessage message)
meta in interface javax.sound.midi.MetaEventListenermessage - Meta mssage describing the MIDI event.public void resetGain()
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 | |||||||||