Solved

Can I use Java to generate sound?

Posted on 2001-06-13
6
572 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
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 100 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping2 challenge 13 80
Starting to learn JAVA, 7 59
Java Message handling in Service Layer 3 57
configure dependency in POM for new database 3 15
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

912 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now