diff --git a/goborator.go b/goborator.go index 555ec81..3f5f5b3 100644 --- a/goborator.go +++ b/goborator.go @@ -136,5 +136,7 @@ func (g *Gaborator) analyze(block []float32) { //export cgoCallback func cgoCallback(ptr C.uintptr_t, data *C.float, size C.int) { - cgo.Handle(ptr).Value().(chan []float32) <- unsafe.Slice((*float32)(data), int(size)) + buf := make([]float32, size) + copy(buf, unsafe.Slice((*float32)(data), int(size))) + cgo.Handle(ptr).Value().(chan []float32) <- buf } diff --git a/goborator_test.go b/goborator_test.go index eb613ec..043abd2 100644 --- a/goborator_test.go +++ b/goborator_test.go @@ -36,9 +36,8 @@ func TestGoborator(t *testing.T) { var i = 0 start := time.Now() - //for c := range ob.GaborTransform(channel) { - for _ = range ob.GaborTransform(channel) { - //fmt.Printf("%d: %+F\n", i, c) + for c := range ob.GaborTransform(channel) { + fmt.Printf("%d: %+F\n", i, c) i++ }