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

Author Topic: Three Audio System Hurdles (Music Layers, Loop Sections, and DSP FX)  (Read 3027 times)

0 Members and 1 Guest are viewing this topic.

katanaswordfish

  • Newbie
  • *
  • Posts: 1
    • View Profile
Currently, I'm working on an audio subsystem for a game project. However, I've run into a few issues concerning what might be considered more 'advanced' playback methods. Specifically; mixing/layering multiple music tracks, looping and queuing various sections of a song, and rendering audio with basic DSP post-processing effects (simple high/low-pass filters, simple delay, and perhaps reverb).

Thanks to SFML, loading up and playing a .OGG audio file is dead simple. However, that kind of functionality might be considered the minimum threshold of what's needed for creating interesting and dynamic audio in game. To create an interesting and dynamic 'audio engine', it's important to be able to control the flow of the music, the mixing of multiple music layers, and some basic DSP effects in real time. I'm curious if anyone knows a good approach to achieving these goals using SFML (2.0)'s current system.

1 - When it comes to layering multiple audio tracks, the simple solution of telling multiple sf::Music objects to play at the same time seems to work relatively well. I created two test tracks and told them to play at the same time, and they appeared to stay in sync over multiple minutes. This is really useful for fading music layers in and out over time and creating a more interesting sound-scape. I'm not sure if there is a better way of achieving this with SFML/OpenAL Soft, but it works for now.

2 - However, my first main issue comes up when trying to create specific 'loop points'. Of course, it's very useful to be able to control the structure and the flow of a song, instead of being restricted to start-to-finish playback. I was thinking that one approach might be to use the 'setPlayingOffset()' function, together with certain start point timestamps. However, this doesn't seem to help with the process of looping a specific section of a given song. ( For example, a song might have an intro, a-section, b-section, and outro.. In my ideal situation, I would be able to direct the music file to play through the intro, and then loop the a-section until instructed to continue on to the b-section. ) - My second thought was to load up each section of the song into a separate sf::Music object. If each section of the song exists within it's own OpenAL buffer object, then it should be easy to play the intro buffer, queue up the a-section buffer, instruct it to loop, and then direct any changes later when needed! Unfortunately, I'm new to both SFML and OpenAL, and I've been having trouble determining if this strategy would be possible within the sf::Music setup. I might be wrong, but it seems to me that sf::Musics can't be easily queued in the way that OpenAL buffers can be queued into OpenAL sources. Is this true?

3 - Finally, the last piece of my audio system wishlist is the ability to run my SFX and music through basic DSP effects, like those found in OpenAL's EFX extension (reverb, echo/delay, filters, etc.). In my searches, I managed to find this forum post from 2010, which seemed to suggest that it was not possible. (http://en.sfml-dev.org/forums/index.php?topic=2245.0). However, this page seems to suggest that the EFX extension is compatible with OpenAL Soft (http://kcat.strangesoft.net/openal.html), and I noticed the EFX include files in the extensions section of the SFML source code. I couldn't find anything on how one would implement EFX-style effects using SFML, so I'm curious if it's possible or not.

It may seem like these kinds of features aren't necessary to make a functioning game. But, unfortunately, I'd argue that dynamic game audio is often overlooked compared to graphics. While there may very well be technical reasons for this, it seems like a shame that there isn't some kind of 'programmable pipeline' audio library analogous to OpenGL/GLSL. I'll admit that, as a pretty new and self-taught programmer, the low-level implementation details of these libraries is currently beyond me. However, these high-level features (audio layer mixing, queue/loop points, DSP effect, etc.) are certainly useful for creating powerful and interesting game audio.

I'm hoping there will be some way for me to create an audio subsystem using SFML/OpenAL Soft that allows me to tackle all three of these problems. If not, I hope that these kinds of problems will be heavily considered when refactoring the audio module of SFML in future version. SFML is really great so far and it provides a ton of power on the visual side of things. I hope that OpenAL Soft has left enough room for SFML to grow in the audio realm. Any help/insight into how I might be able to build a more robust audio system for my project, or any explanation why it might not be possible would certainly be very valuable to me. Thanks!  ;D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Three Audio System Hurdles (Music Layers, Loop Sections, and DSP FX)
« Reply #1 on: August 07, 2013, 07:57:54 am »
1- SFML doesn't focus on synchronization, so it's great that it works fine :P
There are better mechanisms in OpenAL to ensure that multiple sounds start synchronized.

2- sf::Music may be too high-level for this kind of customization. You should try with sf::SoundStream (which is the base class of sf::Music). Loop points have already been requested in the past, I need to tweak the API to provide support for this feature. There's a task in the tracker about it.

3- Effects are currently not implemented in SFML, but it's planned. There should also be a task in the tracker for this feature.

So basically... be patient, or write your own system using OpenAL directly ;)
Laurent Gomila - SFML developer