Salut,
Mon problème vient du fait que je n'arrive pas à écouter en live, le son provenant du micro.
Surement du à une mauvaise utilisation des QueueBuffers.
Le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
 
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.AL10;
import org.lwjgl.openal.ALC10;
import org.lwjgl.openal.ALC11;
import org.lwjgl.openal.ALCdevice;
 
 
public class ClientOpenAL extends Thread{
	private ALCdevice aDefaultDevice;
	private ALCdevice aInputDevice;	
	private IntBuffer aSampleCount;
	private ByteBuffer aSample;
	private IntBuffer aBuffers;
	private IntBuffer aSource;
	private boolean aStop;
 
	public void startOpenAL() throws LWJGLException {
		//Creation du context et ouverture du device
		AL.create(null, 8000, 60, false);
		this.aDefaultDevice = AL.getDevice();
 
		//Verif du support de la capture audio
		if (!ALC10.alcIsExtensionPresent(this.aDefaultDevice, "ALC_EXT_CAPTURE")) {
			System.out.println("pas de perif");
			return;
		}
 
		//Initialisation des Buffers
		this.aSampleCount = BufferUtils.createIntBuffer(1);
		this.aSample = BufferUtils.createByteBuffer(1);
		this.aSource = BufferUtils.createIntBuffer(1);
		this.aBuffers = BufferUtils.createIntBuffer(2);
 
		//Ouverture du device de capture
		this.aInputDevice = ALC11.alcCaptureOpenDevice(null, 8000, AL10.AL_FORMAT_MONO16, 3200);
	}
 
	public void stopOpenAL() {
		ALC11.alcCaptureCloseDevice(this.aInputDevice);
		AL.destroy();
	}
 
	public void getStream(int pBuf) {
 
		//Recupere le nombre d'echantillons
		ALC10.alcGetInteger(this.aInputDevice, ALC11.ALC_CAPTURE_SAMPLES, this.aSampleCount);
 
		//Recupere chaque echantillons dans le buffer
		ALC11.alcCaptureSamples(this.aInputDevice, this.aSample, this.aSampleCount.get(0));
 
		//Transfer les echantillons en fonction du format & de la frequence...
		AL10.alBufferData(pBuf, AL10.AL_FORMAT_MONO16, this.aSample, 8000);
	}
 
	public void run() {
		try {
			startOpenAL();
 
			//Creer la source
			AL10.alGenSources(this.aSource);
 
			//Demarrage de la capture
			ALC11.alcCaptureStart(this.aInputDevice);
 
			getStream(this.aBuffers.get(0));
			getStream(this.aBuffers.get(1));
			AL10.alSourcePlay(this.aSource.get(0));	
 
			while(!this.aStop) {
 
				int processed = AL10.alGetSourcei(this.aSource.get(0), AL10.AL_BUFFERS_PROCESSED);
				System.out.println(processed);
				while(processed-- > 0) {
					IntBuffer buffer = BufferUtils.createIntBuffer(1);
					AL10.alSourceUnqueueBuffers(this.aSource.get(0), buffer);
 
					getStream(buffer.get(0));
 
					//Ajoute le buffer a la source
					AL10.alSourceQueueBuffers(this.aSource.get(0), buffer);	
				}
 
				//Si la source est eteinte on la rallume
				int state = AL10.alGetSourcei(this.aSource.get(0), AL10.AL_SOURCE_STATE);
				if(state!=AL10.AL_PLAYING)
					AL10.alSourcePlay(this.aSource.get(0));	
			}
 
			//Stop la capture
			ALC11.alcCaptureStop(this.aInputDevice);
 
			stopOpenAL();
		} catch (LWJGLException e) {
			e.printStackTrace();
		}
	}
}
Si vous avez des conseils ou une réponse...
Merci d'avance.