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

Author Topic: Getting audio samples from listener  (Read 3655 times)

0 Members and 1 Guest are viewing this topic.

def87

  • Newbie
  • *
  • Posts: 3
    • View Profile
Getting audio samples from listener
« on: July 13, 2016, 07:22:11 pm »
Hello,

is SFML capable of outputting the final mixed audio to memory (or custom hardware) instead of the system audio drivers?
Kind of like a custom audio stream but for output, not input?

This is what I am looking for in an audio library/SDK. OpenAL does not support this.

Thanks.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Getting audio samples from listener
« Reply #1 on: July 13, 2016, 08:29:37 pm »
OpenAL does not support this.
SFML uses OpenAL.

outputting the final mixed audio to memory (or custom hardware) instead of the system audio drivers?
Kind of like a custom audio stream but for output, not input?
Depending on what you require, there may still be options. You could keep track of the data being sent through the streams and mix them manually. You could also "record" the audio from the driver.
Sounds, though, like you want to output audio without actually creating any sound (think of a render texture for sound.) It might be best to do manual internal mixing and manipulation if you don't want to actually play the sound.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Getting audio samples from listener
« Reply #2 on: July 13, 2016, 09:51:25 pm »
You can't play multiple sf::Sound and extract the resulting audio (if that is what you meant), but audio itself is just a collection of sound samples, so in theory you can do the mixing yourself and output it in any way you want.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

def87

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Getting audio samples from listener
« Reply #3 on: July 14, 2016, 04:24:58 pm »
SFML uses OpenAL.
I did not realize that! How does SFML adjust volume? Is a copy of the sound buffer created with the modified volume?
I don't see that implemented in OpenAL, as well as support the setPlayingOffset() function...

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Getting audio samples from listener
« Reply #4 on: July 14, 2016, 05:13:37 pm »
According to the source, it uses alSourcef, which modifies a parameter called AL_GAIN to adjust the volume of that sound.

In the OpenAL Programmers Guide, you can read about alSourcef and AL_GAIN (page 39). :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

def87

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Getting audio samples from listener
« Reply #5 on: July 15, 2016, 12:32:56 am »
Ah, my apologies. I did not read the OpenAL docs carefully enough.
I suppose the AL_SEC_OFFSET property, although it is only a property, alows to change the position in the audio source while playing. I was looking for a function like there is for play, stop, rewind etc.

The abstraction of "sound" and "music" in SFML is helpful. I will look into using only the SFML audio library in my project for now.
Will I need to link to the flc, vorbis etc. libs even when I only need WAV support?

Thanks.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Getting audio samples from listener
« Reply #6 on: July 15, 2016, 12:55:56 am »
You're welcome.

As far as I am aware, if you're statically linking, you have to link all of the dependencies of the audio module when you use the audio module.

SFML audio support is quite basic but has a decent amount of power if you're willing to make use of it creatively ;)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything