Package javax.sound.sampled

Examples of javax.sound.sampled.AudioFormat


        {
            File file = new File(filename);
            AudioFileFormat aff = AudioSystem.getAudioFileFormat(file);
            AudioInputStream in = AudioSystem.getAudioInputStream(file);
            AudioInputStream din = null;
            AudioFormat baseFormat = in.getFormat();
            if (out != null) out.println("Source Format : "+baseFormat.toString());
            AudioFormat  decodedFormat = new AudioFormat(
                  AudioFormat.Encoding.PCM_SIGNED,
                  baseFormat.getSampleRate(),
                  16,
                  baseFormat.getChannels(),
                  baseFormat.getChannels() * 2,
                  baseFormat.getSampleRate(),
                  false);
            if (out != null) out.println("Target Format : "+decodedFormat.toString());
            din = AudioSystem.getAudioInputStream(decodedFormat, in);           
            long toSkip = (long)(file.length()/2);
            long skipped = skip(din,toSkip);
            if (out != null) out.println("Skip : "+skipped+"/"+toSkip+" (Total="+file.length()+")");
            if (out != null) out.println("Start playing");
View Full Code Here


    }
  }
 
  private void dumpAudioFileFormat(AudioFileFormat baseFileFormat, PrintStream out, String info) throws UnsupportedAudioFileException
  {
    AudioFormat baseFormat = baseFileFormat.getFormat();
    if (out != null)
    {
      // AudioFileFormat
      out.println("  -----  "+info+"  -----");   
      out.println("    ByteLength="+ baseFileFormat.getByteLength());   
      out.println("    FrameLength="+ baseFileFormat.getFrameLength());   
      out.println("    Type="+ baseFileFormat.getType());   
      // AudioFormat         
      out.println("    SourceFormat="+baseFormat.toString());
      out.println("    Channels="+ baseFormat.getChannels());   
      out.println("    FrameRate="+ baseFormat.getFrameRate());   
      out.println("    FrameSize="+ baseFormat.getFrameSize());   
      out.println("    SampleRate="+ baseFormat.getSampleRate());   
      out.println("    SampleSizeInBits="+ baseFormat.getSampleSizeInBits());   
      out.println("    Encoding="+ baseFormat.getEncoding());           
    }
    assertEquals("Type",(String)props.getProperty("Type"),baseFileFormat.getType().toString());
    assertEquals("SourceFormat",(String)props.getProperty("SourceFormat"),baseFormat.toString());
    assertEquals("Channels",Integer.parseInt((String)props.getProperty("Channels")),baseFormat.getChannels());     
    assertTrue("FrameRate",Float.parseFloat((String)props.getProperty("FrameRate"))==baseFormat.getFrameRate());
    assertEquals("FrameSize",Integer.parseInt((String)props.getProperty("FrameSize")),baseFormat.getFrameSize());     
    assertTrue("SampleRate",Float.parseFloat((String)props.getProperty("SampleRate"))==baseFormat.getSampleRate());
    assertEquals("SampleSizeInBits",Integer.parseInt((String)props.getProperty("SampleSizeInBits")),baseFormat.getSampleSizeInBits());     
    assertEquals("Encoding",(String)props.getProperty("Encoding"),baseFormat.getEncoding().toString())
  }
View Full Code Here

    assertEquals("Encoding",(String)props.getProperty("Encoding"),baseFormat.getEncoding().toString())
  }
 
  private void dumpAudioInputStream(AudioInputStream in, PrintStream out, String info) throws IOException
  {
    AudioFormat baseFormat = in.getFormat();
    if (out != null)
    { 
      out.println("  -----  "+info+"  -----");   
      out.println("    Available="+in.available());
      out.println("    FrameLength="+in.getFrameLength());
      // AudioFormat         
      out.println("    SourceFormat="+baseFormat.toString());
      out.println("    Channels="+ baseFormat.getChannels());   
      out.println("    FrameRate="+ baseFormat.getFrameRate());   
      out.println("    FrameSize="+ baseFormat.getFrameSize());   
      out.println("    SampleRate="+ baseFormat.getSampleRate());   
      out.println("    SampleSizeInBits="+ baseFormat.getSampleSizeInBits());   
      out.println("    Encoding="+ baseFormat.getEncoding());             
    }   
    assertEquals("SourceFormat",(String)props.getProperty("SourceFormat"),baseFormat.toString());
    assertEquals("Channels",Integer.parseInt((String)props.getProperty("Channels")),baseFormat.getChannels());     
    assertTrue("FrameRate",Float.parseFloat((String)props.getProperty("FrameRate"))==baseFormat.getFrameRate());
    assertEquals("FrameSize",Integer.parseInt((String)props.getProperty("FrameSize")),baseFormat.getFrameSize());     
    assertTrue("SampleRate",Float.parseFloat((String)props.getProperty("SampleRate"))==baseFormat.getSampleRate());
    assertEquals("SampleSizeInBits",Integer.parseInt((String)props.getProperty("SampleSizeInBits")),baseFormat.getSampleSizeInBits());     
    assertEquals("Encoding",(String)props.getProperty("Encoding"),baseFormat.getEncoding().toString())

  }
View Full Code Here

                              "mp3.header.pos","mp3.version.layer","mp3.crc"};
    String[] testPropsAF = {"vbr", "bitrate"};

    File file = new File(filename);
    AudioFileFormat baseFileFormat = null;
    AudioFormat baseFormat = null;
    try
    {
      baseFileFormat = AudioSystem.getAudioFileFormat(file);
      baseFormat = baseFileFormat.getFormat();
      if (out != null) out.println("-> Filename : "+filename+" <-");
View Full Code Here

                /*"mp3.length.frames",*/"mp3.mode","mp3.channels","mp3.version.mpeg",
                "mp3.framesize.bytes","mp3.vbr.scale","mp3.version.encoding",
                "mp3.header.pos","mp3.version.layer","mp3.crc"};
    String[] testPropsAF = {"vbr", "bitrate"};
    AudioFileFormat baseFileFormat = null;
    AudioFormat baseFormat = null;
    try
    {
      URL url = new URL(fileurl);
      baseFileFormat = AudioSystem.getAudioFileFormat(url);
      baseFormat = baseFileFormat.getFormat();
View Full Code Here

  }

  public void testPropertiesShoutcast()
  {
    AudioFileFormat baseFileFormat = null;
    AudioFormat baseFormat = null;
    String shoutURL = (String) props.getProperty("shoutcast");
    try
    {
      URL url = new URL(shoutURL);
      baseFileFormat = AudioSystem.getAudioFileFormat(url);
View Full Code Here

    public void _testDumpPropertiesFile()
    {
        File file = new File(filename);
        AudioFileFormat baseFileFormat = null;
        AudioFormat baseFormat = null;
        try
        {
            baseFileFormat = AudioSystem.getAudioFileFormat(file);
            baseFormat = baseFileFormat.getFormat();
            if (out != null) out.println("-> Filename : "+filename+" <-");
View Full Code Here

        } catch (IOException ioe) {
            ioe.printStackTrace();
        }

        if (audioInputStream != null) {
            AudioFormat format = audioInputStream.getFormat();
            DataLine.Info   info = new DataLine.Info(Clip.class, format,
                                             AudioSystem.NOT_SPECIFIED);
            try {
                audioClip = (Clip) AudioSystem.getLine(info);
                audioClip.addLineListener(this);
View Full Code Here

    this.testAU();
  }
 
  private void processWaveStream(AudioInputStream stream)
  {
    AudioFormat format = stream.getFormat();

    // NOTE: we don't check for encoding, because our backend is unable
    // to get the correct encoding as defined by AudioFormat.Encoding
    // this is not a problem, because the encodings specified do not
    // make sense in most cases.
    this.harness.check(format.getFrameSize() == 1);       
    this.harness.check(format.getChannels() == 1);
    this.harness.check(format.getSampleRate() == 8000.0);
    this.harness.check(format.getFrameRate() == 8000.0);
    this.harness.check(format.getSampleSizeInBits() == 8);
  }
View Full Code Here

    this.harness.check(format.getSampleSizeInBits() == 8);
  }
 
  private void processAUStream(AudioInputStream stream)
  {
    AudioFormat format = stream.getFormat();

    // NOTE: we don't check for encoding, because our backend is unable
    // to get the correct encoding as defined by AudioFormat.Encoding
    // this is not a problem, because the encodings specified do not
    // make sense in most cases.
    this.harness.check(format.getFrameSize() == 2);       
    this.harness.check(format.getChannels() == 1);
    this.harness.check(format.getSampleRate() == 8000.0);
    this.harness.check(format.getFrameRate() == 8000.0);
    this.harness.check(format.getSampleSizeInBits() == 16);
  }
View Full Code Here

TOP

Related Classes of javax.sound.sampled.AudioFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.