Changing the volume of a clip for playback

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.
LVL 12
pigmentartsAsked:
Who is Participating?
 
aozarovCommented:
>> 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
 
aozarovCommented:
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
 
pigmentartsAuthor Commented:
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
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
pigmentartsAuthor Commented:
Also is there a quick way for me to complie this code without setting up a new package.
0
 
aozarovCommented:
>> 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
 
CEHJCommented:
>>
 >> 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
 
pigmentartsAuthor Commented:
hehe, ayuh, i think i remember. whoops :P

I'm going to leave this for a bit and come back to it
0
 
pigmentartsAuthor Commented:
ummm is it possible to add a slider bar to a single clip being played? without going into the javax.sound package
0
 
pigmentartsAuthor Commented:
a slider bar which appears user side so they can adjust the volume
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.