105
« on: February 17, 2017, 08:19:45 pm »
Your fillBuffer function is copying your pointer (activeBuffer_m in this case), so it's not changing activeBuffer_m like you want. You want fillBuffer to take a reference to a pointer, or a pointer to a pointer.
So you actually have a memory leak (paramBuffer is never deleted).
BUT, since it's a member function, you don't need to do that. In fact, I'd get rid of fillBuffer. onGetData should be doing what fillBuffer is currently doing in my mind.
Furthermore, the two buffers is complicating things more than helping, I think. Personally, I'd make a static sized array of size SOUNDSAMPLES and just reuse it every time onGetData() is called (SFML makes a copy of what you give it, so this if fine).
Then, you don't have to do any manual memory management, and it technically would be more efficient as well, since you won't be allocating and freeing memory every SOUNDSAMPLES samples.
Doing this stuff would also make implementing onSeek() easier to implement when you get around to it too (just a change of t_m).
Other design stuff:
If you're not ever changing x_m, I'd make it a constant.
load() should really be a constructor.
x_m and x_t don't indicate to me their meanings without context, I'd rename them to something that indicates their meaning better (I'm actually not 100% sure what x_m is. I'd rename t_m to something like "currentTime", "timePosition", etc).
Hope this helps.