File: headers.go

package info (click to toggle)
golang-github-cryptix-wav 0.0~git20180415.8bdace6-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 164 kB
  • sloc: makefile: 5
file content (45 lines) | stat: -rw-r--r-- 859 bytes parent folder | download | duplicates (2)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package wav

import "time"

const (
	maxSize = 2 << 31
)

var (
	tokenRiff       = [4]byte{'R', 'I', 'F', 'F'}
	tokenWaveFormat = [4]byte{'W', 'A', 'V', 'E'}
	tokenChunkFmt   = [4]byte{'f', 'm', 't', ' '}
	tokenData       = [4]byte{'d', 'a', 't', 'a'}
)

// File describes the WAV file
type File struct {
	SampleRate      uint32
	SignificantBits uint16
	Channels        uint16
	NumberOfSamples uint32
	Duration        time.Duration
	AudioFormat     uint16
	SoundSize       uint32
	Canonical       bool
	BytesPerSecond  uint32
}

// 12 byte header
type riffHeader struct {
	Ftype       [4]byte
	ChunkSize   uint32
	ChunkFormat [4]byte
}

// 20
type riffChunkFmt struct {
	LengthOfHeader uint32
	AudioFormat    uint16 // 1 = PCM not compressed
	NumChannels    uint16
	SampleRate     uint32
	BytesPerSec    uint32
	BytesPerBloc   uint16
	BitsPerSample  uint16
}