mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-09 13:07:03 +03:00
add preset buttons (use macro) + change name of MONO channel pseudo-gain - release
This commit is contained in:
@@ -97,29 +97,6 @@ static void sendIR(u16_t addr, u16_t cmd) {
|
|||||||
UNLOCK_P;
|
UNLOCK_P;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lms_power(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_POWER_FRONT, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button power");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void lms_volume_up(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_VOLUP_FRONT, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button volup");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_volume_down(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_VOLDOWN_FRONT, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button voldown");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_toggle(bool pressed) {
|
static void lms_toggle(bool pressed) {
|
||||||
if (raw_mode) {
|
if (raw_mode) {
|
||||||
sendBUTN(BUTN_PAUSE, pressed);
|
sendBUTN(BUTN_PAUSE, pressed);
|
||||||
@@ -136,158 +113,49 @@ static void lms_pause(bool pressed) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lms_play(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_PLAY, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button play.single");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_stop(bool pressed) {
|
static void lms_stop(bool pressed) {
|
||||||
cli_send_cmd("button stop");
|
cli_send_cmd("button stop");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lms_rew(bool pressed) {
|
#define LMS_CALLBACK(N,B,E) \
|
||||||
if (raw_mode) {
|
static void lms_##N (bool pressed) { \
|
||||||
sendBUTN(BUTN_REW, pressed);
|
if (raw_mode) { \
|
||||||
} else {
|
sendBUTN( BUTN_##B , pressed ); \
|
||||||
cli_send_cmd("button rew.repeat");
|
} else { \
|
||||||
}
|
cli_send_cmd("button" " " #E); \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lms_fwd(bool pressed) {
|
LMS_CALLBACK(power, POWER_FRONT, power)
|
||||||
if (raw_mode) {
|
LMS_CALLBACK(play, PLAY, play.single)
|
||||||
sendBUTN(BUTN_FWD, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button fwd.repeat");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_prev(bool pressed) {
|
LMS_CALLBACK(volup, VOLUP_FRONT, volup)
|
||||||
if (raw_mode) {
|
LMS_CALLBACK(voldown, VOLDOWN_FRONT, voldown)
|
||||||
sendBUTN(BUTN_REW, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button rew");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_next(bool pressed) {
|
LMS_CALLBACK(rew, REW, rew.repeat)
|
||||||
if (raw_mode) {
|
LMS_CALLBACK(fwd, FWD, fwd.repeat)
|
||||||
sendBUTN(BUTN_FWD, pressed);
|
LMS_CALLBACK(prev, REW, rew)
|
||||||
} else {
|
LMS_CALLBACK(next, FWD, fwd)
|
||||||
cli_send_cmd("button fwd");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_up(bool pressed) {
|
LMS_CALLBACK(up, ARROW_UP, arrow_up)
|
||||||
if (raw_mode) {
|
LMS_CALLBACK(down, ARROW_DOWN, arrow_down)
|
||||||
sendBUTN(BUTN_ARROW_UP, pressed);
|
LMS_CALLBACK(left, ARROW_LEFT, arrow_left)
|
||||||
} else {
|
LMS_CALLBACK(right, ARROW_RIGHT, arrow_right)
|
||||||
cli_send_cmd("button arrow_up");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_down(bool pressed) {
|
LMS_CALLBACK(pre1, PRESET_1, preset1.single)
|
||||||
if (raw_mode) {
|
LMS_CALLBACK(pre2, PRESET_2, preset2.single)
|
||||||
sendBUTN(BUTN_ARROW_DOWN, pressed);
|
LMS_CALLBACK(pre3, PRESET_3, preset3.single)
|
||||||
} else {
|
LMS_CALLBACK(pre4, PRESET_4, preset4.single)
|
||||||
cli_send_cmd("button arrow_down");
|
LMS_CALLBACK(pre5, PRESET_5, preset5.single)
|
||||||
}
|
LMS_CALLBACK(pre6, PRESET_6, preset6.single)
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_left(bool pressed) {
|
LMS_CALLBACK(knob_left, KNOB_LEFT, knob_left)
|
||||||
if (raw_mode) {
|
LMS_CALLBACK(knob_right, KNOB_RIGHT, knob_right)
|
||||||
sendBUTN(BUTN_ARROW_LEFT, pressed);
|
LMS_CALLBACK(knob_push, KNOB_PUSH, knob_push)
|
||||||
} else {
|
|
||||||
cli_send_cmd("button arrow_left");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_right(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_ARROW_RIGHT, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button arrow_right");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_pre1(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_PRESET_1, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button preset_1.single");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_pre2(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_PRESET_2, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button preset_2.single");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_pre3(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_PRESET_3, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button preset_3.single");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_pre4(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_PRESET_4, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button preset_4.single");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_pre5(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_PRESET_5, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button preset_5.single");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_pre6(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_PRESET_6, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button preset_6.single");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void lms_knob_left(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_KNOB_LEFT, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button knob_left");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_knob_right(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_KNOB_RIGHT, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button knob_right");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lms_knob_push(bool pressed) {
|
|
||||||
if (raw_mode) {
|
|
||||||
sendBUTN(BUTN_KNOB_PUSH, pressed);
|
|
||||||
} else {
|
|
||||||
cli_send_cmd("button knob_push");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const actrls_t LMS_controls = {
|
const actrls_t LMS_controls = {
|
||||||
lms_power,
|
lms_power,
|
||||||
lms_volume_up, lms_volume_down, // volume up, volume down
|
lms_volup, lms_voldown, // volume up, volume down
|
||||||
lms_toggle, lms_play, // toggle, play
|
lms_toggle, lms_play, // toggle, play
|
||||||
lms_pause, lms_stop, // pause, stop
|
lms_pause, lms_stop, // pause, stop
|
||||||
lms_rew, lms_fwd, // rew, fwd
|
lms_rew, lms_fwd, // rew, fwd
|
||||||
|
|||||||
@@ -254,8 +254,8 @@ frames_t _output_frames(frames_t avail) {
|
|||||||
|
|
||||||
out_frames = !silence ? min(size, cont_frames) : size;
|
out_frames = !silence ? min(size, cont_frames) : size;
|
||||||
|
|
||||||
if (output.channels & 0x01) gainR = MONO_MUTED;
|
if (output.channels & 0x01) gainR = COPY_MONO;
|
||||||
else if (output.channels & 0x02) gainL = MONO_MUTED;
|
else if (output.channels & 0x02) gainL = COPY_MONO;
|
||||||
|
|
||||||
wrote = output.write_cb(out_frames, silence, gainL, gainR, cross_gain_in, cross_gain_out, &cross_ptr);
|
wrote = output.write_cb(out_frames, silence, gainL, gainR, cross_gain_in, cross_gain_out, &cross_ptr);
|
||||||
|
|
||||||
|
|||||||
@@ -364,13 +364,13 @@ inline
|
|||||||
void _apply_gain(struct buffer *outputbuf, frames_t count, s32_t gainL, s32_t gainR) {
|
void _apply_gain(struct buffer *outputbuf, frames_t count, s32_t gainL, s32_t gainR) {
|
||||||
if (gainL == FIXED_ONE && gainR == FIXED_ONE) {
|
if (gainL == FIXED_ONE && gainR == FIXED_ONE) {
|
||||||
return;
|
return;
|
||||||
} else if (gainL == MONO_MUTED) {
|
} else if (gainL == COPY_MONO) {
|
||||||
ISAMPLE_T *ptr = (ISAMPLE_T *)(void *)outputbuf->readp + 1;
|
ISAMPLE_T *ptr = (ISAMPLE_T *)(void *)outputbuf->readp + 1;
|
||||||
while (count--) {
|
while (count--) {
|
||||||
*(ptr - 1) = *ptr = gain(gainR, *ptr);
|
*(ptr - 1) = *ptr = gain(gainR, *ptr);
|
||||||
ptr += 2;
|
ptr += 2;
|
||||||
}
|
}
|
||||||
} else if (gainR == MONO_MUTED) {
|
} else if (gainR == COPY_MONO) {
|
||||||
ISAMPLE_T *ptr = (ISAMPLE_T *)(void *)outputbuf->readp;
|
ISAMPLE_T *ptr = (ISAMPLE_T *)(void *)outputbuf->readp;
|
||||||
while (count--) {
|
while (count--) {
|
||||||
*(ptr + 1) = *ptr = gain(gainL, *ptr);
|
*(ptr + 1) = *ptr = gain(gainL, *ptr);
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ void _wake_create(event_event*);
|
|||||||
#define MAX_SILENCE_FRAMES 2048
|
#define MAX_SILENCE_FRAMES 2048
|
||||||
|
|
||||||
#define FIXED_ONE 0x10000
|
#define FIXED_ONE 0x10000
|
||||||
#define MONO_MUTED (FIXED_ONE + 1)
|
#define COPY_MONO (FIXED_ONE + 1)
|
||||||
|
|
||||||
#ifndef BYTES_PER_FRAME
|
#ifndef BYTES_PER_FRAME
|
||||||
#define BYTES_PER_FRAME 8
|
#define BYTES_PER_FRAME 8
|
||||||
|
|||||||
Reference in New Issue
Block a user