public class MidiChannel extends Object implements MetaEventListener
| Modifier and Type | Field and Description |
|---|---|
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 and Description |
|---|
MidiChannel(boolean toLoop,
String sourcename,
FilenameURL midiFilenameURL)
Constructor: Defines the basic source information.
|
MidiChannel(boolean toLoop,
String sourcename,
String filename)
Constructor: Defines the basic source information.
|
MidiChannel(boolean toLoop,
String sourcename,
URL midiFile,
String identifier)
Constructor: Defines the basic source information.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cleanup()
Shuts the channel down and removes references to all instantiated objects.
|
void |
dequeueSound(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,
String message)
Prints the specified message if error is true.
|
protected void |
errorMessage(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.
|
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'.
|
String |
getSourcename()
Returns the unique identifier for this source.
|
float |
getVolume()
Returns the current volume for the MIDI source.
|
protected void |
importantMessage(String message)
Prints an important message.
|
boolean |
loading()
Check if a MIDI file is in the process of loading.
|
protected void |
message(String message)
Prints a message.
|
void |
meta(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(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(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,
String sourcename,
FilenameURL filenameURL)
Changes the basic information about the MIDI source.
|
void |
switchSource(boolean toLoop,
String sourcename,
String filename)
Changes the basic information about the MIDI source.
|
void |
switchSource(boolean toLoop,
String sourcename,
URL midiFile,
String identifier)
Changes the basic information about the MIDI source.
|
protected float fadeOutGain
protected float fadeInGain
protected long fadeOutMilis
protected long fadeInMilis
protected long lastFadeCheck
public MidiChannel(boolean toLoop,
String sourcename,
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,
String sourcename,
URL midiFile,
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,
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.public void cleanup()
public void queueSound(FilenameURL filenameURL)
filenameURL - MIDI sequence to play next.public void dequeueSound(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,
String sourcename,
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,
String sourcename,
URL midiFile,
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,
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(String value)
value - New source name.public String getSourcename()
public void setFilenameURL(FilenameURL value)
value - Path to the MIDI file.public String getFilename()
public FilenameURL getFilenameURL()
public void meta(MetaMessage message)
meta in interface MetaEventListenermessage - Meta mssage describing the MIDI event.public void resetGain()
protected void message(String message)
message - Message to print.protected void importantMessage(String message)
message - Message to print.protected boolean errorCheck(boolean error,
String message)
error - True or False.message - Message to print if error is true.protected void errorMessage(String message)
message - Message to print.protected void printStackTrace(Exception e)
e - Exception containing the information to print.Copyright © 2017. All rights reserved.