Solved

Can I use Java to generate sound?

Posted on 2001-06-13
6
595 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 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How  can  i  resolve  HTTP Status 404 -? 8 80
import as existing maven project 3 78
Java array 10 89
Java ArrayList and if statement 2 55
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…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

752 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