16
\$\begingroup\$

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?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ What audio format are you using? \$\endgroup\$
    – Philipp
    Commented Feb 21, 2016 at 4:23
  • 27
    \$\begingroup\$ 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. \$\endgroup\$ Commented Feb 21, 2016 at 9:46
  • 8
    \$\begingroup\$ Try doing this with 100x the speed to achieve 99% compression. That should make the loss of quality apparent. \$\endgroup\$
    – usr
    Commented Feb 21, 2016 at 17:12

1 Answer 1

43
\$\begingroup\$

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.

\$\endgroup\$
6
  • 4
    \$\begingroup\$ 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 \$\endgroup\$
    – 小太郎
    Commented Feb 21, 2016 at 7:33
  • 8
    \$\begingroup\$ 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. \$\endgroup\$
    – 小太郎
    Commented Feb 21, 2016 at 8:42
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ Commented Feb 21, 2016 at 19:40
  • 3
    \$\begingroup\$ 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 \$\endgroup\$
    – yms
    Commented Feb 21, 2016 at 23:45
  • 4
    \$\begingroup\$ 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 \$\endgroup\$ Commented Feb 22, 2016 at 12:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .