-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLive.java
37 lines (28 loc) · 1.13 KB
/
Live.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.io.*;
import javax.sound.sampled.*;
public class Live{
public static void main(String[] args) {
AudioFormat audioFormat = new AudioFormat(44100, 16, 2, true, true);
TargetDataLine m_targetLine;
SourceDataLine m_sourceLine;
int m_nExternalBufferSize;
try{
m_targetLine = (TargetDataLine) AudioSystem.getLine(
new DataLine.Info(TargetDataLine.class, audioFormat));
m_sourceLine = (SourceDataLine) AudioSystem.getLine(
new DataLine.Info(SourceDataLine.class, audioFormat));
m_targetLine.open(audioFormat);
m_sourceLine.open(audioFormat);
byte[] buffer = new byte[m_targetLine.getBufferSize()/5];
m_targetLine.start();
m_sourceLine.start();
while(true){
// int read = ;
m_sourceLine.write(buffer, 0, m_targetLine.read(buffer, 0, buffer.length));
}
}
catch (LineUnavailableException e){
System.out.println("an error has occured opening a line");
}
}
}