public final class Midi extends Object
The tick
represents the position in the sound data.
Example:
final Midi midi = AudioMidi.loadMidi(Medias.create("music.mid")); midi.play(false); Thread.sleep(1000); midi.pause(); Thread.sleep(1000); midi.resume(); midi.pause(); midi.stop();
Modifier and Type | Field and Description |
---|---|
static String |
ERROR_MIDI
Error midi.
|
static int |
VOLUME_MAX
Maximum volume value.
|
static int |
VOLUME_MIN
Minimum volume value.
|
Modifier and Type | Method and Description |
---|---|
long |
getTicks()
Get the total number of ticks.
|
void |
pause()
Pause the music (can be resumed).
|
void |
play(boolean loop)
Play the music.
|
void |
resume()
Resume the music (if paused).
|
void |
setLoop(long first,
long last)
Set loop area in tick.
|
void |
setStart(long tick)
Set starting tick (starting music position).
|
void |
setVolume(int volume)
Set the midi volume.
|
void |
stop()
Stop the music.
|
public static final int VOLUME_MIN
public static final int VOLUME_MAX
public static final String ERROR_MIDI
public void play(boolean loop)
The music will be played from the beginning (can be set by setStart(long)
) until the end.
In case of a loop, music will be played in loop between the set ticks using setLoop(long, long)
.
loop
- The loop flag.public void setStart(long tick)
tick
- The starting tick [0 - getTicks()
]
.LionEngineException
- If argument is invalid.public void setLoop(long first, long last)
first
- The first tick [0 - last}]
.last
- The last tick [first - getTicks()
}]
.LionEngineException
- If arguments are invalid.public void setVolume(int volume)
volume
- The volume in percent [VOLUME_MIN
- VOLUME_MAX
]
.LionEngineException
- If argument is invalid or midi not available.public long getTicks()
public void stop()
public void pause()
public void resume()
Copyright © 2016 Byron 3D Games Studio. All rights reserved.