| Summary: | More audio backends should support floating point audio | ||
|---|---|---|---|
| Product: | SDL | Reporter: | John Chadwick <johnwchadwick> |
| Component: | audio | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | enhancement | ||
| Priority: | P2 | CC: | johnwchadwick |
| Version: | HG 2.0 | Keywords: | target-2.0.0 |
| Hardware: | All | ||
| OS: | All | ||
(Sorry if you get a lot of copies of this email, we're touching dozens of bug reports right now.) Tagging a bunch of bugs as target-2.0.0, Priority 2. This means we're in the final stretch for an official SDL 2.0.0 release! These are the bugs we really want to fix before shipping if humanly possible. That being said, we don't promise to fix them because of this tag, we just want to make sure we don't forget to deal with them before we bless a final 2.0.0 release, and generally be organized about what we're aiming to ship. Hopefully you'll hear more about this bug soon. If you have more information (including "this got fixed at some point, nevermind"), we would love to have you come add more information to the bug report when you have a moment. Thanks! --ryan. |
Currently, floating point audio support in SDL HG is rather poor. While it is indeed supported in some backends, it is not in others that very easily can support floating point output. 1. In winmm, this is achieved by setting the wFormatTag of the WAVEFORMATEX structure to WAVE_FORMAT_IEEE_FLOAT (0x0003) during initialization. Note that mingw headers do not seem to contain WAVE_FORMAT_IEEE_FLOAT, so I just use 0x0003. Pseudo diff of SDL_winmm.c, line 262: ---------------------------------------------------------------- case AUDIO_S32: + case AUDIO_F32: break; /* valid. */ ... waveformat.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format); + if(this->spec.format == AUDIO_F32) + waveformat.wFormatTag = 0x0003; // WAVE_FORMAT_IEEE_FLOAT if (this->spec.channels > 2) ---------------------------------------------------------------- 2. directsound seems to support floating point through exactly the same means. Pseudo diff of SDL_directsound.c, line 475: ---------------------------------------------------------------- case AUDIO_S32: + case AUDIO_F32: this->spec.format = test_format; valid_format = 1; ... waveformat.wFormatTag = WAVE_FORMAT_PCM; + if(this->spec.format == AUDIO_F32) + waveformat.wFormatTag = 0x0003; // WAVE_FORMAT_IEEE_FLOAT waveformat.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format); ---------------------------------------------------------------- 3. PulseAudio of course supports floating point. Bonus: it supports big endian too. Pseudo diff of SDL_pulseaudio.c, line 343: ---------------------------------------------------------------- break; + case AUDIO_F32LSB: + paspec.format = PA_SAMPLE_FLOAT32LE; + break; + case AUDIO_F32MSB: + paspec.format = PA_SAMPLE_FLOAT32BE; + break; default: ---------------------------------------------------------------- There may be more backends that could, but do not support floating point audio, but these are the ones I looked at. Thanks for reading. P.S. sorry about the 'pseudo' diffs. I will try to get real diffs in a moment, I just wanted to demonstrate how I got floating point working in each backend.