Move functions

This commit is contained in:
Milan Nikolic 2023-11-09 08:55:58 +01:00
parent 9f257fc589
commit f953e65a3a
No known key found for this signature in database
GPG key ID: 9229D0EAA3AA4E75
6 changed files with 184 additions and 215 deletions

View file

@ -40,20 +40,73 @@ func internalAudioStreamCallbackGo(data unsafe.Pointer, frames C.int) {
}
}
// newWaveFromPointer - Returns new Wave from pointer
func newWaveFromPointer(ptr unsafe.Pointer) Wave {
return *(*Wave)(ptr)
}
// cptr returns C pointer
func (w *Wave) cptr() *C.Wave {
return (*C.Wave)(unsafe.Pointer(w))
}
// newSoundFromPointer - Returns new Sound from pointer
func newSoundFromPointer(ptr unsafe.Pointer) Sound {
return *(*Sound)(ptr)
}
func (s *Sound) cptr() *C.Sound {
return (*C.Sound)(unsafe.Pointer(s))
}
// newAudioStreamFromPointer - Returns new AudioStream from pointer
func newAudioStreamFromPointer(ptr unsafe.Pointer) AudioStream {
return *(*AudioStream)(ptr)
}
// cptr returns C pointer
func (a *AudioStream) cptr() *C.AudioStream {
return (*C.AudioStream)(unsafe.Pointer(a))
}
// newMusicFromPointer - Returns new Music from pointer
func newMusicFromPointer(ptr unsafe.Pointer) Music {
return *(*Music)(ptr)
}
// Sound source type
type Sound struct {
Stream AudioStream
FrameCount uint32
_ [4]byte
}
// Music type (file streaming from memory)
// NOTE: Anything longer than ~10 seconds should be streamed
type Music struct {
Stream AudioStream
FrameCount uint32
Looping bool
CtxType int32
CtxData unsafe.Pointer
}
// AudioStream type
// NOTE: Useful to create custom audio streams not bound to a specific file
type AudioStream struct {
// Buffer
Buffer *C.rAudioBuffer
// Processor
Processor *C.rAudioProcessor
// Frequency (samples per second)
SampleRate uint32
// Bit depth (bits per sample): 8, 16, 32 (24 not supported)
SampleSize uint32
// Number of channels (1-mono, 2-stereo)
Channels uint32
_ [4]byte
}
// InitAudioDevice - Initialize audio device and context
func InitAudioDevice() {
C.InitAudioDevice()