Set position

https://bitbucket.org/xuuki/grid/src/e8452327dc6187fa1b65f49ded8c9a0ac9022381?at=master

I wanted to share my current code I’ve designed a grid to play back samples. I’m currently using the AudioBuffer class to store and play the samples. it was previously using audio transport source to play back the sample which seemed more "compatible " with set position.
Using Audiobuffer class however, I’m not sure how to look up the size of the memory and then tell set position to jump to a different part in the memory and continue playing?

AudioBuffer::getNumSamples tells the length of the buffer. For changing the playback position, you probably have some kind of a “bufferposition” member variable? So then you just change that to a new number between 0 and AudioBuffer::getNumSamples-1.

Indeed there is a bufferposition that counts until it reaches the audioFileBuffer.getNumSamples. But I think the area i don’t understand is that I’ve used a row of sixteen buttons to divide the sample by multiplying the input by 0.0625 (this is so any sample is scaled from 0 to 1. then I send that value to the input of setposition. But i cant work out how to get that to find the bufferposition relative to audioFileBuffer.getNumSamples? and then reposition the bufferposition in the void FilePlayer::getNextAudioBlock function ( where the bufferposition counts through audioBuffer).

It’s just normal multiplication and division math. Just take care you do the calculations as floating point and that you don’t end up using the sample position getNumSamples exactly. (Because that’s already past the buffer end, the last valid index is getNumSamples-1.)