Ik wil audio capturen dat op m'n line in binnenkomt. Als ik met de gevonden MediaLocator direct een realizedPlayer maak, hoor ik het geluid goed binnenkomen, maar zodra ik het met behulp van een processor wil doen omdat ik het bijvoorbeeld wil opslaan oid, blijft het stil.
De hierna volgende code geeft geen foutmeldingen, maar levert niet het geluid op van de line in. Ik ben al blij als iemand me in de goede richting kan helpen zodat er geluid uit de player komt die wordt gemaakt met de Datasource.
De hierna volgende code geeft geen foutmeldingen, maar levert niet het geluid op van de line in. Ik ben al blij als iemand me in de goede richting kan helpen zodat er geluid uit de player komt die wordt gemaakt met de Datasource.
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
| import javax.media.*; import javax.media.format.AudioFormat; import javax.media.protocol.ContentDescriptor; import javax.media.protocol.DataSource; import javax.media.protocol.FileTypeDescriptor; import java.io.IOException; import java.util.Vector; public class CaptureAudio { public CaptureAudio() throws CannotRealizeException, NoDataSinkException, NoPlayerException, IOException { DataSource dataSource; Processor mediaProcessor = null; CaptureDeviceInfo di = null; final Format[] FORMATS = new Format[]{new AudioFormat(AudioFormat.LINEAR, 44100, 16, 2)}; final ContentDescriptor CONTENT_DESCRIPTOR = new ContentDescriptor(FileTypeDescriptor.RAW); Vector deviceList = CaptureDeviceManager.getDeviceList(new AudioFormat(AudioFormat.LINEAR, 44100, 16, 2)); if (deviceList.size() > 0) di = (CaptureDeviceInfo) deviceList.firstElement(); else System.exit(-1); final Format[] DIFORMAT = di.getFormats(); //MediaLocator file = new MediaLocator("file:Startup.wav"); System.out.println(DIFORMAT[0]); System.out.println(FORMATS[0]); try { mediaProcessor = Manager.createRealizedProcessor(new ProcessorModel(di.getLocator(), FORMATS, CONTENT_DESCRIPTOR)); } catch (NoProcessorException e) { System.out.println(e); } catch (IOException e) { System.out.println(e); } DataSource source = mediaProcessor.getDataOutput(); Player audioPlayer = Manager.createRealizedPlayer(source); audioPlayer.start(); //DataSink dataSink = null; /* * try { MediaLocator dest = new MediaLocator("file://foo.wav"); * dataSink = Manager.createDataSink(mediaProcessor.getDataOutput(), * dest); dataSink.open(); } catch (NoDataSinkException e) { * System.out.println(e); System.exit(-1); } catch (IOException e) { * System.exit(-1); } catch (SecurityException e) { System.exit(-1); } */ } public static void main(String[] args) { try { CaptureAudio capture = new CaptureAudio(); System.out.println(" Press the Enter key to exit"); System.in.read(); System.out.println("-> Exiting"); } catch (Exception ex) { ex.printStackTrace(); } System.exit(0); } } |
Geef mij nog een joint zei de goudvis, misschien word ik haai