read data as int16
This commit is contained in:
parent
b9257adf5f
commit
e5172787a1
12
main.go
12
main.go
|
@ -11,6 +11,7 @@ import "C"
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/binary"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
@ -42,7 +43,7 @@ func main() {
|
|||
|
||||
C.projectm_set_window_size(handle, 800, 600)
|
||||
|
||||
preset := C.CString("/usr/share/projectM/presets/presets_projectM/Unchained - ReAwoke.milk")
|
||||
preset := C.CString("/usr/share/projectM/presets/presets_stock/Zylot - Wisps.milk")
|
||||
C.projectm_load_preset_file(handle, preset, false)
|
||||
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
|
@ -58,15 +59,14 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
audioData := make([]byte, 4096)
|
||||
n, err := reader.Read(audioData)
|
||||
audioData := make([]int16, 4096)
|
||||
|
||||
err = binary.Read(reader, binary.LittleEndian, audioData)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ptr := C.CBytes(audioData)
|
||||
|
||||
C.projectm_pcm_add_float(handle, (*C.float)(ptr), C.uint(n/C.sizeof_float), C.PROJECTM_STEREO)
|
||||
C.projectm_pcm_add_int16(handle, (*C.int16_t)(&audioData[0]), C.uint(len(audioData)), C.PROJECTM_STEREO)
|
||||
|
||||
C.projectm_opengl_render_frame(handle)
|
||||
window.GLSwap()
|
||||
|
|
Loading…
Reference in New Issue