sound : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

sound
The official Java sound interface is called JMF. It can play many audio and video file formats including MP3. The catch is, the user has to download and hook up the JMF (Java Media Framework) jar files to make it work. So you might want something simpler.
Introduction Sound Files Used On This Site
Playing A Sound with javax.sound.sampled Canned Sound Sources
Applet Sound with java.applet.AudioClip Learning More
Synthesizing Sound Mathematically Links
Common Sound File Types

Introduction

I have posted some source code to create sounds mathematically, i.e. create AU files in RAM (Random Access Memory) and play them with sun.audio.AudioPlayer.start. If you feed it a Math.sin wave for example you will hear a smooth continuous tone of the same frequency as the sine wave. You can create any theoretically possible sound. All you need is a way of mathematically describing it, or providing a list of amplitudes. sun.audio is not an official class. It is accessible in Applets in Java version 1.1, not in JDK (Java Development Kit) 1.2, but is now back again in JDK 1.4.

The Java Sound engine can render 8 or 16-bit audio data, in mono or stereo, with sample rates from 8KHz to 48KHz, that might be found in streaming audio or any of the supported file formats. You can also play *.au, *.wav, *.midi (SMP 0, SMF (Standard MIDI Format) 1 and RMP (RealPlayer Metadata Package)) and *.aiff files with java.applet. AudioClip. play. For *.au files use G.711 µ-law format did not originally support PCM (Pulse-Code Modulation). Originally, you could use only 8-bit, 8000 Hz (Hertz), single-channel (mono) NEXT/Sun *.au files with G.711 µ-law compression. However JDK 1.8.0_131+ does play PCM_SIGNED 8000.0 Hz, 8-bit, 64 kpbs, mono. Java supports only 8 KHz to 48 KHz.

In my Vercheck app, I used Sun PCM_SIGNED 8000.0 Hz, 8-bit, 64 kpbs, mono.

If your files are in other formats such as *.mp3, you can use a utility like Goldwave to convert them. Unfortunately, not all *.wav files or all *.midi files will play. You just have to test them.

Using AudioClip, I have managed to get *.wav and *.au files to work on Vista, but not *.midi or *.mp3.

RealPlayer is required for *.ra files. AudioClip has been around since JDK 1.0.

You can use javax.sound.midi to play MIDI (Musical Instrument Digital Interface) files. It has been around since JDK 1.3.

You can use javax.sound.sampled.SourceDataLine can be used to merge sampled datastreams and play a variety of sound files. It has been around since JDK 1.3.

Playing A Sound with javax.sound.sampled

This technique works both in Applets and applications. It is suitable also for very large sound files. This code will let you play sound in the background while your program continues computing and responding to GUI (Graphic User Interface) events. Possible formats include AudioFormat.Encoding. PCM_SIGNED, PCM_UNSIGNED, ULAW and ALAW. PCM is the most widely supported. It is simple linear sampling without any sort of compression. CDs (Compact Discs) use 16-bit PCM. Possible file types include: AudioFileFormat. Type. AIFC, AIFF (Audio Interchange File Format), AU, SND and WAVE. Third parties can add support for other types, e.g. MP3. I have a horrible feeling that what is supported depends entirely on the capabilities of the native sound driver on any particular platform. This is not at all WORA (Write Once, Run Anywhere). You can find out a bit of what your current platform support with code like this:

Applet Sound with java.applet.AudioClip

Applets can play *.au files, (and *.wav files in Windows) this way: AudioClip.play

is not very bright. If you call it while a sound is playing, it will not wait for that first sound to complete. It plays the two sounds on top of each other.

Here is a technique to introduce time delays to avoid overlap.

In a similar way, you can use javax.sound.midi to play midi files.

Synthesizing Sound Mathematically

Common Sound File Types

Audio Format MIME Type And Extensions Associated With Them
Extension MIME Type Alternate MIME Types Notes
3gppaudio/3gp audio only, also 3gp
aacaudio/aacaudio/MP4-LATM, audio/x-aac, audio/x-mp4Apple QuickTime compressed audio used in iPods
aifaudio/x-aiff MacIntosh sound
aifcaudio/x-aiff MacIntosh sound
aiffaudio/x-aiff MacIntosh uncompressed sound
asfvideo/x-ms-asf Microsoft media audio and/or video
auaudio/basicaudio/x-pn-austandard Unix/Internet/Java uncompressed wave sound
avivideo/avivideo/x-msvideoearlier Microsoft video format. avi movie, works with Winamp (best), MS Media Player (often audio only), or QuickTime (in theory)
chtaudio/x-dspeech  
dusaudio/x-dspeech  
esaudio/echospeech  
gsdaudio/gsm  
gsmaudio/gsm  
karaudio/midi  
m3uaudio/x-mpegurl redirect to audio url
m4aaudio/mp4 MPEG-4 Audio
m4uaudio/x-mpegurlvideo/vnd.mpegurlredirect to audio url
midaudio/x-midiaudio/midiMIDI sound
midiaudio/x-midiaudio/midiMIDI sound
mp2audio/mpegaudio/x-mpeg 
mp3audio/mp3audio/mpeg, audio/x-mp3, audio/x-mpgmp3/mpeg compressed audio. Popular format for portable music players.
mp4video/mp4  
mpegvideo/mpeg mpeg movie player
mpgaaudio/mpeg  
ogaaudio/ogg Ogg audio
oggaudio/x-oggvorbisapplication/oggencapsulation for Vorbis I non-proprietary audio or video.
ogxapplication/ogg muliplex ogg stream
raaudio/x-pn-realaudio Real Audio
ramaudio/x-pn-realaudio Real Audio
rmaudio/x-pn-realaudioapplication/vnd.rn-realmediaReal Audio
rmfaudio/rmfaudio/x-rmf 
rmmaudio/x-pn-realaudio  
rmpapplication/vnd.rn-rn_music_package RealPlayer Metadata Package File, playlist
rmsaudio/x-realaudio-secure  
rpmaudio/x-pn-realaudio-plugin Real Audio
sndaudio/basic standard Internet/Java wave sound
soundpackapplication/octet-stream Stardock Windows audio themes
streamaudio/x-qt-stream  
tsiaudio/tsplayer  
voxaudio/voxware  
vqeaudio/x-twinvq-plugin  
vqfaudio/x-twinvq  
vqlaudio/x-twinvq  
wavaudio/wavaudio/x-pn-windows-pcm, audio/x-wavMicrosoft wave uncompressed sound files
waxaudio/x-ms-wax Microsoft compressed audio
wmaaudio/x-ms-wma Microsoft compressed audio
wmvvideo/x-ms-wmv Microsoft compressed video. Play with Windows media Player or Winamp. Winamp lets you slide forward and back.
wtxaudio/wtx  
xamlapplication/xaml+xml Silverlight

Sound Files Used On This Site

Audio Links Legend
streaming or downloadable
Click corresponding icon to download player.
Real Audio click to listen
Flash click to listen
compressed mp3 click to listen
super compressed mp4 click to listen
Microsoft Media Player click to listen
MIDI music files click to listen
uncompressed au click to listen
Microsoft uncompressed wav click to listen
unknown click to listen
lyrics click to listen
transcript click to listen

Canned Sound Sources

Windows stores its *.wav files in C:\WINNT\media\ or C:\Windows\Media\ These are the sound effects you hear on error, on incoming mail etc. I find them easier to configure if you listen to them, then copy them with a name meaningful to you. Ones I find useful for configuring for non-system purposes include:
Euphonious Windows Sounds
Theme Sound Name Where Comments
Afternoon Deskop Mail Notification "C:\Windows\media\Afternoon\Windows Notify.wav" Ding Dong
Afternoon Print Complete "C:\Windows\media\Afternoon\Windows Print complete.wav" Three note guitar riff
Cityscape Critical Battery Alarm "C:\Windows\media\Cityscape\Windows Battery Critical.wav" reminiscent of West Side Story
Cityscape Device Failed to Connect "C:\Windows\media\Cityscape\Windows Hardware Fail.wav" Jazzy
Delta Low Battery Alarm "C:\Windows\media\Delta\Windows Battery Low.wav" reminiscent of dueling banjos
Festival Exclamation "C:\Windows\media\Festival\Windows Exclamation.wav" Mariachi trumpet fanfare
Garden Critical Stop "C:\Windows\media\Garden\Windows Critical Stop.wav" A strum on some primitive stringed instrument.
Heritage Incoming Call "C:\Windows\media\Heritage\Windows Ringin.wav" old fashioned telephone bell.
Landscape Fax Sent C:\Windows\media\Landscape\tada.wav ta-da!
Quirky Print Complete "C:\Windows\media\Quirky\Windows Print complete.wav" Star Treky sound
Raga Critical Stop "C:\Windows\media\Raga\Windows Critical Stop.wav" brrrr plop
Savanna Default Beep "C:\Windows\media\Savanna\Windows Ding.wav" Balalaika strike
Sonata Print Complete "C:\Windows\media\Sonata\Windows Print complete.wav" pizzicato

Of course, you can scan the net for WAV files to replace the Microsoft sounds, e.g. HAL (Heuristic Algorithmic) saying human error. Keep in mind, when you change themes, your sounds may be replaced too.

Here are some places where you can find canned sounds: SoundAmerica, Sound collection links. Vista no longer comes with a rich set of sounds, so you have to find them on the web.

Windows 10 comes with a nice assortment of visual themes and sound themes including:

Windows 10 Sound Schemes
Name Where What It Sounds Like
Afternoon C:\Windows\media\Afternoon\ acoustic guitar
Calligraphy C:\Windows\media\Calligraphy\ Chinese instruments
Characters C:\Windows\media\Characters\ electric guitar
Cityscape C:\Windows\media\Cityscape\ vibraphone
Delta C:\Windows\media\Delta\ Mississippi
Festival C:\Windows\media\Festival\ trumpet
Garden C:\Windows\media\Garden\ chimes
Heritage C:\Windows\media\Heritage\ Spanish guitar
Landscape C:\Windows\media\Landscape\ symphonic
Quirky C:\Windows\media\Quirky\ electronic
Raga C:\Windows\media\Raga\ sitar
Savanna C:\Windows\media\Savanna\ pizzicato
Sonata C:\Windows\media\Sonata\ violins

Learning More

download
Oracle’s Javadoc on javax.sound.midi package : available:
Oracle’s Javadoc on javax.sound.sampled package : available:
download sound demo
Oracle’s Javadoc on AudioFormat class : available:
Oracle’s Javadoc on AudioInputStream class : available:
Oracle’s Javadoc on AudioSystem class : available:
Oracle’s Javadoc on DataLine class : available:
Oracle’s Javadoc on SourceDataLine class : available:
Oracle’s Javadoc on Mixer.getSourceLineInfo : available:
Oracle’s Javadoc on Line.Info : available:
AU
AudioMicro: clips for $9 each
AudioMicro: free sound clips
AudioSparx.com: sound effect clips typically $5 each
beep
Chorus Experimenter student project
ClipStream
Crescendo
Find Sounds: search engine for sound clips. Shows and plays sounds it finds
Freedom Audio
FreeSound: free to use sounds in any way want if you give attribution
FreeSoundEffects.com
Goldwave
GrSites: free sound clips
Honk: a windows utility to generate sounds from the Windows command line
HONK: command line sound utility
IMF
Into to javax.media.sound API
javax.media.sound FAQ
JavaZoom JavaLayer MP3 player
JavaZoom JGui: plays WAV, AU, AIFF) VORBIS, FLAC, MONKEY’s AUDIO and SPEEX audio formats
JavaZoom vorbis OGG player
JMF: JMF
JSAPI
MIDI
MIME
MP-3
Opera browser: good for downloading sounds
PacDV: free sound clips
Partners in Rhyme: free and pay sound clips
Philharmonia orchestra sound samples
Real Audio
Rhythm Tutor Student Project
sound-on-the-fly
SoundBible: free clips
Soundbite
SoundJay: free sound clips
Speaker: make tones on the built-in PC) Speaker from Java
Stonewashed: free sound clips
Sun Java Sound home
Tritonus: Java sound API alternative implementation
wav

This page is posted
on the web at:

http://mindprod.com/jgloss/sound.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\sound.html
Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

IP:[65.110.21.43]
Your face IP:[54.205.179.155]
You are visitor number