Exemplo n.º 1
0
Arquivo: audio.go Projeto: velour/ui
func (s *Sound) mix(stream *C.Uint8, sz C.int) {
	vol := C.int(C.SDL_MIX_MAXVOLUME)

	left := uintptr(sz)
	dst := uintptr(unsafe.Pointer(stream))
	for left > 0 {
		data := uintptr(s.data) + uintptr(s.pos)

		n := uintptr(left)
		if s.len-s.pos < n {
			n = s.len - s.pos
		}

		C.SDL_MixAudio((*C.Uint8)(unsafe.Pointer(dst)), (*C.Uint8)(unsafe.Pointer(data)), C.Uint32(n), vol)
		left -= n
		s.pos += n
		dst += uintptr(n)

		if !s.repeat {
			break
		} else if s.pos >= s.len {
			s.pos = 0
		}
	}
}
Exemplo n.º 2
0
func MixAudio(dst, src *uint8, len_ uint32, volume int) {
	_dst := (*C.Uint8)(unsafe.Pointer(dst))
	_src := (*C.Uint8)(unsafe.Pointer(src))
	_len := (C.Uint32)(len_)
	_volume := (C.int)(volume)
	C.SDL_MixAudio(_dst, _src, _len, _volume)
}
Exemplo n.º 3
0
func MixAudio(dst, src []byte, vol int) error {
	if len(dst) != len(src) {
		return errors.New("len(dst) != len(src)")
	}

	C.SDL_MixAudio(
		(*C.Uint8)(unsafe.Pointer(&dst[0])),
		(*C.Uint8)(unsafe.Pointer(&src[0])),
		C.Uint32(len(dst)),
		C.int(vol),
	)

	return nil
}
Exemplo n.º 4
0
// MixAudio (https://wiki.libsdl.org/SDL_MixAudio)
func MixAudio(dst, src *uint8, len_ uint32, volume int) {
	_dst := (*C.Uint8)(unsafe.Pointer(dst))
	_src := (*C.Uint8)(unsafe.Pointer(src))
	C.SDL_MixAudio(_dst, _src, C.Uint32(len_), C.int(volume))
}
Exemplo n.º 5
0
func MixAudio(dst, src []byte, volume int) {
	C.SDL_MixAudio((*C.Uint8)(unsafe.Pointer(&dst[0])), (*C.Uint8)(unsafe.Pointer(&src[0])), C.Uint32(len(dst)), C.int(volume))
}
Exemplo n.º 6
0
func MixAudio(dst, src *C.Uint8, length C.Uint32, volume C.int) {
	C.SDL_MixAudio(dst, src, length, volume)
}