func (d *Decoder) WasPCMAccessed() bool {
	if d == nil {
		return false
	}
	return d.pcmDataAccessed
}
WasPCMAccessed returns positively if the PCM data was previously accessed.
package wav
import (
	"bytes"
	"encoding/binary"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"time"
	"github.com/go-audio/audio"
	"github.com/go-audio/riff"
)
var (
	CIDList = [4]byte{'L', 'I', 'S', 'T'}
	CIDSmpl = [4]byte{'s', 'm', 'p', 'l'}
	CIDInfo = []byte{'I', 'N', 'F', 'O'}
	CIDCue = [4]byte{'c', 'u', 'e', 0x20}
)
type Decoder struct {
	r      io.ReadSeeker
	parser *riff.Parser
	NumChans   uint16
	BitDepth   uint16
	SampleRate uint32
	AvgBytesPerSec uint32
	WavAudioFormat uint16
	err             error
	PCMSize         int
	pcmDataAccessed bool
	PCMChunk *riff.Chunk
	Metadata *Metadata
}
func NewDecoder(r io.ReadSeeker) *Decoder {
	return &Decoder{
		r:      r,
		parser: riff.New(r),
	}
}
func (d *Decoder) Seek(offset int64, whence int) (int64, error) {
	return d.r.Seek(offset, whence)
}
func (d *Decoder) SampleBitDepth() int32 {
	if d == nil {
		return 0
	}
	return int32(d.BitDepth)
}
func (d *Decoder) PCMLen() int64 {
	if d == nil {
		return 0
	}
	return int64(d.PCMSize)
}
func (d *Decoder) Err() error {
	if d.err == io.EOF {
		return nil
	}
	return d.err
}
func (d *Decoder) EOF() bool {
	if d == nil || d.err == io.EOF {
		return true
	}
	return false
}
func (d *Decoder) IsValidFile() bool {
	d.err = d.readHeaders()
	if d.err != nil {
		return false
	}
	if d.NumChans < 1 {
		return false
	}
	if d.BitDepth < 8 {
		return false
	}
	if d, err := d.Duration(); err != nil || d <= 0 {
		return false
	}
	return true
}
func (d *Decoder) ReadInfo() {
	d.err = d.readHeaders()
}
func (d *Decoder) ReadMetadata() {
	if d.Metadata != nil {
		return
	}
	d.ReadInfo()
	if d.Err() != nil || d.Metadata != nil {
		return
	}
	var (
		chunk *riff.Chunk
		err   error
	)
	for err == nil {
		chunk, err = d.parser.NextChunk()
		if err != nil {
			break
		}
		switch chunk.ID {
		case CIDList:
			if err = DecodeListChunk(d, chunk); err != nil {
				if err != io.EOF {
					d.err = err
				}
			}
			if d.Metadata != nil && d.Metadata.SamplerInfo != nil {
				break
			}
		case CIDSmpl:
			if err = DecodeSamplerChunk(d, chunk); err != nil {
				if err != io.EOF {
					d.err = err
				}
			}
		case CIDCue:
			if err = DecodeCueChunk(d, chunk); err != nil {
				if err != io.EOF {
					d.err = err
				}
			}
		default:
			chunk.Drain()
		}
	}
}
func (d *Decoder) FwdToPCM() error {
	if d == nil {
		return fmt.Errorf("PCM data not found")
	}
	d.err = d.readHeaders()
	if d.err != nil {
		return nil
	}
	var chunk *riff.Chunk
	for d.err == nil {
		chunk, d.err = d.NextChunk()
		if d.err != nil {
			return d.err
		}
		if chunk.ID == riff.DataFormatID {
			d.PCMSize = chunk.Size
			d.PCMChunk = chunk
			break
		}
		if chunk.ID == CIDList {
			DecodeListChunk(d, chunk)
		}
		chunk.Drain()
	}
	if chunk == nil {
		return fmt.Errorf("PCM data not found")
	}
	d.pcmDataAccessed = true
	return nil
}