Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2011
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import javax.sound.sampled.*;
  2.  
  3. public class AudioPump {
  4.  
  5.     public static void main(String[] args) throws Exception {
  6.  
  7.         AudioFormat format = new AudioFormat(8000f, 8, 1, false, false);
  8.         DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
  9.         SourceDataLine soundLine = (SourceDataLine)AudioSystem.getLine(info);
  10.         soundLine.open(format, 32000);
  11.         soundLine.start();
  12.  
  13.         byte[] buffer = new byte[8];
  14.         int t = 0;
  15.  
  16.         while(true) {
  17.             for(int n = 0; n < buffer.length; n++) {
  18.                 buffer[n] = (byte)f(t++);
  19.             }
  20.             soundLine.write(buffer, 0, buffer.length);
  21.         }
  22.     }
  23.  
  24.     private static int f(int t) {
  25.         return (t>>7|t|t>>6)*10+4*(t&t>>13|t>>6);
  26.         //return (t*(t>>5|t>>8))>>(t>>16);
  27.         //return t*(((t>>12)|(t>>8))&(63&(t>>4)));
  28.     }
  29.  
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement