1.playing audio in java
Java sound API(package javax.sound) supports two types of audios:
- sampled audio
- musical instrument digital interface(MIDI)
sampled audio:
In the sampled audio ,the supported file formats are: AIFC,AIFF,WAVE,SND,AU and doesn\'t
support the audio format MP3.
Provide two ways to play the audio: using clip and using source data line
using clip : (javax.sound.sampled.clip) used to play a short sound file.
In this method the whole audio clip is loaded into the memoryto have control over audio clip
before playing it.
steps for playing the audio file:
1. create an audioInputStream for a given sound file.
2. acquire audio format and create DataLine.Info Object
3.Obtain the clip
4.open the AudioInputStream ,start playing
5.close the resource acquired
using source data line :(javax.sound.sampled.SourceDataLine),used to play the long sound line.
these type of sounds cant be preloaded into the memory so, the data is read into the buffer in the
form of bytes repeatedly.
steps for playing the audio file:
1. open the sorce data file similarly by creating,acquiring and obtaining as in clip.
2. open and start the sound file
3. repeatedly read a chunk of bytes from the AudioInputStream and send it to the
SourceDataLine\'s buffer untill reaching the end f the file
4.close the resource acquired.
Musical Instrument Digital Interface(MIDI): music is synthesized from special nodes and effects.
steps for playing the audio:
1. allocate a sequence piped from a MIDI file
2. allocate a sequencer to play a MIDI sequence
3. set the current sequence for the sequencer to play
4. open the sequencer to load the sequence.
5. set the loop count by using SetLoopCount() and start playing the music by using start()
6. stop the play using stop().
2. creating a timer:
the Timer is provided in the java.util package.
In which we create an instance for thread like
Thread thread= new Thread();
then using this instance thread we use the sleep() available in the timer class as follows:
thread.sleep();
here the arguments int the sleep() is nothing but the time in milli seconds for example:
thread.sleep(2000) will sleep the process execution or triggering for 20 seconds.
BLanks:
1.
actionPerformed() in the Listener interface
2.
3.
close()
4.
5.
scope
Solution
1.playing audio in java
Java sound API(package javax.sound) supports two types of audios:
- sampled audio
- musical instrument digital interface(MIDI)
sampled audio:
In the sampled audio ,the supported file formats are: AIFC,AIFF,WAVE,SND,AU and doesn\'t
support the audio format MP3.
Provide two ways to play the audio: using clip and using source data line
using clip : (javax.sound.sampled.clip) used to play a short sound file.
In this method the whole audio clip is loaded into the memoryto have control over audio clip
before playing it.
steps for playing the audio file:
1. create an audioInputStream for a given sound file.
2. acquire audio format and create DataLine.Info Object
3.Obtain the clip
4.open the A.
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
1.playing audio in javaJava sound API(package javax.sound) support.pdf
1. 1.playing audio in java
Java sound API(package javax.sound) supports two types of audios:
- sampled audio
- musical instrument digital interface(MIDI)
sampled audio:
In the sampled audio ,the supported file formats are: AIFC,AIFF,WAVE,SND,AU and doesn't
support the audio format MP3.
Provide two ways to play the audio: using clip and using source data line
using clip : (javax.sound.sampled.clip) used to play a short sound file.
In this method the whole audio clip is loaded into the memoryto have control over audio clip
before playing it.
steps for playing the audio file:
1. create an audioInputStream for a given sound file.
2. acquire audio format and create DataLine.Info Object
3.Obtain the clip
4.open the AudioInputStream ,start playing
5.close the resource acquired
using source data line :(javax.sound.sampled.SourceDataLine),used to play the long sound line.
these type of sounds cant be preloaded into the memory so, the data is read into the buffer in the
form of bytes repeatedly.
steps for playing the audio file:
1. open the sorce data file similarly by creating,acquiring and obtaining as in clip.
2. open and start the sound file
3. repeatedly read a chunk of bytes from the AudioInputStream and send it to the
SourceDataLine's buffer untill reaching the end f the file
4.close the resource acquired.
Musical Instrument Digital Interface(MIDI): music is synthesized from special nodes and effects.
steps for playing the audio:
1. allocate a sequence piped from a MIDI file
2. allocate a sequencer to play a MIDI sequence
3. set the current sequence for the sequencer to play
4. open the sequencer to load the sequence.
5. set the loop count by using SetLoopCount() and start playing the music by using start()
6. stop the play using stop().
2. creating a timer:
2. the Timer is provided in the java.util package.
In which we create an instance for thread like
Thread thread= new Thread();
then using this instance thread we use the sleep() available in the timer class as follows:
thread.sleep();
here the arguments int the sleep() is nothing but the time in milli seconds for example:
thread.sleep(2000) will sleep the process execution or triggering for 20 seconds.
BLanks:
1.
actionPerformed() in the Listener interface
2.
3.
close()
4.
5.
scope
Solution
1.playing audio in java
Java sound API(package javax.sound) supports two types of audios:
- sampled audio
- musical instrument digital interface(MIDI)
sampled audio:
In the sampled audio ,the supported file formats are: AIFC,AIFF,WAVE,SND,AU and doesn't
support the audio format MP3.
Provide two ways to play the audio: using clip and using source data line
using clip : (javax.sound.sampled.clip) used to play a short sound file.
In this method the whole audio clip is loaded into the memoryto have control over audio clip
before playing it.
steps for playing the audio file:
1. create an audioInputStream for a given sound file.
2. acquire audio format and create DataLine.Info Object
3.Obtain the clip
4.open the AudioInputStream ,start playing
5.close the resource acquired
3. using source data line :(javax.sound.sampled.SourceDataLine),used to play the long sound line.
these type of sounds cant be preloaded into the memory so, the data is read into the buffer in the
form of bytes repeatedly.
steps for playing the audio file:
1. open the sorce data file similarly by creating,acquiring and obtaining as in clip.
2. open and start the sound file
3. repeatedly read a chunk of bytes from the AudioInputStream and send it to the
SourceDataLine's buffer untill reaching the end f the file
4.close the resource acquired.
Musical Instrument Digital Interface(MIDI): music is synthesized from special nodes and effects.
steps for playing the audio:
1. allocate a sequence piped from a MIDI file
2. allocate a sequencer to play a MIDI sequence
3. set the current sequence for the sequencer to play
4. open the sequencer to load the sequence.
5. set the loop count by using SetLoopCount() and start playing the music by using start()
6. stop the play using stop().
2. creating a timer:
the Timer is provided in the java.util package.
In which we create an instance for thread like
Thread thread= new Thread();
then using this instance thread we use the sleep() available in the timer class as follows:
thread.sleep();
here the arguments int the sleep() is nothing but the time in milli seconds for example:
thread.sleep(2000) will sleep the process execution or triggering for 20 seconds.
BLanks:
1.
actionPerformed() in the Listener interface
2.
3.
close()
4.
5.
scope