sf::SoundBuffer::getSamples()
returns a pointer to the samples. You'll have to send/retrieve the individual samples rather than the pointer only.
I'd try something like this (untested):
sf::Packet& operator << (sf::Packet& packet, SoundBuffer& a)
{
std::size_t num = a.getSampleCount();
// Send the number of samples first
packet << num;
// Now send the actual samples (repeat as long as we have some left)
for (sf::Int16 *p = a.getSamples(); num; ++p, --num)
packet << p;
}
On the client side you'll just have to reverse the whole thing, then use sf::SoundBuffer::loadFromMemory()
to load the data into the buffer.
Just keep in mind this is uncompressed and might be rather taxing on the connection. As such you might want to implement your own compression layer. You can find an example on the documentation page of sf::Packet
.