use 24-bit audio

This commit is contained in:
Sébastien Bourdeauducq 2024-12-28 19:26:40 +08:00
parent 3895b13662
commit b7973f13db

View File

@ -12,7 +12,7 @@
#include "imgui_impl_glfw.h" #include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h" #include "imgui_impl_opengl3.h"
#define SND_BITS 16 #define SND_BITS 24
#define SND_PCHAN 2 #define SND_PCHAN 2
#define SND_RCHAN 2 #define SND_RCHAN 2
#define SND_RATE 44100 #define SND_RATE 44100
@ -61,7 +61,7 @@ static void dsp_thread()
} }
uint32_t phase_out[SND_PCHAN] = { 0 }; uint32_t phase_out[SND_PCHAN] = { 0 };
int16_t buf_out[SND_BUFLEN*SND_PCHAN]; int32_t buf_out[SND_BUFLEN*SND_PCHAN];
size_t buf_out_offset = sizeof(buf_out); size_t buf_out_offset = sizeof(buf_out);
uint32_t phase_in[SND_PCHAN] = { 0 }; uint32_t phase_in[SND_PCHAN] = { 0 };
@ -97,7 +97,7 @@ static void dsp_thread()
} }
if(revents & POLLIN) { if(revents & POLLIN) {
int16_t buf_in[SND_BUFLEN*SND_RCHAN]; int32_t buf_in[SND_BUFLEN*SND_RCHAN];
size_t read = sio_read(hdl, buf_in, sizeof(buf_in)); size_t read = sio_read(hdl, buf_in, sizeof(buf_in));
// input channels are averaged together to reduce uncorrelated noise // input channels are averaged together to reduce uncorrelated noise
double scale = pow(0.5, SND_BITS-1)/SND_RCHAN; double scale = pow(0.5, SND_BITS-1)/SND_RCHAN;