Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shenjinti/go711
A G711 codec encode/decode writtren by golang
https://github.com/shenjinti/go711
Last synced: 17 days ago
JSON representation
A G711 codec encode/decode writtren by golang
- Host: GitHub
- URL: https://github.com/shenjinti/go711
- Owner: shenjinti
- License: bsd-3-clause
- Created: 2024-10-03T04:36:55.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-10-03T04:49:05.000Z (4 months ago)
- Last Synced: 2024-11-10T17:11:51.039Z (3 months ago)
- Language: Go
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go711
This is a simple G711 codec implementation in Go.
It supports both A-law (PCMA )and μ-law (PCMU) encoding and decoding.## Installation
```bash
go get github.com/shenjinti/go711
```## Usage Example
```go
func TestPCMA(t *testing.T) {
pcmBytes := []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}
// Encode PCM bytes to A-law bytes
alawBytes, err := EncodePCMA(pcmBytes)
if err != nil {
t.Fatal(err)
}
if len(alawBytes) != 4 {
t.Fatalf("a-law bytes length is not 4: %d", len(alawBytes))
}
// Decode A-law bytes to PCM bytes
pcmBytes, err = DecodePCMA(alawBytes)
if err != nil {
t.Fatal(err)
}
if len(pcmBytes) != 8 {
t.Fatal("PCM bytes length is not 8", len(pcmBytes))
}
}
```