Dag mensen, ik ben bezig om een programma te maken die geluid opneemt van de microphone ingang. Dit moet dan opgeslagen in wav / wma.
Wat ik op dit moment heb is het volgende, maar het gaat mis zodra ik gebruik maak van de DriverGuid.
Terwijl is wel de ingang in collDevices heb zitten.
Wat ik geprobeerd heb is eigenlijk dat ik dit script van het internet gehaald heb. Ik heb wel gespeeld met ide Guid maar krijg de volgende fout melding:
Wat ik op dit moment heb is het volgende, maar het gaat mis zodra ik gebruik maak van de DriverGuid.
Terwijl is wel de ingang in collDevices heb zitten.
C#:
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
| public partial class frmAudioRecord : Form { // ### Variables. private Device objDevice; private WaveFormat objWaveFormat; private Buffer objBuffer; private BufferDescription objBufferDescription; private Capture objCapture; private CaptureBuffer objCaptureBuffer; private CaptureBufferDescription objCaptureBufferDescription; private MemoryStream objMemoryStream; private byte[] objStreamBuffer; private Guid objGuidID; // ### Constructor. public frmAudioRecord() { // ### Initialize component. InitializeComponent(); CaptureDevicesCollection collDevices = new CaptureDevicesCollection(); for (int i = 0; i < collDevices.Count; i++) { if (collDevices[i].DriverGuid.ToString() != "") { this.objGuidID = collDevices[i].DriverGuid; } } // ### Create a new device. try { this.objDevice = new Device(collDevices[1].DriverGuid); } catch (DirectXException ex) { MessageBox.Show(ex.ToString()); } // ### Wave format. this.objWaveFormat = new WaveFormat(); this.objWaveFormat.BitsPerSample = 8; this.objWaveFormat.BlockAlign = 1; this.objWaveFormat.Channels = 1; this.objWaveFormat.AverageBytesPerSecond = 20500; this.objWaveFormat.SamplesPerSecond = 20500; this.objWaveFormat.FormatTag = WaveFormatTag.Pcm; // ### Buffer description. this.objBufferDescription = new BufferDescription(); this.objBufferDescription.Format = this.objWaveFormat; this.objBufferDescription.BufferBytes = 100000; this.objBufferDescription.ControlPositionNotify = true; this.objBufferDescription.ControlFrequency = true; this.objBufferDescription.ControlPan = true; this.objBufferDescription.ControlVolume = true; // ### Create a new buffer. this.objBuffer = new Buffer(this.objBufferDescription, this.objDevice); // ### Set cooperative level. this.objDevice.SetCooperativeLevel(this, CooperativeLevel.Priority); // ### Create a new capture. this.objCapture = new Capture(); // ### Capture buffer description. this.objCaptureBufferDescription = new CaptureBufferDescription(); this.objCaptureBufferDescription.BufferBytes = 100000; this.objCaptureBufferDescription.Format = this.objWaveFormat; // ### Create capture buffer. this.objCaptureBuffer = new CaptureBuffer(this.objCaptureBufferDescription, this.objCapture); // ### Memory stream buffer. this.objStreamBuffer = new byte[100000]; for (int i = 0; i < 100000; i++) { this.objStreamBuffer[i] = 0; } // ### Create memory stream. this.objMemoryStream = new MemoryStream(this.objStreamBuffer); } private void btnOpnemen_Click(object sender, EventArgs e) { this.objCaptureBuffer.Start(true); } private void btnBeluisteren_Click(object sender, EventArgs e) { this.objCaptureBuffer.Read(0, this.objMemoryStream, 100000, LockFlag.None); this.objBuffer.Write(0, this.objMemoryStream, (int)this.objMemoryStream.Length, LockFlag.EntireBuffer); this.objBuffer.Play(0, BufferPlayFlags.Looping); } private void Stoppen_Click(object sender, EventArgs e) { this.objCaptureBuffer.Stop(); } } |
Wat ik geprobeerd heb is eigenlijk dat ik dit script van het internet gehaald heb. Ik heb wel gespeeld met ide Guid maar krijg de volgende fout melding:
[ Voor 7% gewijzigd door Verwijderd op 23-04-2006 12:52 ]