Checkpoint

This commit is contained in:
maze authored and maze committed 2026-10-29 17:29:41 +01:00
1 parent 0295eb1ad2
commit b8a493b93d
138 files changed
+1898 -57607

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
package audio
import (
"encoding/binary"
"errors"
)
var ErrFormat = errors.New("invalid audio format")
type Format uint
// Audio format.
const (
ByteFormat Format = iota
Int8Format
Int16LEFormat
Int16BEFormat
Int32LEFormat
Int32BEFormat
invalidFormat
)
func (f Format) Order() binary.ByteOrder {
switch f {
case Int16LEFormat, Int32LEFormat:
return binary.LittleEndian
case Int16BEFormat, Int32BEFormat:
return binary.BigEndian
default:
return binary.NativeEndian
}
}
func (f Format) BytesPerSample() int {
switch f {
case ByteFormat, Int8Format:
return 8
case Int16LEFormat, Int16BEFormat:
return 16
case Int32LEFormat, Int32BEFormat:
return 32
default:
return 0
}
}