Urgent help needed with Sound Control

A

Amit Gangrade

Hello Everyone ,

I had written a code for a Simple audio player which takes an audio
file as an input an plays it.

class SimpleAudioPlayer {
.......
.......
public int play(Clip clip,int count) {
clip.loop(count);
return 0;
}
.....
.....
}

the play method is called from the another method which sets up the
audioInputStream and creates a desired clip and then passes it on to
the
play( ) method.

Now I had written another class which acts as a Filter class for
SimpleAudioPlayer class. This class contains a function FilterPlay it
intercepts the calls to the play( ) method. It can change the
arguments of the play( ) method and then pass then on to it.

class FilterSimpleAudioPlayer {
public int FilterPlay(Clip clip,int count) {
....change the argument clip .....
....pass the control to the play( ) function....
}
}


My question has actually nothing to do with the Filtering thing .
my question is how do I change the Clip object in Filter function.
I need to change it to demonstrate the ability of software filtering.
The changes to clip object may be like add echo to the sound,
change the volume, but I dont find a way to do it.
The class FloatControl might do this job but I dont know how to use
it to do this.

any help for the above will be really gr8.

thnx
Amit
 
A

Amit Gangrade

Hello Everyone ,

I had written a code for a Simple audio player which takes an audio
file as an input an plays it.

class SimpleAudioPlayer {
.......
.......
public int play(Clip clip,int count) {
clip.loop(count);
return 0;
}
.....
.....
}

the play method is called from the another method which sets up the
audioInputStream and creates a desired clip and then passes it on to
the
play( ) method.

Now I had written another class which acts as a Filter class for
SimpleAudioPlayer class. This class contains a function FilterPlay it
intercepts the calls to the play( ) method. It can change the
arguments of the play( ) method and then pass then on to it.

class FilterSimpleAudioPlayer {
public int FilterPlay(Clip clip,int count) {
....change the argument clip .....
....pass the control to the play( ) function....
}
}


My question has actually nothing to do with the Filtering thing .
my question is how do I change the Clip object in Filter function.
I need to change it to demonstrate the ability of software filtering.
The changes to clip object may be like add echo to the sound,
change the volume, but I dont find a way to do it.
The class FloatControl might do this job but I dont know how to use
it to do this.

any help for the above will be really gr8.

thnx
Amit

finally was able to do it ..
this is how it worked

/* your clip object must be ready and then before
doing clip.loop() write the follwoing */

Control cntls[] = clip.getControls(); //get the controls supported by the
//clip in cntls array.

for(int i=0;i<cntls.length;i++) { //print the controls for reference
System.out.println(i+ " "+ cntls.toString());
}
// now to change the Volume of the clip.The volume control is given
// by cntls[0]. Cast cntls[0] into FloatControl.
FloatControl f = (FloatControl) cntls[0];
f.setValue((float) 10);
System.out.println("Volume = " + f.getValue());

clip.loop(1) ; //sound will be played with greater gain.
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top