public class Sound extends EV3DevDevice
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
CMD_APLAY |
private static java.lang.String |
CMD_BEEP |
private static java.lang.String |
DISABLED_FEATURE_MESSAGE |
private static Sound |
Instance |
private static Logger |
log |
private static java.lang.String |
SOUND_PATH |
private static java.lang.String |
VOLUME |
private static java.lang.String |
VOLUME_PATH |
ADDRESS, DEVICE, LEGO_PORT, LEGO_SENSOR, MODE, PATH_DEVICE
EV3DEV_ROOT_PATH, EV3DEV_TESTING_KEY, ROOT_PATH
Modifier | Constructor and Description |
---|---|
private |
Sound() |
Modifier and Type | Method and Description |
---|---|
void |
beep()
Beeps once.
|
static Sound |
getInstance()
Return a Instance of Sound.
|
int |
getVolume()
Get the current master volume level
|
void |
playSample(java.io.File file)
Play a wav file.
|
void |
playSample(java.io.File file,
int volume)
Play a wav file.
|
void |
playTone(int frequency,
int duration)
Plays a tone, given its frequency and duration.
|
void |
playTone(int frequency,
int duration,
int volume)
Plays a tone, given its frequency and duration.
|
void |
setVolume(int volume)
Set the master volume level
|
void |
twoBeeps()
Beeps twice.
|
detect, getIntegerAttribute, getStringAttribute, setIntegerAttribute, setStringAttribute
getMotorPort, getPlatform, getSensorPort
getROOT_PATH
private static final Logger log
private static final java.lang.String SOUND_PATH
private static final java.lang.String CMD_BEEP
private static final java.lang.String CMD_APLAY
private static final java.lang.String VOLUME
private static final java.lang.String VOLUME_PATH
private static final java.lang.String DISABLED_FEATURE_MESSAGE
private static Sound Instance
public static Sound getInstance()
public void beep()
public void twoBeeps()
public void playTone(int frequency, int duration, int volume)
frequency
- The frequency of the tone in Hertz (Hz).duration
- The duration of the tone, in milliseconds.volume
- The volume of the playback 100 corresponds to 100%public void playTone(int frequency, int duration)
frequency
- The frequency of the tone in Hertz (Hz).duration
- The duration of the tone, in milliseconds.public void playSample(java.io.File file, int volume)
file
- the 8-bit or 16-bit PWM (WAV) sample filevolume
- the volume percentage 0 - 100public void playSample(java.io.File file)
file
- the 8-bit or 16-bit PWM (WAV) sample filepublic void setVolume(int volume)
volume
- 0-100public int getVolume()