rodrwan

Micro-in-java

Apr 12th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. import java.io.File;
  2. import javax.sound.sampled.*;
  3.  
  4. public class Main {
  5.   AudioFileFormat.Type aFF_T = AudioFileFormat.Type.WAVE;
  6.   AudioFormat aF = new AudioFormat(8000.0F, 16, 1, true, false);
  7.   TargetDataLine tD;
  8.   File f = new File("Grabacion.wav");
  9.   public Main() {
  10.    try {
  11.     DataLine.Info dLI = new DataLine.Info(TargetDataLine.class,aF);
  12.     tD = (TargetDataLine)AudioSystem.getLine(dLI);
  13.     new CapThread().start();
  14.     System.out.println("Grabando durante 10s...");
  15.     Thread.sleep(10000);
  16.     tD.close();
  17.    }catch (Exception e) {}
  18.   }
  19.   class CapThread extends Thread {
  20.   public void run() {
  21.    try {
  22.     tD.open(aF);
  23.     tD.start();
  24.     AudioSystem.write(new AudioInputStream(tD), aFF_T, f);
  25.    }catch (Exception e){}
  26.   }
  27.  }
  28.  public static void main(String[] args) { new Main(); }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment