Hello, thanks to SFML, it is simple and very easy to learn. The sound play and record works on my FreeBSD computer. My computer is crude and has low hardware configure. sf::SoundBufferRecorder::getAvailableDevices has found two andio record devices on my system:
OSS Default
pcm2:record:dsp2
The problem is I can't make spacialization aka 3D Sound work. I have tried to set some different distances between the listener and the sound source, but the sound heard in my ears are the same without any differences. The following is my c++ code and shell test script line. (c++ code was compile to ./run with clang. cut.oga is short audio file. mksh)
#include <SFML/Audio.hpp>
#include <iostream>
#include <string>
int main(int argc, char * argv[]) {
if (argc != 2) {std::cerr << argv[0] << " [Listener Z Position]." << std::endl; return 1;}
float z = std::stof(argv[1]);
sf::SoundBuffer buffer;
if (!buffer.loadFromFile("cut.oga")) {std::cerr << "Load cut.oga error.\n"; return 1;}
sf::Sound sound;
sound.setBuffer(buffer);
sound.play();
sound.setLoop(false);
sf::Listener::setPosition(0.0f, 0.0f, z);
sf::Listener::setDirection(0.0f, 0.0f, -1.0f);
sf::Listener::setUpVector(0.0f, 1.0f, 0.0f);
sf::Listener::setGlobalVolume(50.0f);
sound.setPosition(0.0f, 0.0f, 0.0f);
sound.setRelativeToListener(false);
sound.setMinDistance(2.0f);
sound.setAttenuation(20.0f);
while (sound.getStatus() == sf::Sound::Playing) {
sf::sleep(sf::seconds(0.1f));
}
return 0;
}
z=4; while [ $z -gt -5 ]; do echo $z; ./run $((z--)); done
3D GUI world should be rendered in your brain to simplify the code.