public interface Midi
The tick
represents the position in the sound data.
Example:
final Midi midi = AudioMidi.loadMidi(Media.get("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 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 repeat)
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.
|
static final int VOLUME_MIN
static final int VOLUME_MAX
long getTicks()
void setStart(long tick)
tick
- The starting tick [0 - getTicks()
]
.void setLoop(long first, long last)
first
- The first tick [0 - last}]
.last
- The last tick [first - getTicks()
}]
.void setVolume(int volume)
volume
- The volume in percent [VOLUME_MIN
- VOLUME_MAX
]
.void play(boolean repeat)
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)
.
repeat
- The loop flag.void stop()
void pause()
void resume()