Solved

Can I use Java to generate sound?

Posted on 2001-06-13
6
566 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
Comment Utility
take a look at the JMF (Java Media Framework).
0
 
LVL 3

Expert Comment

by:dnoelpp
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 2

Author Comment

by:zicai
Comment Utility
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
Comment Utility
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
Comment Utility
Hi, rkumar115, thank you very much!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
This video teaches viewers about errors in exception handling.

771 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

10 Experts available now in Live!

Get 1:1 Help Now