Skip to content

Commit 4281a2f

Browse files
committed
channelptr now supports raw arrays
1 parent d3d57f2 commit 4281a2f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/SampleBuf.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ end
7979
"""Get a pointer to the underlying data for the buffer. Will return a Ptr{T},
8080
where T is the element type of the buffer. This is particularly useful for
8181
passing to C libraries to fill the buffer"""
82-
channelptr(buf::SampleBuf, channel) =
83-
pointer(buf.data) + (channel-1)*nframes(buf) * sizeof(eltype(buf))
82+
channelptr(buf::Array, channel, frameoffset=0) =
83+
pointer(buf) + ((channel-1)*nframes(buf)+frameoffset) * sizeof(eltype(buf))
84+
channelptr(buf::SampleBuf, channel, frameoffset=0) =
85+
channelptr(buf.data, channel, frameoffset)
8486

8587
# the index types that Base knows how to handle. Separate out those that index
8688
# multiple results

0 commit comments

Comments
 (0)