-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat.go
More file actions
28 lines (24 loc) · 756 Bytes
/
format.go
File metadata and controls
28 lines (24 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package wave
import (
"encoding/binary"
"io"
)
// Format holds configuration about the WAVE.
type Format struct {
AudioFormat uint16 // 1 if PCM is used.
NumChans uint16 // Number of channels (1 = mono, 2 = stereo, ...)
SampleRate uint32 // Samples per second (44100, ...).
ByteRate uint32 // Average bytes per second.
BlockAlign uint16 // Bytes per sample.
BitsPerSample uint16 // Bits per sample.
}
// decodeFormat decodes a chunk in a format chunk.
func decodeFormat(r io.Reader) (Format, error) {
var dst Format
err := binary.Read(r, binary.LittleEndian, &dst)
return dst, err
}
// encode a format struct into an io.Writer.
func (f *Format) encode(w io.Writer) error {
return binary.Write(w, binary.LittleEndian, f)
}