Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Audio output only on one channel  (Read 6514 times)

0 Members and 2 Guests are viewing this topic.

serdnar

  • Newbie
  • *
  • Posts: 4
    • View Profile
Audio output only on one channel
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Audio output only on one channel
« Reply #1 on: July 07, 2020, 04:06:37 pm »
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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

serdnar

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Audio output only on one channel
« Reply #2 on: July 07, 2020, 05:25:13 pm »
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();

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Audio output only on one channel
« Reply #3 on: July 08, 2020, 01:04:07 am »
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).
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

serdnar

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Audio output only on one channel
« Reply #4 on: July 08, 2020, 02:02:20 pm »
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();

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Audio output only on one channel
« Reply #5 on: July 08, 2020, 10:20:07 pm »
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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

serdnar

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Audio output only on one channel
« Reply #6 on: July 08, 2020, 10:35:35 pm »
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.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Audio output only on one channel
« Reply #7 on: July 09, 2020, 10:16:44 pm »
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 :-[
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything