Urgent help needed with Sound Control

Discussion in 'Java' started by Amit Gangrade, Nov 15, 2003.

  1. 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
     
    Amit Gangrade, Nov 15, 2003
    #1
    1. Advertising

  2. (Amit Gangrade) wrote in message news:<>...
    > 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.
    }
     
    Amit Gangrade, Nov 16, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. andy

    urgent help needed !

    andy, Jul 12, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    932
  2. Ramki
    Replies:
    2
    Views:
    524
    Digitlcoup
    Feb 10, 2004
  3. Brahmam

    Urgent help needed.............

    Brahmam, Apr 7, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    436
    Brahmam
    Apr 7, 2006
  4. Luc The Perverse

    Sound Quality In Sound API

    Luc The Perverse, Oct 30, 2005, in forum: Java
    Replies:
    4
    Views:
    1,515
    Andrew Thompson
    Oct 31, 2005
  5. Replies:
    0
    Views:
    561
Loading...

Share This Page