-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mulaw to wav headers linaer 16 working
- Loading branch information
Showing
10 changed files
with
121 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v0.1.5 | ||
v0.2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package utils | ||
|
||
import "encoding/binary" | ||
|
||
type ENDIANNESS int | ||
|
||
const ( | ||
LITTLE_ENDIAN ENDIANNESS = iota | ||
BIG_ENDIAN | ||
) | ||
|
||
// GetEndianess returns the endianness of the CPU safety | ||
func GetEndianess() ENDIANNESS { | ||
if binary.LittleEndian.Uint16([]byte{0x01, 0x00}) == 1 { | ||
return LITTLE_ENDIAN | ||
} else { | ||
return BIG_ENDIAN | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package utils | ||
|
||
import "testing" | ||
|
||
func TestGetEndianess(t *testing.T) { | ||
e := GetEndianess() | ||
if e != LITTLE_ENDIAN && e != BIG_ENDIAN { | ||
t.Errorf("unexpected endianess: %d", e) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
package utils | ||
|
||
func DecodeFromULaw(uLaw byte) int16 { | ||
pcm := ulawDecode[uLaw] | ||
return int16(pcm) | ||
// DecodeULawToPCM decodes raw ULaw-encoded audio data to linear PCM. | ||
// Each ULaw frame is 8-bit logarithmic PCM, which is converted to 16-bit linear PCM. | ||
func DecodeULawToPCM(ulaw []byte) []byte { | ||
if len(ulaw) == 0 { | ||
return nil | ||
} | ||
pcm := make([]byte, len(ulaw)*2) | ||
for i, ulawFrame := range ulaw { | ||
pcmFrame := mulawToPcmTable[ulawFrame] | ||
copy(pcm[i*2:], []byte{byte(pcmFrame), byte(pcmFrame >> 8)}) | ||
} | ||
return pcm | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2b52c93
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.