0

I use socket to send some voice data to another PC and I encoded my data before sending it using ALAW with this "setup":

AudioFormat.Encoding.ALAW, 
8000.0f        // sampleRate
8,             // sampleSizeInBits
1,             // channels
1,             // frameSize
8000.0f,       // frameRate
false);        // bigEndian

The problem is, it generates a small (but quite annoying) noise at receiver side when I don't speak anything at the microphone. When I speak, the noise is almost gone but not entirely.

When I change to ULAW (exactly same "setup") the noise doesn't exist at all, the sound is very clear.

Is there anything I can do about that? Is there any recommended setup to use along with ALAW? I really need to stick to ALAW because ULAW causes me some mess in the code (and too much modifications would be necessary).

Side note: I printed the buffer and without speaking to microphone it has lots of 8,-1,8,-1,8,0,8,0 type of pattern. I tried to force all 8 to become 0 but still not big difference. I tried that because with ULAW there are many 0's when I don't speak instead of 8's as for ALAW. This pattern that I'm talking about is from the (convert ALAW to PCM) PCM before being sent for playing by sound card. I took conversion algorithm from here if it is important: ALAW PCM Conversions

Catalin Bcn
  • 13
  • 1
  • 6

1 Answers1

2

Check the silence suppression settings. And be shure that there is not some implicit codec conversion.

A-law vs u-Law A-law and u-law are two algorithms that are used in modifying an input signal for digitization. These algorithms are implemented in telephony systems all over the world. The two algorithms have a fairly minimal difference and most people would not know the difference. The first difference between the two is the dynamic range of the ouput; U-law has a larger dynamic range than a-law. Dynamic range is basically the ratio between the quietest and loudest sound that can be represented in the signal. The downside of having a higher dynamic range is greater distortion of small signals. This simply means that a-law would sound better than u-law when the sound input is very soft.

Read more: Difference Between A-law and u-Law | Difference Between | A-law vs u-Law http://www.differencebetween.net/technology/difference-between-a-law-and-u-law/#ixzz3eIfw2LtV

frhack
  • 4,862
  • 2
  • 28
  • 25
  • Where may I check for the silence suppression settings? By implicit codec you mean built in by jdk when using ais = AudioSystem.getAudioInputStream(PCMFormat, ais) ? Because if so, that may be the problem as I use both that command and the algorithms that I post a link (edited) and there may be a difference between them. But I can't discard any of them as the first is mandatory and I also need the external algorithm for some other operations. – Catalin Bcn Jun 27 '15 at 22:01
  • in your java code do you specify the same codec ? If not it's possible that some default codec is involved and so there is some auto conversion. – frhack Jun 27 '15 at 22:05
  • Yes I specify AudioFormat.Encoding.ALAW with all that setup posted above. Seems like, as you said, voice activation detection is activated, but why only for ALAW and not for ULAW? And how may I deactivate it? – Catalin Bcn Jun 27 '15 at 22:07
  • I suggest you to double check your code and confiugrations. It seems there is no issue with alaw. Use the latest library, check everything and retry. – frhack Jun 27 '15 at 22:26