Java Audio Demos

This page consists of some trivial Java audio demos.
Ptolemy users might find the below interesting if they want to put audio from Ptolemy Demos on web pages. Ideally, we would like to have streaming realtime audio from a Ptolemy simulation.

Remote links:

  • Javasoft Tutorial about Applet Sound
  • Javasoft Java Media Framework (JMF) API - Java Sounds API Intel JMF (Note that Intel is no longer working on the JMF)
  • Information about Audio on Suns
  • Goldwave - A commercial audio tool for windows.
  • Au Format info
  • The buttons below were based on code grabbed from: http://www.dstc.qut.edu.au/~gough/itb445/sourcebook/SoundPlayTest.java
  • Other Ptolemy Group Java Code
  • Gamelan has a good list of multimedia sound applets and applications, below are some interesting ones.
  • Java wav2au converter application (not applet)
  • Rainbow tune player applet
  • Vocoder application
  • Synthesizer application
  • The Playing Wave: plays real time calculated audio.
  • Edward Lee's EECS20 Page
  • FFT Applet with sliders and plotter - Other FFT source code
  • Limitations

  • JDK1.1 can't deal with .wav files The UhOh button should play sounds/uh-oh.wav. I get a NativeAudioStream: invalid file type. http://www.javasoft.com/nav/read/Tutorial/applet/ui/sound.html says:
    Currently, the Java API supports only one sound format: 8 bit, u-law, 8000 Hz, one-channel, Sun ".au" files. You can create these on a Sun workstation using the audiotool application. You can convert files from other sound formats using an audio format conversion program.
  • The Java Programmer's FAQ says

    8.1 Why won't my audio file play?

      A. Java 1.1 and earlier releases use one audio format exclusively. The audio file must be in .au format, recorded at 8 KHz, mono, in mu-law encoding. If your audio clip is in a different format (e.g., .wav) or a different frequency it must be converted to the exact specifications above before Java can play it. Support for .wav and other formats is part of the Java Media Framework coming in JDK 1.2.

      Search at www.yahoo.com for GoldWave for Win 95, sox for Unix and similar conversion utilities for other systems. One conversion utility in Java is at http://saturn.math.uaa.alaska.edu/~hursha

    8.4 How do I play video in Java?

    8.5 How can I play *.au files from an application?

      A. You've got 2 options:

        a. Use the AudioClip class in sun.audio

        If you take this option, you can only play AU files. Worse, your code is no longer 100% pure Java, as it relies on a vendor library.

        b. Use the new Java Media Framework API, allowing a wide range of video and audio formats to be played back. See previous question for implementations of this.


  • sun.audio.*

  • sun.audio documentation
  • The Playing Wave applet, which plays real time calculated audio uses the sun.audio.*
  • See Why Developers Should Not Write Programs That Call 'sun' Packages on www.javasoft.com

  • The Java Media Mail archive has a thread about using sun.audio in an application to read from a file and pack into a byte array.

  • JDK1.2

    http://java.sun.com/products/jdk/1.2/docs/guide/sound/index.html says:

    Audio enhancements include a new sound engine and support for audio in applications as well as applets.

    Java Sound supports the following audio file formats: AIFF, AU and WAV. It also supports the following MIDI based song file formats: TYPE 0 MIDI, TYPE 1 MIDI and RMF.

    Java Sound 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.

    This release includes the following new method in the class java.applet.Applet. This method enables applications to create AudioClips without requiring an AppletContext.

             public static final AudioClip newAudioClip(URL r)
    

    Descriptions of the sounds


    If your browser recognized the applet tag, you would see an applet here.
    Some boring guy talking about Sun audio for far too long.
    A very small train (.au format)
    A .wav that does not work.
    Raw u-law SDF Ptolemy0.6 file with no header that probably won't work.
    u-law SDF Ptolemy0.6 output that had a header tacked on with
    raw2audio < blockVox.au > blockVoxraw2audio.au
    
    u-law SDF Ptolemy0.6 output that had a header tacked on with
    sox -t ul -r 8000 blockVox.au -t .au blockVoxsox.au
    
    Ptolemy 0.7 SDF audio file with the right header.