Alright, I have done some research and as I suspected, this whole issue with a hard coded up-vector is far more problematic than I first thought; it is not just a matter of code safety, but the whole feature of orienting the listener is broken. Let me explain.
What made me thinking is that why is the up-vector there in OpenAL in the first place? Maybe it is actually used for something? And if you think about it, of course it is. A sole vector pointing where you look is not enough to describe orientation. Consider if you are looking forward and you have one blue fire to the front-left and one orange fire to the front-right like so (pardon my bad drawing skills
):
The red arrow is the at-vector, the green is the up-vector.
Frame1: this is a first person view, the red at-vector is going straight forward and the up-vector is going straight up
Frame2: this is a top down view of the same scene. The player is looking straight at the fires
Frame3a: this is a side view of the same scene
In all those frames, the sound of the blue fire is heard through the left speaker and the yellow fire is heard through the right. This is all good. However, now consider that the player turns around with his back towards the fires and bends his neck backwards like crazy so that he looks at the fires straight, but is upside down. This would be what the Frame3b picture shows. The at-vector is still at the fires but the up-vector is now pointing downwards. And if you imagine doing this, the blue fire should now be heard through the right speaker and the yellow should be heard through the left. This is not possible in SFML since the up-vector is hard coded.
This might seem like a longshot situation but if you mean to develop applications with free moving 3D cameras, then it isn't really. Even the space simulator example from before would be enough. If you go forward, and then make a half-circle loop upwards to go the other way upside down, all of a sudden all sounds would be inverted because the up-vector is pointing in the wrong direction! Not good.
Furthermore, it is even more problematic, because as the OpenAL specification says, it expects the vectors to be orthogonal. i.e. having only right angles. Not having orthogonal vectors is not undefined behaviour however, but it creates unintended behaviour: A skewed space for the sound calculations. I verified this by asking in the #OpenAL channel:
http://thunked.org/p/view/pub/1xjz28aboAnd I looked in the OpenAL source code to verify this:
http://thunked.org/p/view/pub/mjljisdt9This is verifies what the person in the channel said: The up-vector and at-vector are used to calculate an orthogonal right-vector and these three vectors are then normalised and used to construct the listener-space coordinate system which is used for calculations with the sources sounds.
In other words if the vectors are not orthogonal, the calculations will be off due to the skewed space. In practice this means that
the SFML 3D audio spatialisation only works as intended when the listener look-at is perfectly straight ahead. If the player looks up or down in an FPS game for instance, the audio calculations are skewed accordingly.
This imo is a major flaw of the 3D spatialisation. If you would use SFML for anything but the most basic spatialisation tasks, the result will be off. What is even worse is that it is not even mentioned in the documentation which could cause a lot of headaches for people trying to use it and wondering why sounds are not behaving correctly.
All of these issues are in the library apparently because it is too difficult for newbie programmers to understand that proper 3D orientation requires at least 2 orthogonal vectors. This is to me absurd, and the argument is voidified by the fact that newbies would not even make 3D applications in the first place. And starting out with a small API to avoid clutter and add features later etc is surely fine and all, but
this feature doesn't even work properly without two vectors which is why that argument doesn't even apply here either.
If you still after this think that this issue is not worth fixing (it can even be done without breaking the API by adding a default up-vector argument like tank said), then at the very least explain in the documentation that most values you give to the setDirection() function will produce skewed and flawed output and that (0, 1, 0) will totally break it. That way people who want to have proper audio spatialisation can look for another library to use.