func (s *Sound) LoadPCMData() { format := 0 if s.Channels > 1 { switch s.BitsPerSample { case 8: format = C.AL_FORMAT_STEREO8 case 16: format = C.AL_FORMAT_STEREO16 } } else { switch s.BitsPerSample { case 8: format = C.AL_FORMAT_MONO8 case 16: format = C.AL_FORMAT_MONO16 } } C.alGenBuffers(1, &s.buffer) C.alBufferData(s.buffer, C.ALenum(format), unsafe.Pointer(&s.Data[0]), C.ALsizei(s.Size), C.ALsizei(s.Frequency)) }
// SetData() specifies the sample data the buffer should use. // For FormatMono16 and FormatStereo8 the data slice must be a // multiple of two bytes long; for FormatStereo16 the data slice // must be a multiple of four bytes long. The frequency is given // in Hz. // Renamed, was BufferData. func (self Buffer) SetData(format int32, data []byte, frequency int32) { C.alBufferData(C.ALuint(self), C.ALenum(format), unsafe.Pointer(&data[0]), C.ALsizei(len(data)), C.ALsizei(frequency)) }
func (buf Buffer) BufferData(data Data) error { C.alBufferData(buf.buffer, C.ALenum(data.Format), unsafe.Pointer(&data.Data[0]), C.ALsizei(C.int(len(data.Data))), C.ALsizei(C.int(data.Frequency))) return GetError() }
func alBufferData(b Buffer, format uint32, data []byte, freq int32) { C.alBufferData(C.ALuint(b), C.ALenum(format), unsafe.Pointer(&data[0]), C.ALsizei(len(data)), C.ALsizei(freq)) }
func (self Buffer) SetDataUInt(format Format, data []uint16, frequency int32) { C.alBufferData(C.ALuint(self), C.ALenum(format), unsafe.Pointer(&data[0]), C.ALsizei(len(data)*2), C.ALsizei(frequency)) }
func (self Buffer) SetDataStereo16(data [][2]int16, frequency int32) { C.alBufferData(C.ALuint(self), C.ALenum(FormatStereo16), unsafe.Pointer(&data[0]), C.ALsizei(len(data)*4), C.ALsizei(frequency)) }
func (buffer Buffer) BufferData(format ALenum, data interface{}, size int, freq int) { C.alBufferData(C.ALuint(buffer), C.ALenum(format), ptr(data), C.ALsizei(size), C.ALsizei(freq)) }