Hello SFML community!
So, i have a problem -
In a project that i am working on, there is a need to cut off a small part(1/20 sec) of the sound buffer from the beginning.
So essentially i made a function that takes the soundbuffer, removes the first 2205 (44100 / 20) samples and returns it. Then i make a sound from the returned buffer, but it wont play!
Is there any special tricks or things that i should know when doing these type of things?
Maybe there is a better way of doing this?
here is the function:
sf::SoundBuffer BufferHelper::RemoveFromBeginning(sf::SoundBuffer Buffer)
{
const sf::Int16* Samples = Buffer.getSamples();
std::vector<sf::Int16> vectorBufferNew;
vectorBufferNew.reserve(Buffer.getSampleCount() - 2205);
vectorBufferNew.resize(Buffer.getSampleCount() - 2205);
for (int i = 0; i < Buffer.getSampleCount() - 2205; i++)
{
vectorBufferNew[i] = Samples[2205 + i];
}
sf::SoundBuffer FinalBuffer;
FinalBuffer.loadFromSamples(&vectorBufferNew[0], vectorBufferNew.size(), 1, 44100);
return FinalBuffer;
}
Thanks