Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to cut back on my game's file size and music and SFX are taking up a good chunk.

If I make a song or sound effect at 120bpm and then apply a tempo and pitch doubling using a DAW or standalone program, then record the new double speed audio file, it ends up being half the original file size (because the song length is now halved). Then I use my game engine (Unity) to play back the 240bpm audio file at half speed, so now it sounds normal. No artifacts or distortion.

So here's the question: am I sacrificing anything like processing power in order to play it at half-speed? I am loading in a file that's half the size so there must be some kind of trade-off somewhere right? I have a feeling nobody in their right mind would do this but why not?

share|improve this question
1  
What audio format are you using? – Philipp Feb 21 at 4:23
25  
you will be reinventing an inefficient lossy audio compression scheme. instead, try using Opus codec normally. it's very potent at low bitrates, even suitable for music at 64kbps and even smaller for simpler sounds. – Sarge Borsch Feb 21 at 9:46
8  
Try doing this with 100x the speed to achieve 99% compression. That should make the loss of quality apparent. – usr Feb 21 at 17:12
up vote 45 down vote accepted

By authoring an audio clip with high BPM, then playing back at half speed you are effectively halving the sample rate.

You can achieve a similar reduction in asset size without changing your workflow or any existing audio files by reducing the sample rate in the AudioClip inspector. Also checkout the various compression options on that page as they all have different storage / quality / CPU trade-offs.

It is often best to import assets files into your unity project as they are. Unity then allows configuration of independent quality settings for each build target.


"Am I sacrificing anything ... in order to play it at half-speed?":

Yes. You mention authoring at a high pitch so that it will sound normal on playback. By reducing the range of useful frequencies during authoring you are essentially compressing your audio into an artificiality narrow range of values, this may compromise the quality of sound on playback. This effect will not always be apparent to the listener.

share|improve this answer
3  
Decreasing sample rate only reduces the number of higher frequencies available due to en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem. Nothing to do with bit-depth, which controls the noise floor. See also: xiph.org/video/vid1.shtml – 小太郎 Feb 21 at 7:33
7  
It will completely remove the higher frequencies. For example, a 44.1 kHz sample rate will only have frequencies up to 22.05 kHz, but if your sample rate is 22 kHz, you will only have frequencies up to 11 kHz. – 小太郎 Feb 21 at 8:42
2  
In addition this may add unneeded sound processing costs during runtime. It may or may not be noticeable depending on file size and audio length. – user1306322 Feb 21 at 19:40
2  
I would like to add to this that if you still want to sacrifice quality for gaining in file size, it will be better to use some lossy compression algoritm such as mp3 then adjust the compression ratio accordingly, this kind of algorithm will also discard some frequencies, but in theory it will chose from those that are less perceptible by humans – yms Feb 21 at 23:45
4  
Not only will you lose frequencies above 11khz, if you do not purposely filter the higher frequencies out you will be subject to aliasing whereby the higher frequencies are interpreted to be lower frequencies. This will result in unintended and unwanted frequencies being heard. en.wikipedia.org/wiki/Aliasing – razethestray Feb 22 at 12:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.