使用ds5原始的音量调节范围

This commit is contained in:
awalol
2026-05-07 22:28:29 +08:00
parent 33c44907b6
commit 8bb0c816df
4 changed files with 33 additions and 12 deletions
+4 -2
View File
@@ -7,6 +7,7 @@
#include "resample.h"
#include "tusb.h"
#include <algorithm>
#include <cmath>
#include <cstdio>
#include "opus.h"
#include "utils.h"
@@ -59,9 +60,10 @@ void audio_loop() {
WDL_ResampleSample *in_buf;
int nframes = resampler.ResamplePrepare(frames, OUTPUT_CHANNELS, &in_buf);
float gain = mute[0] ? 0.0f : powf(10.0f, get_config().speaker_volume / 20.0f);
for (int i = 0; i < nframes; i++) {
audio_buf[audio_buf_pos++] = raw[i * INPUT_CHANNELS] / 32768.0f * (get_config().speaker_volume - 1.0f) * !mute[0];
audio_buf[audio_buf_pos++] = raw[i * INPUT_CHANNELS + 1] / 32768.0f * (get_config().speaker_volume - 1.0f) * !mute[0];
audio_buf[audio_buf_pos++] = raw[i * INPUT_CHANNELS] / 32768.0f * gain;
audio_buf[audio_buf_pos++] = raw[i * INPUT_CHANNELS + 1] / 32768.0f * gain;
if (audio_buf_pos == 512 * 2) {
static audio_raw_element element{};
memcpy(element.data,audio_buf,512 * 2 * 4);