SFML community forums
Help => Audio => Topic started by: serdnar on July 07, 2020, 03:31:02 pm
-
Hey,
I try to bring a SoundBuffer to only one channel (stereo left/right).
I tryed the following:
- create it wich two channels, only fill in every second value. -> sound is still on both ears.
- using setPosition(-1, 0, 0); to move the sound to left. -> still some sound (but more quiet) on the right ear
Is there any possibillity to split Buffers to different channels without impacting the other channel? Some low level functionality?
Thanks
-
I'd have expected that an interlaced two channel buffer with one channel being 0 would just play on one channel, but maybe your audio driver is detecting a mono input and expanding it onto stereo.
Do you have some example code, so I can test this on my system?
If you change the position of the sound, setMinDistance to 1 and setAttenuation to 100, that way it should be max volume for the left/right ear and immediately drop to 0 after distance 1. Or similar.
-
Audio driver sounds reasonable. It is not stereo, but somhow quiet on the other ear. room correction is deactivated.
sf::SoundBuffer buffl;
vector<sf::Int16> samplesl;
for (int i = 0; i < 44100; i++)
{
samplesl.push_back(SineWave(i, 324, 1));
samplesl.push_back(0);
}
buffl.loadFromSamples(&samplesl[0], samplesl.size(), 2, 44100);
sf::Sound soundl;
soundl.setBuffer(buffl);
soundl.setLoop(true);
//soundl.setPosition(-1, 0, 0);
soundl.play();
-
Rather than create a stereo buffer with one channel as silence, you could create a mono buffer from that stereo buffer. Or, create two from it and control them separately.
You should note that spacial positioning only applies to mono sound sources; stereo sounds are always stereo (I'm guessing this is where you're finding some error).
I've already given an example that shows how to split a stereo SFML sound buffer into two mono SFML sounds buffers. You can find that here:
https://stackoverflow.com/a/50078065/6158263
That said, you seem to already understand how to create a buffer from scratch. Try just a mono buffer (1 channel) and the move it's position in space to the left (as you mentioned).
-
Not a big change, but this has the same effect / error.
Still a little bit of sound in the other channel as well.
sf::SoundBuffer buffl;
vector<sf::Int16> samplesl;
for (int i = 0; i < 44100; i++)
{
samplesl.push_back(SineWave(i, 324, 1));
}
buffl.loadFromSamples(&samplesl[0], samplesl.size(), 1, 44100);
sf::Sound soundl;
soundl.setBuffer(buffl);
soundl.setLoop(true);
soundl.setPosition(-1, 0, 0);
soundl.play();
-
That seems correct too. It looks like this is a sound card/driver issue to be honest.
Do you have any global "environment" effects? e.g. reverb.
Is your speaker setup identical to what the driver thinks it is? e.g. headphones for headphones, 2-channel for 2 speakers, 5.1 for 5 speakers and subwoofer. It could be mixing surround sound into fewer channels or vice versa.
-
I tryed it with two cards now (USB audio card and direct), but on the same pc - same effect.
I will try on an other pc tomorrow.
btw: you can also hear it, if you are running two different frequences on each ear. example: a sinus wave with 60 and 70 HZ. Only if you have both ears on the headphone, you should hear a 10HZ benaural wave. Otherwise not. In this test, jou can hear this 10HZ wave on each single ear - which should not be the case.
If this works fine in your setup, it must be an problem of my hardware.
best and thanks so far.
-
My only other suggestion that I can think of at the moment is probably too obvious that you've checked this already (if it applies) but do you have any outboard effects (between card and speakers) and are they switched off/turned fully dry?
Other than that, I'm not sure what else to suggest. Sorry :-[