Example #1
0
func (strm *Stream) ReadSound(sound []float32) error {
	cerr := C.Pa_ReadStream(strm.cee, unsafe.Pointer(&sound[0]),
		C.ulong(len(sound)/strm.inopts.ChannelCnt))
	if cerr != C.paNoError {
		return errors.New(C.GoString(C.Pa_GetErrorText(cerr)))
	}
	return nil
}
Example #2
0
// ReadStream function as declared in portaudio/portaudio.h:1095
func ReadStream(stream *Stream, buffer unsafe.Pointer, frames uint) Error {
	cstream, _ := (unsafe.Pointer)(unsafe.Pointer(stream)), cgoAllocsUnknown
	cbuffer, _ := (unsafe.Pointer)(unsafe.Pointer(buffer)), cgoAllocsUnknown
	cframes, _ := (C.ulong)(frames), cgoAllocsUnknown
	__ret := C.Pa_ReadStream(cstream, cbuffer, cframes)
	__v := (Error)(__ret)
	return __v
}
Example #3
0
// Read uses the buffer provided to OpenStream.
// The number of samples to read is determined by the size of the buffer.
func (s *Stream) Read() error {
	if s.callback.IsValid() {
		return CanNotReadFromACallbackStream
	}
	if s.in == nil {
		return CanNotReadFromAnOutputOnlyStream
	}
	buf, frames, err := getBuffer(s.in, s.inParams)
	if err != nil {
		return err
	}
	return newError(C.Pa_ReadStream(s.paStream, buf, C.ulong(frames)))
}