Closed vuki closed 3 years ago
There is some danger here, since we are unable to know if the buffer pointer is valid and of the specified length.
Off the top of my head, what about using some sort of static routines that achieve the same thing?
Sure, there is some danger, but it is programmer's responsibility to provide correct data. If the length and channel number provided in the constructor are valid and the pointer is not deallocated somewhere else, I think it is safe. I made this PR with intention of creating short-time wrappers, mostly for use in callbacks, such as the one required by RtAudio. I don't know how to achieve the same effect other way, without unnecessary data copying..
Adds new constructor to
StkFrames
class that takes a pointer to an existingStkFloat
buffer and wraps it into theStkFrames
object. This is useful in frameworks that provide a buffer that needs to be filled with samples. Wrapping the buffer pointer inStkFrames
class allows sending the buffer directly intoStk
objects, without need for data copying. A singletick
invocation is needed to fill the buffer instead of callingtick
for each sample.For example, the callback function in
crtsine.cpp
may be written as:Test code:
Result: