Advertisement
Guest User

Untitled

a guest
Jan 30th, 2016
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. /**
  2. * Defines an audio format
  3. */
  4. AudioFormat getAudioFormat() {
  5. float sampleRate = 16000;
  6. int sampleSizeInBits = 8;
  7. int channels = 1;
  8. boolean signed = true;
  9. boolean bigEndian = false;
  10. AudioFormat format = new AudioFormat(sampleRate, sampleSizeInBits,
  11. channels, signed, bigEndian);
  12. return format;
  13. }
  14.  
  15. //How I open the line:
  16. AudioFormat format = getAudioFormat();
  17. DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
  18.  
  19. if (!AudioSystem.isLineSupported(info)) {
  20. System.out.println("Line not supported");
  21. System.exit(0);
  22. }
  23. line = (TargetDataLine) AudioSystem.getLine(info);
  24. line.open(format);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement