Package javax.sound.sampled

Examples of javax.sound.sampled.SourceDataLine


            //96515374
        }
    }

    private SourceDataLine getLine(AudioFormat audioFormat) throws LineUnavailableException {
        SourceDataLine res = null;
        DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
        res = (SourceDataLine) AudioSystem.getLine(info);
        res.open(audioFormat);
        return res;
    }
View Full Code Here


   }
  }

  private SourceDataLine getLine(AudioFormat audioFormat) throws LineUnavailableException
  {
    SourceDataLine res = null;
    DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
    res = (SourceDataLine) AudioSystem.getLine(info);
    res.open(audioFormat);
    return res;
  }
View Full Code Here

  }
 
  private void rawplay(AudioFormat targetFormat, AudioInputStream din) throws IOException, LineUnavailableException
  {
    byte[] data = new byte[4096];
    SourceDataLine line = getLine(targetFormat);   
    if (line != null)
    {
      // Start
      line.start();
      int nBytesRead = 0, nBytesWritten = 0;
      while (nBytesRead != -1)
      {
      nBytesRead = din.read(data, 0, data.length);
      if (nBytesRead != -1) nBytesWritten = line.write(data, 0, nBytesRead);
      }
      // Stop
      line.drain();
      line.stop();
      line.close();
      din.close();
    }   
  }
View Full Code Here

        return totalSkipped;       
    }

    private SourceDataLine getLine(AudioFormat audioFormat) throws LineUnavailableException
    {
      SourceDataLine res = null;
      DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
      res = (SourceDataLine) AudioSystem.getLine(info);
      res.open(audioFormat);
      return res;
    }
View Full Code Here

    }
   
    private void rawplay(AudioFormat targetFormat, AudioInputStream din) throws IOException, LineUnavailableException
    {
        byte[] data = new byte[4096];
        SourceDataLine line = getLine(targetFormat);       
        if (line != null)
        {
          // Start
          line.start();
          int nBytesRead = 0, nBytesWritten = 0;
          while (nBytesRead != -1)
          {
            nBytesRead = din.read(data, 0, data.length);
            if (nBytesRead != -1) nBytesWritten = line.write(data, 0, nBytesRead);
          }
          // Stop
          line.drain();
          line.stop();
          line.close();
          din.close();
        }      
    }
View Full Code Here

        return featExts;
    }

    public AudioWriter openAudioWriter() throws LineUnavailableException {
        SourceDataLine line = null;
        AudioWriter writer = null;
        DataLine.Info info = new DataLine.Info(SourceDataLine.class,
                                               format);
       
        Mixer.Info[] m1x0rs = AudioSystem.getMixerInfo();
        //System.out.println("Do you support " + info + "?");
        for(int i=0; i<m1x0rs.length; i++)
            if(AudioSystem.getMixer(m1x0rs[i]).isLineSupported(info))
                mixerToUse = i;
       
        // Obtain and open the line.
        line = (SourceDataLine) AudioSystem.getMixer(m1x0rs[mixerToUse])
            .getLine(info);
        //line.open(format, 1024*5);
        line.open(format);
        //System.out.println("Source line opened from mixer: "
        //+ m1x0rs[mixerToUse]);
        writer = new AudioWriter(line);
       
        return writer;
View Full Code Here

     * @return A <code>SourceDataLine</code> that can be used for purposes
     * such as writing directly to a speaker.
     */
    public static SourceDataLine getSourceDataLine(AudioFormat audio_format,
                                                   org.vocvark.jAudioTools.AudioEventLineListener listener) {
        SourceDataLine source_data_line = null;
        DataLine.Info data_line_info = new DataLine.Info(SourceDataLine.class, audio_format);
        try {
            source_data_line = (SourceDataLine) AudioSystem.getLine(data_line_info);
            if (listener != null)
                source_data_line.addLineListener(listener);
            source_data_line.open(audio_format);
        } catch (LineUnavailableException e) {
            System.out.println(e);
            System.exit(0);
        }
        source_data_line.start();
        return source_data_line;
    }
View Full Code Here

    // other wise just play the audio directly

    else
    {
      IStream stream = mContainer.getStream(event.getStreamIndex());
      SourceDataLine line = getJavaSoundLine(stream);
      if (line != null)
        playAudio(stream, line, samples);
    }
  }
View Full Code Here

    if (!(tool instanceof IMediaCoder))
      throw new UnsupportedOperationException();

    AudioQueue queue = mAudioQueues.get(streamIndex);
    IStream stream = ((IMediaCoder)tool).getContainer().getStream(streamIndex);
    SourceDataLine line = getJavaSoundLine(stream);
   
    // if no queue (and there is a line), create the queue

    if (null == queue && line != null)
    {
View Full Code Here

  private SourceDataLine getJavaSoundLine(IStream stream)
  {
    IStreamCoder audioCoder = stream.getStreamCoder();
    int streamIndex = stream.getIndex();
    SourceDataLine line = mAudioLines.get(streamIndex);
    if (line == null)
    {
      try
      {
        // estabish the audio format, NOTE: xuggler defaults to signed 16 bit
        // samples

        AudioFormat audioFormat = new AudioFormat(audioCoder.getSampleRate(),
          (int) IAudioSamples
          .findSampleBitDepth(audioCoder.getSampleFormat()), audioCoder
          .getChannels(), true, false);
       
        // create the audio line out
       
        DataLine.Info info = new DataLine.Info(SourceDataLine.class,
            audioFormat);
        line = (SourceDataLine) AudioSystem.getLine(info);

        // open the line and start the line

        line.open(audioFormat);
        line.start();
        mAudioLines.put(streamIndex, line);

        // if mDataLine is not yet defined, do so

        if (null == mDataLine)
View Full Code Here

TOP

Related Classes of javax.sound.sampled.SourceDataLine

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.