func (b *PCMBuffer) AsI8() (out []int8) {
	if b == nil {
		return nil
	}
	switch b.DataType {
	case DataTypeI8:
		return b.I8
	case DataTypeI16:
		out = make([]int8, len(b.I16))
		for i := 0; i < len(b.I16); i++ {
			out[i] = int8(b.I16[i])
		}
	case DataTypeI32:
		out = make([]int8, len(b.I32))
		for i := 0; i < len(b.I32); i++ {
			out[i] = int8(b.I32[i])
		}
	case DataTypeF32:
		out = make([]int8, len(b.F32))
		for i := 0; i < len(b.F32); i++ {
			out[i] = int8(b.F32[i])
		}
	case DataTypeF64:
		out = make([]int8, len(b.F64))
		for i := 0; i < len(b.F64); i++ {
			out[i] = int8(b.F64[i])
		}
	}
	return out
}
AsI8 returns the buffer's samples as int8 sample values.
If the buffer isn't in this format, a copy is created and converted.
Note that converting might result in loss of resolution.
package audio
import "math"
type PCMDataFormat uint8
const (
	DataTypeUnknown PCMDataFormat = iota
	DataTypeI8
	DataTypeI16
	DataTypeI32
	DataTypeF32
	DataTypeF64
)
var _ Buffer = (*PCMBuffer)(nil)
type PCMBuffer struct {
	Format *Format
	I8 []int8
	I16 []int16
	I32 []int32
	F32 []float32
	F64 []float64
	DataType PCMDataFormat
	SourceBitDepth uint8
}
func (b *PCMBuffer) Len() int {
	if b == nil {
		return 0
	}
	switch b.DataType {
	case DataTypeI8:
		return len(b.I8)
	case DataTypeI16:
		return len(b.I16)
	case DataTypeI32:
		return len(b.I32)
	case DataTypeF32:
		return len(b.F32)
	case DataTypeF64:
		return len(b.F64)
	default:
		return 0
	}
}
func (b *PCMBuffer) PCMFormat() *Format {
	if b == nil {
		return nil
	}
	return b.Format
}
func (b *PCMBuffer) NumFrames() int {
	if b == nil || b.Format == nil {
		return 0
	}
	numChannels := b.Format.NumChannels
	if numChannels == 0 {
		numChannels = 1
	}
	return b.Len() / numChannels
}
func (b *PCMBuffer) AsFloatBuffer() *FloatBuffer {
	newB := &FloatBuffer{}
	newB.Data = b.AsF64()
	if b.Format != nil {
		newB.Format = &Format{
			NumChannels: b.Format.NumChannels,
			SampleRate:  b.Format.SampleRate,
		}
	}
	return newB
}
func (b *PCMBuffer) AsFloat32Buffer() *Float32Buffer {
	newB := &Float32Buffer{}
	newB.Data = b.AsF32()
	if b.Format != nil {
		newB.Format = &Format{
			NumChannels: b.Format.NumChannels,
			SampleRate:  b.Format.SampleRate,
		}
	}
	return newB
}
func (b *PCMBuffer) AsIntBuffer() *IntBuffer {
	newB := &IntBuffer{}
	newB.Data = b.AsInt()
	if b.Format != nil {
		newB.Format = &Format{
			NumChannels: b.Format.NumChannels,
			SampleRate:  b.Format.SampleRate,
		}
	}
	return newB
}