Audio (API)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: Audio (API)

  1. #1
    Join Date
    Mar 2017
    Posts
    6

    Audio (API)

    Hello, I am new to the forums, and joined because I wanted a forum to ask some professionals if there is a better method for using audio files. But, in my thought I realized I probably have all the customization I need with the Clip interface.

    But, my question is how is one using Clip (an interface), as if it were a class? Where are these methods instantiated? What class that implements Clip is being passed at AudioSystem.getClip()?

    Code:
        
        private void playSound(File f){
        	if(f!=null){
                     try {
                       AudioInputStream ais = AudioSystem.getAudioInputStream(f);
                       Clip clip = AudioSystem.getClip();
                       clip.open(ais);
                       FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
    					gainControl.setValue(-30.0f); 
                       clip.start();
                      }
                         catch(UnsupportedAudioFileException ioe) {ExceptionHandling.add(ioe);}
                           catch(LineUnavailableException ioe) { ExceptionHandling.add(ioe);}
                             catch(IOException ioe) { ExceptionHandling.add(ioe); }	
        				}
        						}

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,697

    Re: Audio (API)

    What class that implements Clip is being passed at AudioSystem.getClip()?
    Call the getClass() method for that object and print it to see what class it is.
    Norm

  3. #3
    Join Date
    Mar 2017
    Posts
    6

    Re: Audio (API)

    I get class com.sun.media.sound.DirectAudioDevice$DirectClip, however, I cannot find that in java docs at all.

  4. #4
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,697

    Re: Audio (API)

    That looks like an internal class that is not supposed to be accessible except as an interface. The interface is documented.
    Norm

  5. #5
    Join Date
    Mar 2017
    Posts
    6

    Re: Audio (API)

    That is a thing? Why would they hide classes from us?

  6. #6
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,697

    Re: Audio (API)

    So it can be changed (improved) without any changes to the existing docs
    Norm

  7. #7
    Join Date
    Mar 2017
    Posts
    6

    Re: Audio (API)

    Okay so is there anywhere I can find the content of such a class?

  8. #8
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,697

    Re: Audio (API)

    No, It's not supposed to be public.
    Norm

  9. #9
    Join Date
    Mar 2017
    Posts
    6

    Re: Audio (API)

    So, there is a matter of property? I was always under the impression all of java API's, Bytecode, JVM, and such were all free to evaluate. This assumption is inaccurate? Does Oracle have some restrictions on what we are allowed to view for reasons of copyright?

  10. #10
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,697

    Re: Audio (API)

    Sorry, I don't know anything about that.
    Norm

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


HTML5 Development Center