Checkpoint
This commit is contained in:
138 files changed
+1898
-57607
No files matched your search
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user