code: func (p *PlaybackDevice) Write(buffer interface{}) (samples int, err error) {
  	bufferType := reflect.TypeOf(buffer)
  	if !(bufferType.Kind() == reflect.Array ||
  		bufferType.Kind() == reflect.Slice) {
  		return 0, errors.New("Write requires an array type")
  	}
  
  	sizeError := errors.New("Write requires a matching sample size")
  	switch bufferType.Elem().Kind() {
  	case reflect.Int8:
  		if p.formatSampleSize() != 1 {
  			return 0, sizeError
  		}
  	case reflect.Int16:
  		if p.formatSampleSize() != 2 {
  			return 0, sizeError
  		}
  	case reflect.Int32, reflect.Float32:
  		if p.formatSampleSize() != 4 {
  			return 0, sizeError
  		}
  	case reflect.Float64:
  		if p.formatSampleSize() != 8 {
  			return 0, sizeError
  		}
  	default:
  		return 0, errors.New("Write does not support this format")
  	}
  
  	val := reflect.ValueOf(buffer)
  	length := val.Len()
  	sliceData := val.Slice(0, length)
  
  	var frames = C.snd_pcm_uframes_t(length / p.Channels)
  	bufPtr := unsafe.Pointer(sliceData.Index(0).Addr().Pointer())
  
  	ret := C.snd_pcm_writei(p.h, bufPtr, frames)
  	if ret == -C.EPIPE {
  		C.snd_pcm_prepare(p.h)
  		return 0, ErrUnderrun
  	} else if ret < 0 {
  		return 0, createError("write error", C.int(ret))
  	}
  	samples = int(ret) * p.Channels
  	return
  }
docs: // Write writes a buffer of data to a playback device.