If you want to process the samples of a playing sf::Music on the fly, then create your own class derived from it, and override the onGetData virtual function. Something like:
class MyMusic : public sf::Music
{
protected:
bool onGetData(Chunk& data) override
{
if (sf::Music::onGetData(data))
{
// ... data contains the next chunk of samples to be played by the music ...
return true;
}
else
return false;
}
};
Since sf::Music is triple-buffered, the data that you get there will only be played a few moments later (something like 2 seconds), so you may have to adjust if you want your visualizer to be perfectly synchronized with the music.