fix: usbaudio set_cur cmd set volume

This commit is contained in:
awalol
2026-05-07 19:11:42 +08:00
parent 8155ebdfec
commit b736cc91d7
4 changed files with 19 additions and 4 deletions
+3 -2
View File
@@ -13,6 +13,7 @@
#include "pico/multicore.h"
#include "pico/util/queue.h"
#include "config.h"
#include "usb.h"
#define INPUT_CHANNELS 4
#define OUTPUT_CHANNELS 2
@@ -59,8 +60,8 @@ void audio_loop() {
int nframes = resampler.ResamplePrepare(frames, OUTPUT_CHANNELS, &in_buf);
for (int i = 0; i < nframes; i++) {
audio_buf[audio_buf_pos++] = raw[i * INPUT_CHANNELS] / 32768.0f * (get_config().speaker_volume - 1.0f);
audio_buf[audio_buf_pos++] = raw[i * INPUT_CHANNELS + 1] / 32768.0f * (get_config().speaker_volume - 1.0f);
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];
if (audio_buf_pos == 512 * 2) {
static audio_raw_element element{};
memcpy(element.data,audio_buf,512 * 2 * 4);