func (c *Parser) IDnSize() ([4]byte, uint32, error) {
	var ID [4]byte
	var blockSize uint32
	if err := binary.Read(c.r, binary.BigEndian, &ID); err != nil {
		return ID, blockSize, err
	}
	if err := binary.Read(c.r, binary.LittleEndian, &blockSize); err != err {
		return ID, blockSize, err
	}
	return ID, blockSize, nil
}
IDnSize returns the next ID + block size
package riff
import (
	"encoding/binary"
	"errors"
	"fmt"
	"io"
	"sync"
	"time"
)
type Parser struct {
	r io.Reader
	Chan chan *Chunk
	ChunkParserTimeout time.Duration
	Wg *sync.WaitGroup
	ID [4]byte
	Size uint32
	Format [4]byte
	wavHeaderSize uint32
	WavAudioFormat uint16
	NumChannels uint16
	SampleRate uint32
	AvgBytesPerSec uint32
	BlockAlign uint16
	BitsPerSample uint16
}
func (c *Parser) ParseHeaders() error {
	id, size, err := c.IDnSize()
	if err != nil {
		return err
	}
	c.ID = id
	if c.ID != RiffID {
		return fmt.Errorf("%s - %s", c.ID, ErrFmtNotSupported)
	}
	c.Size = size
	if err := binary.Read(c.r, binary.BigEndian, &c.Format); err != nil {
		return err
	}
	return nil
}
func (c *Parser) Duration() (time.Duration, error) {
	if c == nil {
		return 0, errors.New("can't calculate the duration of a nil pointer")
	}
	if c.ID == [4]byte{} || c.AvgBytesPerSec == 0 {
		err := c.Parse()
		if err != nil {
			return 0, nil
		}
	}
	switch c.Format {
	case WavFormatID:
		return c.wavDuration()
	default:
		return 0, ErrFmtNotSupported
	}
}
func (c *Parser) String() string {
	out := fmt.Sprintf("Format: %s - ", c.Format)
	if c.Format == WavFormatID {
		out += fmt.Sprintf("%d channels @ %d / %d bits - ", c.NumChannels, c.SampleRate, c.BitsPerSample)
		d, _ := c.Duration()
		out += fmt.Sprintf("Duration: %f seconds", d.Seconds())
	}
	return out
}
func (c *Parser) NextChunk() (*Chunk, error) {
	if c == nil {
		return nil, errors.New("can't calculate the duration of a nil pointer")
	}
	id, size, err := c.IDnSize()
	if err != nil {
		return nil, err
	}
	if size%2 == 1 {
		size++
	}
	ch := &Chunk{
		ID:   id,
		Size: int(size),
		R:    c.r,
	}
	return ch, nil
}