Audio: Best settings on all platforms.

After numerous tests, I have found the perfect audio settings. It seems samples now needs to be 2048 for everyone. Buffer needs to be 8192. Anything else gets a patchy noise. None of these platforms were using the right audio settings. Qt and SDL now sound perfect but Blackberry still doesn't (OpenAL thing?).
This commit is contained in:
Sacha committed 2013-10-22 13:29:34 +10:00
1 parent dbef0b21a9
commit 6986edb978
3 files changed
+12 -10

No files matched your search

+9 -7
View File
@@ -11,7 +11,8 @@
#include "base/NativeApp.h"
#define SAMPLE_SIZE 44100
#define AUDIO_FREQ 44100
#define SAMPLE_SIZE 2048
class BlackberryAudio
{
public:
@@ -53,22 +54,23 @@ private:
{
size_t frames_ready;
alGetSourcei(source, AL_SOURCE_STATE, &state);
if (state != AL_PLAYING)
frames_ready = NativeMix(stream, SAMPLE_SIZE / 2);
if (state != AL_PLAYING) {
frames_ready = NativeMix((short*)stream, SAMPLE_SIZE);
}
else
frames_ready = 0;
if (frames_ready > 0)
{
const size_t bytes_ready = frames_ready * sizeof(short) * 2;
alSourcei(source, AL_BUFFER, 0);
alBufferData(buffer, AL_FORMAT_STEREO16, stream, bytes_ready, SAMPLE_SIZE);
alBufferData(buffer, AL_FORMAT_STEREO16, stream, bytes_ready, AUDIO_FREQ);
alSourcei(source, AL_BUFFER, buffer);
alSourcePlay(source);
// TODO: Maybe this could get behind?
usleep((1000000 * frames_ready) / SAMPLE_SIZE);
usleep((1000000 * frames_ready) / AUDIO_FREQ);
}
else
usleep(100);
usleep(100000);
}
}
ALCdevice *alcDevice;
@@ -76,7 +78,7 @@ private:
ALenum state;
ALuint buffer;
ALuint source;
short stream[SAMPLE_SIZE];
char stream[4*SAMPLE_SIZE];
pthread_t thread_handle;
};
#endif
+1 -1
View File
@@ -523,7 +523,7 @@ int main(int argc, char *argv[]) {
fmt.freq = 44100;
fmt.format = AUDIO_S16;
fmt.channels = 2;
fmt.samples = 1024;
fmt.samples = 2048;
fmt.callback = &mixaudio;
fmt.userdata = (void *)0;
+2 -2
View File
@@ -193,7 +193,7 @@ public:
fmt.setSampleSize(AUDIO_SAMPLESIZE);
fmt.setByteOrder(QAudioFormat::LittleEndian);
fmt.setSampleType(QAudioFormat::SignedInt);
mixlen = 4*AUDIO_CHANNELS*AUDIO_SAMPLES;
mixlen = 2*AUDIO_CHANNELS*AUDIO_SAMPLES;
mixbuf = (char*)malloc(mixlen);
output = new QAudioOutput(fmt);
output->setBufferSize(mixlen);
@@ -214,7 +214,7 @@ public:
protected:
void timerEvent(QTimerEvent *) {
memset(mixbuf, 0, mixlen);
NativeMix((short *)mixbuf, mixlen / 4);
NativeMix((short *)mixbuf, AUDIO_SAMPLES);
feed->write(mixbuf, mixlen);
}
private: