All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lejos.hardware.Audio Maven / Gradle / Ivy

Go to download

leJOS (pronounced like the Spanish word "lejos" for "far") is a tiny Java Virtual Machine. In 2013 it was ported to the LEGO EV3 brick.

The newest version!
package lejos.hardware;

import java.io.File;



public interface Audio extends Sounds
{        
    /**
     * Play a system sound.
     * 
     * 
     * 
     * 
     * 
     * 
     * 
     * 
aCodeResulting Sound
0short beep
1double beep
2descending arpeggio
3ascending arpeggio
4long, low buzz
*/ public void systemSound(int aCode); /** * Plays a tone, given its frequency and duration. * @param aFrequency The frequency of the tone in Hertz (Hz). * @param aDuration The duration of the tone, in milliseconds. * @param aVolume The volume of the playback 100 corresponds to 100% */ public void playTone(int aFrequency, int aDuration, int aVolume); public void playTone(int freq, int duration); /** * Play a wav file * @param file the 8-bit PWM (WAV) sample file * @param vol the volume percentage 0 - 100 * @return The number of milliseconds the sample will play for or < 0 if * there is an error. * @throws FileNotFoundException */ public int playSample(File file, int vol); /** * Play a wav file * @param file the 8-bit PWM (WAV) sample file * @return The number of milliseconds the sample will play for or < 0 if * there is an error. * @throws FileNotFoundException */ public int playSample(File file); /** * Queue a series of PCM samples to play at the * specified volume and sample rate. * * @param data Buffer containing the samples * @param offset Offset of the first sample in the buffer * @param len Number of samples to queue * @param freq Sample rate * @param vol playback volume * @return Number of samples actually queued */ public int playSample(byte [] data, int offset, int len, int freq, int vol); /** * 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. * @param inst Instrument definition * @param freq The note to play (in Hz) * @param len The duration of the note (in ms) */ public void playNote(int[] inst, int freq, int len); /** * Set the master volume level * @param vol 0-100 */ public void setVolume(int vol); /** * Get the current master volume level * @return the current master volume 0-100 */ public int getVolume(); /** * 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. */ public void loadSettings(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy