What the heck are you talking about? All that's changed is that it uses the same sound system on windows as it has on linux.
Meh, that's not quite what I got from the changelog, but I suppose that it depends on how much of that functionality is exposed to Lua in the end.
I just hope OpenAL sucks less than the last time it was put into Windows- I assume that they've finally made it be able to run WAVs without horrible popping and hissing on most audio hardware now
I wouldn't really put it that way. My calculator can play sounds without clipping, because it only plays one thing at a time.
For one thing... OTA played
quite a few simultaneous sounds, at least polyphony levels of 16 or so.
Without clipping or distortion, either. And, if you've ever fired up Audacity and looked at the waveforms, it wasn't because their audio engineer was really clever- by today's standards, many of the sounds come dangerously close to clipping levels, and certainly would, if played simultaneously.
Spring, on the other hand, struggles with 16 sounds, when most modern game engines, and practically all soundcards, even the cheap ones, can do far more polyphony pretty well.
For
another thing, practically all commercial games don't clip or have serious issues with distortion, either.
When's the last time you heard massive distortion in a MP shooter? Yeah, me neither- even when multiple guys are all gunning away, it reaches peak volume, but doesn't exceed it. Oh, I suppose you could blow your speakers out, at peak volume, but you'd have to
try.
Or think about the sound in Dawn of War. There, you could still hear footsteps of the big, stompy robots and things, in the middle of a firefight. In Spring, it just gets totally lost when combat starts.
To address this in Spring seems like it shouldn't be that awful. I think it's mainly because sound is considered to be un-sexy that nobody's fixed it up very well, and I'm hoping that this time around, it gets fixed properly.
First off, don't just send sounds off to the card any time something asks. Track a queue, then you know what's scheduled this frame. Don't do sounds in unsync, do them on a frame basis- nobody will ever notice.
Since you'd have a queue, you'd know what's in it and where it is, and the relative volume vs. the position the POV was in. That's already being determined- now, just store it, instead of sending it out immediately.
From there, it should be pretty easy. If X sounds are scheduled, and 3 out of X are the same .WAV, then we can add their combined volumes, and know immediately if they're going to clip. Anything over 110% of max volume is guaranteed to clip, given the way that we have to master sound. So... just send
ONE .WAV to the sound driver, at whatever that final volume is. Not three, at three different volumes... like we're doing now, except for that rather weak hack for unit replies.
It'd be better to end up with some stuff playing mono, than just throw sounds around, or just give that final sound a positional offset that makes it accurate to the relative POV- I don't think we're really supporting 3D sound yet, so there ya go, it'd at least be stereo-correct, if not 3D-correct.
Ideally, yeah, we want everything positionally accurate, but that's ideally- many people's soundcards can't handle that. And if we're not asking the soundcard what it can actually handle, then we're just assuming that it'll work, because OpenAL / DirectSound accepts it.
Build a sound-state per Player, using that same queue, instead of sending every-bloody-thing over, so that player X and player Y don't have exactly the same thing going on, just with different positional information.
There's practically nothing that can be done, to avoid clipping entirely, but the last time
I looked at the code, sound handling was
really primitive in Spring.
Also we're not bothering to find out what polyphony or other features are available from the sound driver, so we don't know if we're exceeding the maximum number of sounds the card supports. We can ask OpenAL for that information, and know if we're going to saturate the card, and we can certainly know if we're in danger of saturating the bus- too many sounds of X length being delivered this frame is bad... delay a few of them a frame, it's better to hear them late than not hear them at all. And it's
really a good idea not to saturate the bus.
Right now, we're not doing any of that. And that means, at least in the current build I'm testing, that sounds are frequently being cut off
Meh, if you have other code I should read, I'll read it, but that's basically what we
were doing, so far as I can tell, and I hope it's improved.
Shoving too many wavs into the bus is a major problem, not just in terms of clipping but in terms of quality of the game state- you can very easily bring Spring to its knees by shoving enough sounds around, and it's really annoying that so many sounds are played per frame, and clipping so frequently... that stuff like unit movement noises get totally obliterated frequently, no matter how large a radius I give them
