Download

Sample rate conflicts

I am trying to set my project to 44.1khz in Project Settings->Platforms - Mac->Audio Mixer Sample Rate and have it set to 44100. However upon loading the engine, Audio MIDI Setup shows my audio device switches to 48k. If I manually set it back to 44.1, and Play In-Engine, it gets set back to 48k. I don’t seem to see any way around it. I am using the new audio engine on macOS, so maybe the bug lies with that?

Also, if you look through the source, there’s a lot of assumptions about sample rate.

A few examples:

From MediaSoundWave.cpp:58


// poor man's re-sampling
const float ResampleRatio = (float)SinkSampleRate / 44100.0f;

XAudio2Support.h:904


return (double)VoiceState.SamplesPlayed / 44100;

AudioVolume.cpp:35


float FilterConstant = 2.0f * FMath::Sin(PI * 6000.0f * InteriorLPF / 48000);

Hey Coupler!

To be safe, can you make sure you’re loading the AudioMixer module correctly? I’ve posted instructions for Mac in this post:

Note that the new audio mixer code on IOS is experimental. First are you sure you’re running 4.17 with the audio mixer on macOS?

The other hard-coded sample rates are remnants of the old audio engine and are really terrible code. The old audio engine was hard-coded to 44100 so there’s cases where it’s just hard-coded everywhere. The AudioVolume.cpp change is a fix to when it was even more terrible. That code is inside a fix-up block that converts old serialized data to new serilalized data.

Also note that the project setting is supposed to indicate what SR you want the audio mixer to mix to. Different platforms do different things with the final output SR. For example, we allow XAudio2 to do a final Sample Rate conversion to match whatever the sample rate of the hardware. So you might render to 48k, but allow the final output hardare be at 96k. This allows for seamless hot swapping and allows for using sample rate as a CPU optimization (i.e. rendering at a lower SR is cheaper for your game).

We’re working on an iOS hotfix for the audio mixer right now so we’ll check out this issue w/ respect to overriding your hardware SR.

Yeah, I am just building for Mac at the moment. I do have the right setting in the .ini file, so it should be using the engine. Thanks for updating that post w Mac instructions, btw - I wasn’t properly using it before.

That is cool about the modularity between how the audio is rendered and how it is output to the device. I guess the real question I have is - how do I set the internal rendering sample rate of the engine? “AudioSampleRate=44100” in MacEngine.ini doesn’t work…

Is the preferred audio sample rate for audio files 44.1 kHz or 48 kHz? I’ve already exported most of the sounds at 44.1 kHz from reference of older example files. Has this changed with the new engine? Only targeting Win64 if that matters.