Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Can I use Java to generate sound?

Posted on 2001-06-13
6
Medium Priority
?
610 Views
Last Modified: 2010-07-27
Hi, dear experts,

Is it possible to use Java to generate my own sound and
send the sound to either speaker or earphone?  I want to
generate sound of different frequencies and play them.


Thank you.
Yours sincerely
Zicai
0
Comment
Question by:zicai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Expert Comment

by:exorcist
ID: 6185266
take a look at the JMF (Java Media Framework).
0
 
LVL 3

Expert Comment

by:dnoelpp
ID: 6185366
Most simple solution (only play):

AudioClip clip = Applet.newAudioClip(url);
clip.play();

For generating sounds use JMF, as exorcist said. It is really a neat framework. Last year I mimicked a very slow modem (110 bit/sec) via loudspeaker and microphone and did fourier analysis on the recorded sounds. Worked great!
0
 
LVL 1

Accepted Solution

by:
rkumar115 earned 400 total points
ID: 6186699
Java 1.3 provides the Java sound API's which can be used for capturing, processing and playing back audio and MIDI(Musical Instrument Digital Interface) data.

The java Sound web page provides the following information--------

The java Sound API supports the following features:

Audio file formats: AIFF, AU and WAV

Music file formats: MIDI Type 0, MIDI Type 1, and Rich Music Format (RMF)

Sound formats: 8- and 16-bit audio data, in mono and stereo, with sample rates from 8 kHz to 48 kHz  .

Linear, a-law, and mu-law encoded data in any of the supported audio file formats

MIDI wavetable synthesis and sequencing in software, and access to hardware MIDI devices

An all-software mixer that can mix and render up to 64 total channels of digital audio and synthesized MIDI music

he above list describes the reference implementation, not the API itself. The API permits flexible configuration of the audio and MIDI system,including ways for applications to ask the system exactly what resources are installed and available.


There are other java platform APIs that have sound related elements .The JMF(Java Media Framework) is the higher layer API that is currently available as a standard extension to the Java Platform.JMF provides a simpler
solution for basic media-player application programs, and it enables synchronization between different media types, such as audio and video.On the other hand, programs that focus on sound can benefit from the Java Sound API, especially if they require more advanced features, such as
the ability to carefully control buffered audio playback or directly manipulate a MIDI synthesizer. Other Java APIs with sound aspectsinclude Java 3D and APIs for telephony and speech. An implementationof any of these APIs might use an implementation of the Java Sound API internally, but is not required to do so.


The java sound API includes support for both digital video and MIDI data. The functionality for digital video is provided in the package javax.video.sampled
and the functionality for the MIDI is provided in the package javax.sound.midi .


You can get more information in the API programmers guide which is available at the following site
http://java.sun.com/j2se/1.3/docs/guide/sound/


Since java 1.3 provide MIDI you will be able to create the musical sounds and MIDI synthesizers are capable of creating different types of sound.

Hope the above solves your problem
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Author Comment

by:zicai
ID: 6190354
Hi,rkumar115

Do you have some simple samples that can generate sound
and play them? Could you please explain some more on how
to use the MIDI synthesizers?


Thank you very much!
Yours sincerely
Zicai
0
 
LVL 1

Expert Comment

by:rkumar115
ID: 6217936
With JDK1.3.1 Kit you will get the Sound Demo. There is Source code available for that demo. Usually software guys copy these source code in there programs. Rather than I copy a portion of it and give it to you , Its preferable you go through the Source Code Yourself.
You can download the JDK1.3.1 from the javasoft site. It is free.

Best of luck

0
 
LVL 2

Author Comment

by:zicai
ID: 7246076
Hi, rkumar115, thank you very much!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question