将音量调节的范围设为 -100 到 0 (当前无作用), 明确增益的位置
This commit is contained in:
+7
-6
@@ -10,9 +10,10 @@
|
||||
|
||||
#define INPUT_CHANNELS 4
|
||||
#define OUTPUT_CHANNELS 2
|
||||
#define SAMPLE_SIZE 64
|
||||
#define REPORT_SIZE 142
|
||||
#define REPORT_ID 0x32
|
||||
#define SAMPLE_SIZE 64
|
||||
#define REPORT_SIZE 142
|
||||
#define REPORT_ID 0x32
|
||||
#define VOLUME_GAIN 2
|
||||
|
||||
static WDL_Resampler resampler;
|
||||
static uint8_t reportSeqCounter = 0;
|
||||
@@ -47,9 +48,9 @@ void audio_loop() {
|
||||
|
||||
// 4. 转换为int8并缓冲,满64字节即组包发送
|
||||
for (int i = 0; i < out_frames; i++) {
|
||||
int val_l = (int) (out_buf[i * 2] * 254.0f);
|
||||
int val_r = (int) (out_buf[i * 2 + 1] * 254.0f);
|
||||
haptic_buf[haptic_buf_pos++] = (int8_t) std::clamp(val_l, -128, 127);
|
||||
int val_l = (int) (out_buf[i * 2] * 127.0f * VOLUME_GAIN);
|
||||
int val_r = (int) (out_buf[i * 2 + 1] * 127.0f * VOLUME_GAIN);
|
||||
haptic_buf[haptic_buf_pos++] = (int8_t) std::clamp(val_l, -128, 127); // 似乎clamp有点多余?还是以防万一吧
|
||||
haptic_buf[haptic_buf_pos++] = (int8_t) std::clamp(val_r, -128, 127);
|
||||
|
||||
if (haptic_buf_pos != SAMPLE_SIZE) {
|
||||
|
||||
Reference in New Issue
Block a user