Package javax.sound.sampled

Examples of javax.sound.sampled.TargetDataLine


import javax.sound.sampled.Port;
import javax.sound.sampled.TargetDataLine;

public class SoundMicroTest {
  public static void main(String[] args) {
    TargetDataLine line = null;
    DataLine.Info info = new DataLine.Info(TargetDataLine.class, getAudioFormat()); // format
                                        // is
                                        // an
                                        // AudioFormat
                                        // object
View Full Code Here


    if (sm_bDebug) {
      out("AudioRecorder.main(): target audio file format type: "
          + targetType);
    }

    TargetDataLine targetDataLine = null;
    targetDataLine = AudioCommon.getTargetDataLine(strMixerName,
        audioFormat, nInternalBufferSize);
    if (targetDataLine == null) {
      out("can't get TargetDataLine, exiting.");
      System.exit(1);
View Full Code Here

     * used later to read audio data from it. If requesting the line was
     * successful, we are opening it (important!).
     */
    DataLine.Info info = new DataLine.Info(TargetDataLine.class,
        audioFormat);
    TargetDataLine targetDataLine = null;
    try {
      targetDataLine = (TargetDataLine) AudioSystem.getLine(info);
      targetDataLine.open(audioFormat);
    } catch (LineUnavailableException e) {
      out("unable to get a recording line");
      e.printStackTrace();
      System.exit(1);
    }
View Full Code Here

      System.out.println("  Targets (" + tLineInfos.length + "):");
      for(int k=0; k<tLineInfos.length; k++)
      {
        try
        {
          TargetDataLine tLine = (TargetDataLine)mixer.getLine(tLineInfos[k]);
          System.out.println("   Line: " + tLine.getLineInfo() + "\t(Name: " + tLine + ")");
        }
        catch (LineUnavailableException e)
        {
          e.printStackTrace();
        }
View Full Code Here

    DataLine.Info info = new DataLine.Info(TargetDataLine.class, af);
    DataLine.Info sinfo = new DataLine.Info(SourceDataLine.class, af);

    try {
      ByteArrayOutputStream baOut = new ByteArrayOutputStream();
      TargetDataLine tl = (TargetDataLine) AudioSystem.getLine(info);
      tl.open(af);
      tl.start();
      SourceDataLine sl = (SourceDataLine) AudioSystem.getLine(sinfo); // Neu:
                                        // Line
                                        // f�r
                                        // Tonausgabe
      sl.open(af); // �ffnen
      sl.start(); // starten
      int numBytesRead;
      int durchlauf = 0;
      byte[] ba = new byte[256]; // definieren und gleich einmal
                    // initialisieren.
      while (durchlauf < 1000) {
        durchlauf++;
        numBytesRead = tl.read(ba, 0, ba.length);
        baOut.write(ba, 0, numBytesRead);
        sl.write(ba, 0, numBytesRead); // in Tonausgabe schreiben
      }
      baOut.close(); // close() ist wichtig, k�nnten noch Daten gepuffert
              // sein
      tl.stop(); // eingabe stoppen
      sl.stop(); // ausgabe stoppen
      tl.close(); // eingabe schliessen
      sl.close(); // ausgabe schliessen
      ba = baOut.toByteArray(); // ba liegt brach ruhig wieder verwenden
      ByteArrayInputStream baIn = new ByteArrayInputStream(ba);
      AudioInputStream stream = new AudioInputStream(baIn, af, ba.length
          / af.getFrameSize());
View Full Code Here

   * Gets a data line for the specified mixer
   * @param mix
   * @return
   */
  public Line getDataLineForMixer(){
    TargetDataLine line = null;
    try {
      line=(TargetDataLine)this.mixer.getLine(getDataLineInfo());
    } catch (LineUnavailableException e) {
      // Record the error
      String err="getDataLineForMixer() : "+e.getMessage();
View Full Code Here

    }

    static void testTDL(Mixer mixer, Scenario scenario) {
        log("  Testing TDL (scenario: " + scenario + ")...");
        Line.Info linfo = new Line.Info(TargetDataLine.class);
        TargetDataLine line = null;
        try {
            line = (TargetDataLine)mixer.getLine(linfo);
            log("    got line: " + line);
            log("    open...");
            line.open();
        } catch (IllegalArgumentException ex) {
            log("    unsupported (IllegalArgumentException)");
            return;
        } catch (LineUnavailableException ex) {
            log("    unavailable: " + ex);
            return;
        }

        total++;

        log("    start...");
        line.start();

        AsyncLineStopper lineStopper = new AsyncLineStopper(line, STOPPER_DELAY);
        int offset = scenario.getBufferOffset(line);
        int len = scenario.getBufferLength(line);
        // ensure len represents integral number of frames
        len -= len % line.getFormat().getFrameSize();

        log("    read...");
        try {
            line.read(buffer, offset, len);
            log("    ERROR: didn't get ArrayIndexOutOfBoundsException");
            failed++;
        } catch (ArrayIndexOutOfBoundsException  ex) {
            log("    OK: got ArrayIndexOutOfBoundsException: " + ex);
        }
View Full Code Here

TOP

Related Classes of javax.sound.sampled.TargetDataLine

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.