Author Topic: Request: Better Sound Resampling Algorithm  (Read 8481 times)

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Request: Better Sound Resampling Algorithm
« on: September 04, 2008, 09:45:37 PM »
Right now there is sound in a number of formats, especially with the transition to new recordings with higher sampling rates.  The resampling algorthim is very simple.  There's no kind of interpolation with the sound, so the end result is very harsh.  This means some sounds will sound good and others bad based on what rate you've selected in the audio options, and not all sounds will sound good at the same time.  Some better sound resampling will help that a lot.

http://dplogin.com/dplogin/featurevote/feature.php?id=10169

mewa

  • 68 Carbine
  • Posts: 277
Re: Request: Better Sound Resampling Algorithm
« Reply #1 on: December 03, 2008, 05:52:18 PM »
Pick a sample rate and go with it, or provide both files for use (one at 48khz and another downsampled to 44.1khz). I wouldn' t waste too much time on it.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Request: Better Sound Resampling Algorithm
« Reply #2 on: December 12, 2008, 11:32:50 AM »
Until all the sounds are resampled, though, people will be griping about sound quality.  Also, some older computer may need to run at a lower rate for performance reasons.

mewa

  • 68 Carbine
  • Posts: 277
Re: Request: Better Sound Resampling Algorithm
« Reply #3 on: December 12, 2008, 11:07:10 PM »
We can just release two versions/sample rates of each sound as long as theres code to support picking the right file.

Zorchenhimer

  • Autococker
  • Posts: 2614
Re: Request: Better Sound Resampling Algorithm
« Reply #4 on: December 13, 2008, 02:31:40 AM »
That would make the game larger than need be.

mewa

  • 68 Carbine
  • Posts: 277
Re: Request: Better Sound Resampling Algorithm
« Reply #5 on: December 13, 2008, 11:24:08 PM »
We're talking relatively small files here. Largest gun sound I can find is 39KB. Times that by 2 for the possibility of an "empty" sound, then by two again for the different sample rates. Multiply by the number of default sounds in the game. Wouldn't even hit 500KB extra, and thats all uncompressed files.

Another idea that just occurred to me is if the game to incorporate flac or shn support the audio files would be cut in half without any quality loss. I would assume this would mean more processing involved, which doesn't seem like a worthy tradeoff to me as everyone I've introduced the game to was literally shocked that such a well made game fit into 23mb (or whatever size its at now).

mewa

  • 68 Carbine
  • Posts: 277
Re: Request: Better Sound Resampling Algorithm
« Reply #6 on: December 13, 2008, 11:27:15 PM »
I should add, although I know I've written about it elsewhere, that the sample rate issue is a rather small on in my opinion. Just set it at 44.1khz and all will be happy. Although the few using 48khz capable cards wont get all the benefits possible to them, the will hardly be missing out on anything. Reverse the situation and force 48khz rates and the majority with 44.1khz cards will lose a lot of quality in the downsample.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Request: Better Sound Resampling Algorithm
« Reply #7 on: December 15, 2008, 03:13:57 PM »
Nearly every system these days uses 48khz, with the higher end sound cards supporting 96 and 192khz.  Using 44.1 would end in poor quality, I think.  Also, on the subject of making multiple samples of each sound - I don't think that's really a good idea either.  I've been working on recording some ambient sounds to help add atmosphere, and those are quite large without compression (5-10 megs+).  Since the resampling is done at load time, it won't affect in-game performance, only load times (and only if you're using a different sample rate than the sound is recorded in).

This really shouldn't be that big of a deal to implement - just some linear interpolation would make a huge difference.  If we wanted to get fancy, we could take a peek at something like Audacity's source.

mewa

  • 68 Carbine
  • Posts: 277
Re: Request: Better Sound Resampling Algorithm
« Reply #8 on: December 15, 2008, 07:48:15 PM »
Thought you had mentioned before that the audacity algorithms were pretty pathetic (which I've actually seen on other sites)?

The reason I would say just go with 44.1khz is that there is literally negligible loss for those who support higher rates and have to upsample. On the other hand, if those who can only support 44.1khz are forced to downsample there will be a large drop in quality mainly from a lot of antialiasing issues. Seems to me that before another rate becomes an industry standard (will probably be 96khz) that it is best to err on the conservative side and allow all to have pleasant audio.

This thing about 5-10meg files (.wavs, I assume) brings up another point towards using some compression, either lossy or lossless. SHN and Flac both are great lossless formats with fairly open usage policies. They'll generally cut the .wav size in half. Otherwise it might be worth looking into some Mpeg3 or OGG support, which would make this whole conversation about sample rates obsolete.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Request: Better Sound Resampling Algorithm
« Reply #9 on: December 16, 2008, 02:56:04 PM »
I think ViciouZ is working on ogg vorbis supprt.

Regardless of what sample rate we end up supporting, until ALL the sounds have been resampled, which will probably be a while at the current pace, some sounds are going to sound bad.

ViciouZ

  • Map Committee
  • Autococker
  • Posts: 2227
Re: Request: Better Sound Resampling Algorithm
« Reply #10 on: December 17, 2008, 01:45:15 PM »
I think ViciouZ is working on ogg vorbis supprt.

Regardless of what sample rate we end up supporting, until ALL the sounds have been resampled, which will probably be a while at the current pace, some sounds are going to sound bad.

Yes, but the implementation I borrowed had OGG for music only, on a subsytem of its own (OGG_Init/Shutdown) as opposed to the sound effects subsystem.

mewa

  • 68 Carbine
  • Posts: 277
Re: Request: Better Sound Resampling Algorithm
« Reply #11 on: December 18, 2008, 03:50:54 PM »
That should work for the ambient sounds at least, which would be the only files large enough needing compression.

"Regardless of what sample rate we end up supporting, until ALL the sounds have been resampled, which will probably be a while at the current pace, some sounds are going to sound bad."

I'm not sure I understand this fully. Are the sounds mixed in their sample rates right now?....I just checked this. I'm kind of shocked to see such a range of rates. I see 4 different sampling rates in the /guns folder alone. Was there a motive behind this? If we can just agree on a rate for now I can run all the sounds I have through a batch resample and upload.


jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Request: Better Sound Resampling Algorithm
« Reply #12 on: January 14, 2009, 12:49:30 PM »
Well, we COULD resample all of the sounds in the game and require a big update that doesn't actually make the sounds better (and wouldn't cover any custom sounds people have put in their maps), or we could do the same thing in code with a new resampling algorithm that wouldn't require any data changes and would cover any custom sounds.  I'm not sure why you're so opposed to this (or seem to be).

mewa

  • 68 Carbine
  • Posts: 277
Re: Request: Better Sound Resampling Algorithm
« Reply #13 on: January 18, 2009, 01:30:06 AM »
My sincere apologies. Looking back now, I'm pretty sure I didn't read the head post of this thread close enough to understand what you were shooting at. At least it doesn't seem to be what I thought we were talking about in here, but it's also 1a Sat evening and I probably shouldn't be drinking and typing.

Furthermore, it sounds like a good idea. Excuse my naiveness , but are we talking about ingame resampling or the resampling of the original recording files to a standard rate? My post's in here were referring to resampling the original recordings to one rate, 44.1 or 48khz (from what I remember of my thought process). Maybe I'm confused, but doesn't the card/hardware take care of resampling any files to one chosen sample rate?

Anyways, if this is an ingame function, I still think it'd be worthwhile to resample beforehand to one standard rate with a professional app containing a high quality algorithm. This would cut down on the hog factor (still important to us with near 10 year old computer, and those who just don't maintain their PC's and clog it up with all sorts of crap) and would be a negligible difference in total size of install, since the audio is so short in time.

Please tell me where my responses are nonsense and out of context. I've got a feeling I'm missing something....

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Request: Better Sound Resampling Algorithm
« Reply #14 on: January 30, 2009, 04:00:34 AM »
The sound files all get resampled to whatever the sound rate is set at in the audio options.  The problem is, the algorithm currently used just picks the nearest point, so you end up with very "jagged" or "aliased" wave forms (which results in an extra tinny sound, like rattling silverware).  Quake 2 does all the sound mixing before it even reaches the sound card (unless you have 3d audio enabled).

mewa

  • 68 Carbine
  • Posts: 277
Re: Request: Better Sound Resampling Algorithm
« Reply #15 on: February 01, 2009, 10:50:09 PM »
Yea, I understand all awful artifacts produced from poor resampling. When you say "picks the nearest point", are you referring to general process of resampling? All typed of resampling do this same idea in different manners and scales. I think having a better algorithm is an important feature, relatively speaking. It'd be nice, but as far as sound quality is concerned the other thread referring to the clipping issues with all the current recordings plays a much more important role. If this could be done with little time and hassle, I'd say "why not?'. On the same token, I certainly wouldn't make it a focus as there are probably many other features that should go before it.

On a slightly broader note, I think with these feature votes it would be incredibly handy for the voters if they could see some kind of weighting system. Some way to gauge the tradeoffs being made when effort is put into one project versus another. Maybe just real simple, scale of 0-10, with a couple of variables like estimated time taken to implement, estimated time of debugging or some judge of it's complexity, etc. Then you could say you there is an estimate of 30pts for a year (although no one should hold you to the value you give) and people would be able to pick a handfull of feature votes, in order of importance to themselves. Each vote would get a value based on the priority the voter gave it in their individual list and then tallied into a cumulative of which a set of 5 or so projects could be picked. There are some nuances to be worked out in order for this to work, but I think overall it could keep the progress a little more focused. It would also give those players who contribute their opinions a chance to see a more broad picture of development and the sacrifices needed in order for some features to be worked on.

I probably could've made a separate thread for this, or even it's own feature vote. Feel free to splice it out into it's own if you'd like.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Request: Better Sound Resampling Algorithm
« Reply #16 on: February 01, 2009, 11:02:31 PM »
By nearest point, I mean, say you're resampling something to twice the frequency, and you've got 2 points in the wave form (imagine the sound as plotted points on a graph).  Say, arbitrarily, they're 10 and 40, for simplicity.  Currently it would get converted to something like: 10, 10, 40, 40, creating kind of a stair stepping effect.  Ideally, you'd want to interpolate between those points, so you'd get something like 10, 20, 30, 40.

As for the feature vote system, it's not an absolute guide as to what I'll be working on next, but it helps prioritize my task list a bit (as well as gives people who want to contribute some reference for things to work on).  It's probably best to keep it simple.  Some things take longer to implement than others, and the time they take can't always be predicted.

AZTEC

  • PGP
  • Posts: 4
Re: Request: Better Sound Resampling Algorithm
« Reply #17 on: March 09, 2009, 08:03:10 PM »
well this is my first post lol and the reason im doing this is cuz i really want the old sounds well to b specific just the gun sounds the new ones u can barely hear them i use earphones and with the old sounds u can tell from what direction ppl is shooting at u so with these new ones u cant tell till ur dead lol and the walking sounds too they too low u cant tell wheter hes coming from ur left or ur right thats why i really want old sounds plz is there a way to get them back thank you.

eMo

  • VM-68
  • Posts: 184
Re: Request: Better Sound Resampling Algorithm
« Reply #18 on: March 09, 2009, 10:17:01 PM »
I know its OT but,

Aztec, here are the sounds i use : http://dl-client.getdropbox.com/u/59905/sound.zip
i cut out the start sounds and the death sounds cause they bugged me.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Request: Better Sound Resampling Algorithm
« Reply #19 on: March 10, 2009, 08:27:36 AM »
I whipped up a quick linear resampling algorithm for the next build.  It's not perfect, but it sounds a lot better than it used to.  It should hold us over until we get all the sounds re-made in 48khz.