G729 Decoder Issue - Still Getting Noisy Out
Hi
The issue in #17 is not fixed, still noisy output.
efae4649f1746a69adb3b662572edf00.wav
Sharing a PCAP File, which has RTP so that you can test it out on your side also.
thanks, let me check on that
On Thu, Feb 26, 2026 at 9:40 AM Kinshuk Bairagi @.***> wrote:
kingster created an issue (loreste/siprec#19) https://github.com/loreste/siprec/issues/19
Hi
The issue in #17 https://github.com/loreste/siprec/issues/17 is not fixed, still noisy output.
efae4649f1746a69adb3b662572edf00.wav https://github.com/user-attachments/files/25578632/efae4649f1746a69adb3b662572edf00.wav
Sharing a PCAP File, which has RTP so that you can test it out on your side also.
g729.pcap.zip https://github.com/user-attachments/files/25578652/g729.pcap.zip
— Reply to this email directly, view it on GitHub https://github.com/loreste/siprec/issues/19, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOBAMEVVVDBI2YM3QMP5WD4N4AXXAVCNFSM6AAAAACWAUNAFSVHI2DSMVQWIX3LMV43ASLTON2WKOZTHE4TKOJVGY3DCNA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hi @kingster,
Thanks for reporting this and providing the PCAP - it was very helpful for diagnosis.
The fix has been pushed (commit 26df767). The root cause was per-subframe adaptive scaling that caused amplitude pumping, resulting in noisy/distorted audio.
Changes made:
- Frame-level scaling instead of per-subframe scaling
- Smooth gain adaptation to prevent pumping
- Proper gain table values
- Safety limits in LP synthesis
I tested the fix against your PCAP file - it now decodes all 3,564 packets with 0% clipping (previously was 65%+).
Please test with a new call and let us know if the audio quality is improved.
update the ticket after you've tested.
Maybe we can try to create a test case to run the pcap file and create a wav file, and validate that its actually playable?
I got a test case created and ran the pcap againts it, I think that we should definitely create a wave file and validate it to make sure it is playable.
bcg729 is probably the best option.
Fix Implemented
The G.729 decoder has been completely rewritten to address the noisy/distorted audio output.
Root Cause
The original custom G.729 decoder implementation had two critical issues:
- Incorrect codec implementation - The custom decoder was not properly implementing the ITU-T G.729 CS-ACELP algorithm
- Stateless decoding - G.729 is a stateful codec that requires decoder state to persist across packets within the same stream. Creating a new decoder for each packet caused audio distortion and muffled output.
Solution
- Replaced the custom decoder with the
bcg729library (ITU-T compliant implementation) viagithub.com/pidato/audio/g729Go bindings - Added
G729DecoderPoolto maintain persistent decoder state per SSRC (stream identifier) - Updated RTP processing to use the stateful decoder for G.729 streams
Validation
Using the provided PCAP file, both audio streams now decode correctly:
| Stream | Before Fix | After Fix |
|---|---|---|
| 0x690923AB | RMS 185, 16% peak | RMS 2805, full dynamic range |
| 0x71646F07 | RMS 45, 8% peak | RMS 1370, 63% peak |
Files Changed
pkg/media/audio_conversion.go- New bcg729-based decoder with stateful poolpkg/media/rtp.go- Updated to use stateful decoder for G.729 streamspkg/media/audio_conversion_test.go- Updated tests
@kingster - Please validate this fix with your setup and confirm the audio quality is acceptable before we close this issue.
Something not making sense. I recompiled, and re-recorded, and still getting this noisy recordings
ebbaec2b38481f5c46ee7d7f5134bb6d.wav
Build Time I see these logs but the binary gets generated.
GOOS=linux GOARCH=amd64 go build -o siprec ./cmd/siprec
github.com/pidato/audio/g729: build constraints exclude all Go files in /Users/kinshuk.bairagi/go/pkg/mod/github.com/pidato/[email protected]/g729
install bcg729 first
https://gitlab.linphone.org/BC/public/bcg729.git
Hmm let me try that
I had checked https://github.com/pidato/audio/tree/main/g729%2Flinux%2Famd64
and assumed it has the prebuild files that is required.
Will try installing from source.
@kingster - The build warning you're seeing explains the issue:
github.com/pidato/audio/g729: build constraints exclude all Go files in .../g729
This means the bcg729 library bindings are not being compiled into your binary. The github.com/pidato/audio/g729 package requires:
- CGO enabled (default on native builds, but must be explicitly enabled for cross-compilation)
- bcg729 native library installed on the build machine
To fix this:
On Ubuntu/Debian (build machine):
# Install bcg729 development files
sudo apt-get install libbcg729-dev
# Or build from source:
git clone https://gitlab.linphone.org/BC/public/bcg729.git
cd bcg729
cmake .
make
sudo make install
sudo ldconfig
On macOS:
brew install bcg729
Then rebuild with CGO enabled:
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o siprec ./cmd/siprec
If you're cross-compiling (e.g., building Linux binary on macOS), you'll need a cross-compiler toolchain with bcg729 available for the target platform. The easiest approach is to build directly on the Linux server where siprec will run.
Verification
After rebuilding, you should NOT see the "build constraints exclude all Go files" warning. The bcg729 package should compile normally.
did it work for you? Should I close this?
Yes working perfectly :)
Thank you so much!