Bonjour,

J'ai un problème de qualité de son lorsque je l'envoie sur un haut parleur. La technique est assez différente puisque je suis obligé d'utiliser un tableau d'entier. Mais le plus simple est de regarder le code, le voici :

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
AudioInputStream audioInputStream = null;
 
try {
    AudioInputStream originalAudioInputStream = AudioSystem.getAudioInputStream(waveFile);
    AudioFormat originalFormat = originalAudioInputStream.getFormat();
    AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 
        originalFormat.getSampleRate(), 
        originalFormat.getSampleSizeInBits(), 
        originalFormat.getChannels(), 
        originalFormat.getFrameSize(), 
        originalFormat.getFrameRate(), 
        originalFormat.isBigEndian()
    );
    audioInputStream = AudioSystem.getAudioInputStream(decodedFormat, originalAudioInputStream);
 
    byte[] soundByte = new byte[2];
    int[] soundInt = new int[882];
    int index = 0;
 
    while (audioInputStream.read(soundByte, 0, soundByte.length) != -1) {
 
        soundInt[index] = ((soundByte[1] << 8) | soundByte[0]);
 
        if (index == (soundInt.length - 1)) {
            index = 0;
            speaker.write(soundInt);
            Utils.wait(20);
        } else {
            index++;
        }
    }
} catch(Exception e) {
    e.printStackTrace();
} finally {
    if (audioInputStream != null) {
        try {
            audioInputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Donc le problème est bien la qualité très brouillé du son, sinon le fichier wav signé 16 bits mono à 44100Hz passe. La technique ne doit pas bien aller... en plus ca ne support que les wav... et encore.

Auriez-vous des idées?

Cordialement,
Trancer.