?
Solved

Changing the volume of a clip for playback

Posted on 2005-04-23
9
Medium Priority
?
322 Views
Last Modified: 2010-03-31
Is it possible to increase gain or volume of a clip before it is played to a user. So you could play the same clip at different volumes.
0
Comment
Question by:pigmentarts
  • 5
  • 3
9 Comments
 
LVL 15

Expert Comment

by:aozarov
ID: 13852538
You can't do that on an AudioClip but you can do it when using the javax.sound package.
see this code: http://www.onjava.com/onjava/excerpt/jenut3_ch17/examples/SoundPlayer.java
as an example of how to change the volume (using the FloatControl object).
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 13853186
theres quite a few errors in the example so i cant complile the whole thing..but would you help me with using the float control object to affect one midi file being played


It seems to be a heafty amount of code to set a clip..is this just for playing one midi file?

So 1st create a SoundPLayer in a frame, that seems to be the starting point.

File file = new File(args[0]); is the midi file I want to play? (where do i select the codebase and such)

The create an object to play the sound and put it in the frame.

I get a bit lost from that point, it checks to see if its a midi file or a sampled, but if i know its a midi file I can delete that bit can't i?
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 13853188
Also is there a quick way for me to complie this code without setting up a new package.
0
Independent Software Vendors: 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 15

Expert Comment

by:aozarov
ID: 13854386
>> theres quite a few errors in the example so i cant complile the whole
Yes, you need to replace:
> with >
&lg; with <
&amp; with &

>>  Also is there a quick way for me to complie this code without setting up a new package.
If you are using JDK > 1.4 then the javax.sound package is already included and it should compile fine (after fixing the above)

>> File file = new File(args[0]); is the midi file I want to play? (where do i select the codebase and such)
This demo loads the image from the disk (it is not an Applet)

>> The create an object to play the sound and put it in the frame.
That program does it.

>> it checks to see if its a midi file or a sampled,
Right, this sample code can handle both midi and sampled sound (you can remove the latter if you want)

compile the program (after fixing the errors) and run it by providing a midi file.
To change the source of the midi to a remote source should be fairly simple (using URL)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13854623
>>
 >> theres quite a few errors in the example so i cant complile the whole
Yes, you need to replace:
&gt; with >
&lg; with <
&amp; with &
>>

pigmentarts, i already corrected the errors in that code for you and gave it to you ;-)
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 13861990
hehe, ayuh, i think i remember. whoops :P

I'm going to leave this for a bit and come back to it
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 13862000
ummm is it possible to add a slider bar to a single clip being played? without going into the javax.sound package
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 13862003
a slider bar which appears user side so they can adjust the volume
0
 
LVL 15

Accepted Solution

by:
aozarov earned 2000 total points
ID: 13862083
>> ummm is it possible to add a slider bar to a single clip being played? without going into the javax.sound package
No, the problem is not with the slider bar but rather with the fact that you can't change the volume using the plain AudioClip and not using javax.sound package.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month16 days, 19 hours left to enroll

864 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