Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## lejos.nxt
Class Sound

    java.lang.Object
      lejos.nxt.Sound

    public class Sound

extends Object

NXT sound routines.

Field Summary
`static int` | `C2` Play a system sound.
`static int[]` | `FLUTE`
`static int[]` | `PIANO`
`static int` | `VOL_MAX`
`static String` | `VOL_SETTING`
`static int[]` | `XYLOPHONE`

Method Summary
`static void` | `beep()` Beeps once.
`static void` | `beepSequence()` Downward tones.
`static void` | `beepSequenceUp()` Upward tones.
`static void` | `buzz()` Low buzz
`static int` | `getTime()` Returns the number of milliseconds remaining of the current tone or sample.
`static int` | `getVolume()` Get the current master volume level
`static void` | `loadSettings()` Load the current system settings associated with this class.
`static void` | `pause(int t)`
`static void` | `playNote(int[] inst, int freq, int len)` Play a note with attack, decay, sustain and release shape.
`static int` | `playSample(File file)` Play a wav file
`static int` | `playSample(File file, int vol)` Play a wav file
`static void` | `playTone(int freq, int duration)`
`static void` | `playTone(int aFrequency, int aDuration, int aVolume)` Plays a tone, given its frequency and duration.
`static void` | `setVolume(int vol)` Set the master volume level
`static void` | `systemSound(boolean aQueued, int aCode)`
`static void` | `twoBeeps()` Beeps twice.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait`

Field Detail

### VOL_MAX

    public static final int VOL_MAX

See Also:
  Constant Field Values

### VOL_SETTING

    public static final String VOL_SETTING

See Also:
  Constant Field Values

### PIANO

    public static final int[] PIANO

### FLUTE

    public static final int[] FLUTE

### XYLOPHONE

    public static final int[] XYLOPHONE

### C2

    public static int C2

  Play a system sound.

  aCode | Resulting Sound
  --- | ---
  0 | short beep
  1 | double beep
  2 | descending arpeggio
  3 | ascending arpeggio
  4 | long, low buzz

Method Detail

### systemSound

    public static void systemSound(boolean aQueued,
                                   int aCode)

### beep

    public static void beep()

  Beeps once.

### twoBeeps

    public static void twoBeeps()

  Beeps twice.

### beepSequence

    public static void beepSequence()

  Downward tones.

### beepSequenceUp

    public static void beepSequenceUp()

  Upward tones.

### buzz

    public static void buzz()

  Low buzz

### pause

    public static void pause(int t)

### getTime

    public static int getTime()

  Returns the number of milliseconds remaining of the current tone or sample.

  Returns:
    milliseconds remaining

### playTone

    public static void playTone(int aFrequency,
                                int aDuration,
                                int aVolume)

  Plays a tone, given its frequency and duration.

  Parameters:
    `aFrequency` - The frequency of the tone in Hertz (Hz).
    `aDuration` - The duration of the tone, in milliseconds.
    `aVolume` - The volume of the playback 100 corresponds to 100%

### playTone

    public static void playTone(int freq,
                                int duration)

### playSample

    public static int playSample(File file,
                                 int vol)

  Play a wav file

  Parameters:
    `file` - the 8-bit PWM (WAV) sample file
    `vol` - the volume percentage 0 - 100
  Returns:
    The number of milliseconds the sample will play for or < 0 if there is an error.

### playSample

    public static int playSample(File file)

  Play a wav file

  Parameters:
    `file` - the 8-bit PWM (WAV) sample file
  Returns:
    The number of milliseconds the sample will play for or < 0 if there is an error.

### playNote

    public static void playNote(int[] inst,
                                int freq,
                                int len)

  Play a note with attack, decay, sustain and release shape. This function allows the playing of a more musical sounding note. It uses a set of supplied "instrument" parameters to define the shape of the notes envelope.

  Parameters:
    `inst` - Instrument definition
    `freq` - The note to play (in Hz)
    `len` - The duration of the note (in ms)

### setVolume

    public static void setVolume(int vol)

  Set the master volume level

  Parameters:
    `vol` - 0-100

### getVolume

    public static int getVolume()

  Get the current master volume level

  Returns:
    the current master volume 0-100

### loadSettings

    public static void loadSettings()

  Load the current system settings associated with this class. Called automatically to initialize the class. May be called if it is required to reload any settings.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD