ref: 2ee1bf131e6f6a38b2a828ac8518e8b8b8d98aac
parent: 479fff2ccf6ac2f28f91d5d558e5a8c20ed811a4
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Jun 23 21:15:21 EDT 2020
Update miniaudio backend to new mixer
--- a/src/Backends/Audio/miniaudio.cpp
+++ b/src/Backends/Audio/miniaudio.cpp
@@ -28,7 +28,7 @@
(void)device;
(void)input_stream;
- float *stream = (float*)output_stream;
+ short *stream = (short*)output_stream;
ma_mutex_lock(&organya_mutex);
@@ -68,6 +68,17 @@
}
}
+ // Clamp output, and convert from 8-bit to 16-bit
+ for (unsigned int i = 0; i < frames_total * 2; ++i)
+ {
+ if (stream[i] > 0x7F)
+ stream[i] = 0x7F00;
+ else if (stream[i] < -0x7F)
+ stream[i] = -0x7F00;
+ else
+ stream[i] <<= 8;
+ }
+
ma_mutex_unlock(&organya_mutex);
}
@@ -75,7 +86,7 @@
{
ma_device_config config = ma_device_config_init(ma_device_type_playback);
config.playback.pDeviceID = NULL;
- config.playback.format = ma_format_f32;
+ config.playback.format = ma_format_s16;
config.playback.channels = 2;
config.sampleRate = 0; // Let miniaudio decide what sample rate to use
config.dataCallback = Callback;