Results 1 to 7 of 7
  1. #1
    Jlister76 is offline Member
    Join Date
    Feb 2011
    Posts
    4
    Rep Power
    0

    Question Accessing AudioSystem getMixerInfo()??

    Would like to see how a simple program uses the getMixerInfo() to display the mixers that are installed on my computer. I am very new to Java and really appreciate any help and/or advice.

    In Eclipse I set up a class like so:

    import javax.sound.sampled.*;

    public class DisplayMixers {

    What do I need inside my class to call the object and display the name, version, vendor, description which are defined in the Mixer.Info class?

    public void main (String [] args){
    }

    }
    Last edited by Jlister76; 02-22-2011 at 12:09 PM.

  2. #2
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Quote Originally Posted by Jlister76 View Post
    What do I need inside my class to call the object and display the name, version, vendor, description which are defined in the Mixer.Info class?
    You would need to have the AudioSystem class to invoke this method. It returns the details inside an array. I hope you know how to iterate over the array and display the information inside.

    Here is the API link : AudioSystem.getMixerInfo()

    Hope that helps,

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  3. #3
    Jlister76 is offline Member
    Join Date
    Feb 2011
    Posts
    4
    Rep Power
    0

    Default

    First off thank you Goldest for your reply. This is the first time I have been able to ask anyone a question as I've been primarily reading from books & tuts.

    I'm a still a bit confused as what to do to follow your instructions. Do I instantiate an object, then an array of the object and then print the values?

  4. #4
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Quote Originally Posted by Jlister76 View Post
    I'm a still a bit confused as what to do to follow your instructions. Do I instantiate an object, then an array of the object and then print the values?
    The getMixerInfo() method is a static method, so you don't really need to create any object to access it. You can access it directly by the class name AudioSystem.

    This method returns an array of Info objects for the currently installed mixers. You need to store the output into Info[] array, iterate over it and display the contents.

    I hope you can manage that,

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  5. #5
    Jlister76 is offline Member
    Join Date
    Feb 2011
    Posts
    4
    Rep Power
    0

    Default

    Mission accomplished!

    Once again thank you for your help. A breakdown of my code is below and would like to know is there a more efficient way to produce the same results?

    I imported both AudioSytem and Mixer class.
    Accessed the method and stored the objects into an array as you advised
    Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo()

    Then iterated over the array using a try/catch and a for statement
    try {
    System.out.println("Available mixers:");
    for (int cnt = 0; cnt < mixerInfo.length;
    cnt++) {
    System.out.println(mixerInfo[cnt].getVersion());
    System.out.println(mixerInfo[cnt].getName());
    System.out.println(mixerInfo[cnt].getDescription());
    System.out.println(mixerInfo[cnt].getVendor());
    }//end for loop
    } catch (Exception e) {
    // nada

  6. #6
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Quote Originally Posted by Jlister76 View Post
    Mission accomplished!
    Good to know that.

    The only thing is that you don't really need to use the try/catch block. None of the methods used by you throw any exceptions. So you can remove that.

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  7. #7
    Jlister76 is offline Member
    Join Date
    Feb 2011
    Posts
    4
    Rep Power
    0

Similar Threads

  1. Accessing XML in a Jar
    By WizzRD in forum Advanced Java
    Replies: 19
    Last Post: 07-29-2010, 12:20 PM
  2. Replies: 3
    Last Post: 03-03-2010, 09:51 PM
  3. Accessing USB
    By FieryProphet in forum Networking
    Replies: 3
    Last Post: 12-13-2008, 05:29 AM
  4. Accessing file
    By Doctor Cactus in forum New To Java
    Replies: 1
    Last Post: 10-24-2008, 07:31 PM
  5. problem in accessing EJB
    By parimal in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 08-07-2008, 03:31 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •