Bonjour a tous,

j'ai trouver un code sur le net qui permet de lire un fichier audio wav en java.

J'ai adapter ce code a mes besoin (utilisation de thread pour la lecture, lecture en boucle ,et c....)

Voici 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
 
package Polyominos;
 
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
 
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException;
 
public class Sound extends Thread{
 
	private AudioFormat format;
	private byte[] samples;
 
	public Sound(){
		try{
			AudioInputStream stream = AudioSystem.getAudioInputStream(getClass().getClassLoader().getResourceAsStream("resources/tetris.wav"));
			format = stream.getFormat();
			samples = getSamples(stream);
		}
		catch (UnsupportedAudioFileException e){
			e.printStackTrace();
	}
	catch (IOException e){
			e.printStackTrace();
		}
	}
 
	public byte[] getSamples(){
		return samples;
	}
 
	public byte[] getSamples(AudioInputStream stream){
		int length = (int)(stream.getFrameLength() * format.getFrameSize());
		byte[] samples = new byte[length];
		DataInputStream in = new DataInputStream(stream);
		try{
			in.readFully(samples);
		}
		catch (IOException e){
			e.printStackTrace();
		}
		return samples;
	}
 
 
	public void play(InputStream source){
		// 100 ms buffer for real time change to the sound stream
		int bufferSize = format.getFrameSize() * Math.round(format.getSampleRate() / 10);
		byte[] buffer = new byte[bufferSize];
		SourceDataLine line;
		try{
			DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
			line = (SourceDataLine)AudioSystem.getLine(info);
			line.open(format, bufferSize);
		}
		catch (LineUnavailableException e){
			e.printStackTrace();
			return;
		}
		line.start();
		try{
			int numBytesRead = 0;
			while (numBytesRead != -1){
				numBytesRead = source.read(buffer, 0, buffer.length);
				if (numBytesRead != -1)
					line.write(buffer, 0, numBytesRead);
			}
		}
		catch (IOException e){
			e.printStackTrace();
		}
		line.drain();
		line.close();
 
 
	}
 
	public void run(){
	  while(true){
			Sound player = new Sound();
			InputStream stream = new ByteArrayInputStream(player.getSamples());
			player.play(stream);
		}
	}
 
 
}

Je voudrai savoir comment faire pour mettre en "muet". J'ai trouver ceci http://download.oracle.com/javase/6/...trol.Type.html

mais je ne trouve pas comment l'utilisé ... Pourriez vous me venir en aide ?
avez vous une idée ?

Je vous remercie d'avance pour votre aide