Git Product home page Git Product logo

Comments (8)

flibitijibibo avatar flibitijibibo commented on August 25, 2024

Those end up being pretty heavy-duty in terms of dependencies - FAudio is in the same boat as SDL where we really need everything to be either self-contained or something that's zlib-licensed (or stb-style public domain), since many targets can't bring something like ffmpeg into the mix. But, being in the same boat, I've kept a close eye on how SDL has dealt with resampling in particular, and the result is that we have 2 options:

  1. Add a path for libsamplerate, can be dynamically loaded: https://github.com/libsdl-org/SDL/blob/main/src/audio/SDL_audiocvt.c#L497
  2. Make resampling an FAudio_platform_* function, and add pitch shift support to SDL_AudioStream: https://github.com/libsdl-org/SDL/blob/main/include/SDL3/SDL_audio.h#L685

Way back in the day I attempted to use option 2 and the result was pretty limited; we have to be able to adjust the sample rate pretty much all the time, so most resampling libraries don't cut it in terms of all the fussy things XAudio needs. I did my best to take notes from Chris Robinson and OpenAL Soft (without actually using the code, for licensing reasons), but yeah, it's definitely got some sharp edges.

Mixing is a bit tougher because of the way XAudio2 processes channels; mixing isn't hard but writing handwritten SIMD can be sometimes... unlike resampling I actually don't think there's anything that does exactly what XAudio does, but at the same time it's much easier to get correct than resampling.

from faudio.

zfigura avatar zfigura commented on August 25, 2024

Assuming I understand correctly, in both cases we'll need to keep the current code path around, which means I'll need to fix the current resampling code anyway. Having to do that and spend effort on improving a less featureful, non-copyleft project does not sound particularly appealing.

I haven't touched the mixing code much but it does indeed seem like the resampler is in much worse shape than the mixer (and would also benefit more from being outsourced).

What prevents FAudio from linking to an LGPL library?

from faudio.

flibitijibibo avatar flibitijibibo commented on August 25, 2024

FAudio targets consoles and mobile, both of which disallow LGPL binaries :/

I do agree that improving something like SDL's resampling would have a much bigger impact than trying to fix up this one, so if we can get a third party library to do this well it would make the possibility of nuking the old path a whole lot easier (and whatever library that comes in to fix it can presumably be reused for the Wine path as well, even if it has to statically link some SDL files manually or something).

from faudio.

flibitijibibo avatar flibitijibibo commented on August 25, 2024

Remembered that we have an issue filed for this in SDL3:

libsdl-org/SDL#7378

from faudio.

flibitijibibo avatar flibitijibibo commented on August 25, 2024

Looks like Ryan might be doing this for us, could be worth a review when he submits it?

icculus/SDL@f32a3bd

from faudio.

flibitijibibo avatar flibitijibibo commented on August 25, 2024

Talked to Ryan last night and confirmed this should do what I had hoped we could do a few years ago - so, if you'd like, you can replace the resampler with whatever you think will work best for the win32 target, and as long as SDL3 can implement the same layer we should be good to go.

from faudio.

flibitijibibo avatar flibitijibibo commented on August 25, 2024

libsdl-org/SDL#7571

from faudio.

flibitijibibo avatar flibitijibibo commented on August 25, 2024

The new SDL audio converter is now in the SDL3 branch - you can find the test program here, demonstrating the pitch shifting capabilities in particular: https://github.com/libsdl-org/SDL/blob/main/test/testaudiostreamdynamicresample.c

from faudio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.