mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-03-21 13:59:25 +00:00
Compare commits
4 Commits
SqueezeAmp
...
I2S-4MFlas
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed00f029a6 | ||
|
|
ee35e1dc99 | ||
|
|
fd36f6fc71 | ||
|
|
347a795b5f |
@@ -56,9 +56,10 @@ static const actrls_config_map_t actrls_config_map[] =
|
||||
|
||||
// BEWARE: the actions below need to stay aligned with the corresponding enum to properly support json parsing
|
||||
#define EP(x) [x] = #x /* ENUM PRINT */
|
||||
static const char * actrls_action_s[ ] = { EP(ACTRLS_VOLUP),EP(ACTRLS_VOLDOWN),EP(ACTRLS_TOGGLE),EP(ACTRLS_PLAY),
|
||||
static const char * actrls_action_s[ ] = { EP(ACTRLS_POWER),EP(ACTRLS_VOLUP),EP(ACTRLS_VOLDOWN),EP(ACTRLS_TOGGLE),EP(ACTRLS_PLAY),
|
||||
EP(ACTRLS_PAUSE),EP(ACTRLS_STOP),EP(ACTRLS_REW),EP(ACTRLS_FWD),EP(ACTRLS_PREV),EP(ACTRLS_NEXT),
|
||||
EP(BCTRLS_UP),EP(BCTRLS_DOWN),EP(BCTRLS_LEFT),EP(BCTRLS_RIGHT),
|
||||
EP(BCTRLS_PS1),EP(BCTRLS_PS2),EP(BCTRLS_PS3),EP(BCTRLS_PS4),EP(BCTRLS_PS5),EP(BCTRLS_PS6),
|
||||
EP(KNOB_LEFT),EP(KNOB_RIGHT),EP(KNOB_PUSH),
|
||||
""} ;
|
||||
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
#include "buttons.h"
|
||||
|
||||
// BEWARE: this is the index of the array of action below (change actrls_action_s as well!)
|
||||
typedef enum { ACTRLS_NONE = -1, ACTRLS_VOLUP, ACTRLS_VOLDOWN, ACTRLS_TOGGLE, ACTRLS_PLAY,
|
||||
typedef enum { ACTRLS_NONE = -1, ACTRLS_POWER,ACTRLS_VOLUP, ACTRLS_VOLDOWN, ACTRLS_TOGGLE, ACTRLS_PLAY,
|
||||
ACTRLS_PAUSE, ACTRLS_STOP, ACTRLS_REW, ACTRLS_FWD, ACTRLS_PREV, ACTRLS_NEXT,
|
||||
BCTRLS_UP, BCTRLS_DOWN, BCTRLS_LEFT, BCTRLS_RIGHT,
|
||||
BCTRLS_PS1,BCTRLS_PS2,BCTRLS_PS3,BCTRLS_PS4,BCTRLS_PS5,BCTRLS_PS6,
|
||||
KNOB_LEFT, KNOB_RIGHT, KNOB_PUSH,
|
||||
ACTRLS_REMAP, ACTRLS_MAX
|
||||
} actrls_action_e;
|
||||
|
||||
@@ -97,22 +97,6 @@ static void sendIR(u16_t addr, u16_t cmd) {
|
||||
UNLOCK_P;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (raw_mode) {
|
||||
sendBUTN(BUTN_PAUSE, pressed);
|
||||
@@ -129,114 +113,56 @@ 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) {
|
||||
cli_send_cmd("button stop");
|
||||
}
|
||||
|
||||
static void lms_rew(bool pressed) {
|
||||
if (raw_mode) {
|
||||
sendBUTN(BUTN_REW, pressed);
|
||||
} else {
|
||||
cli_send_cmd("button rew.repeat");
|
||||
}
|
||||
#define LMS_CALLBACK(N,B,E) \
|
||||
static void lms_##N (bool pressed) { \
|
||||
if (raw_mode) { \
|
||||
sendBUTN( BUTN_##B , pressed ); \
|
||||
} else { \
|
||||
cli_send_cmd("button" " " #E); \
|
||||
} \
|
||||
}
|
||||
|
||||
static void lms_fwd(bool pressed) {
|
||||
if (raw_mode) {
|
||||
sendBUTN(BUTN_FWD, pressed);
|
||||
} else {
|
||||
cli_send_cmd("button fwd.repeat");
|
||||
}
|
||||
}
|
||||
LMS_CALLBACK(power, POWER_FRONT, power)
|
||||
LMS_CALLBACK(play, PLAY, play.single)
|
||||
|
||||
static void lms_prev(bool pressed) {
|
||||
if (raw_mode) {
|
||||
sendBUTN(BUTN_REW, pressed);
|
||||
} else {
|
||||
cli_send_cmd("button rew");
|
||||
}
|
||||
}
|
||||
LMS_CALLBACK(volup, VOLUP_FRONT, volup)
|
||||
LMS_CALLBACK(voldown, VOLDOWN_FRONT, voldown)
|
||||
|
||||
static void lms_next(bool pressed) {
|
||||
if (raw_mode) {
|
||||
sendBUTN(BUTN_FWD, pressed);
|
||||
} else {
|
||||
cli_send_cmd("button fwd");
|
||||
}
|
||||
}
|
||||
LMS_CALLBACK(rew, REW, rew.repeat)
|
||||
LMS_CALLBACK(fwd, FWD, fwd.repeat)
|
||||
LMS_CALLBACK(prev, REW, rew)
|
||||
LMS_CALLBACK(next, FWD, fwd)
|
||||
|
||||
static void lms_up(bool pressed) {
|
||||
if (raw_mode) {
|
||||
sendBUTN(BUTN_ARROW_UP, pressed);
|
||||
} else {
|
||||
cli_send_cmd("button arrow_up");
|
||||
}
|
||||
}
|
||||
LMS_CALLBACK(up, ARROW_UP, arrow_up)
|
||||
LMS_CALLBACK(down, ARROW_DOWN, arrow_down)
|
||||
LMS_CALLBACK(left, ARROW_LEFT, arrow_left)
|
||||
LMS_CALLBACK(right, ARROW_RIGHT, arrow_right)
|
||||
|
||||
static void lms_down(bool pressed) {
|
||||
if (raw_mode) {
|
||||
sendBUTN(BUTN_ARROW_DOWN, pressed);
|
||||
} else {
|
||||
cli_send_cmd("button arrow_down");
|
||||
}
|
||||
}
|
||||
LMS_CALLBACK(pre1, PRESET_1, preset1.single)
|
||||
LMS_CALLBACK(pre2, PRESET_2, preset2.single)
|
||||
LMS_CALLBACK(pre3, PRESET_3, preset3.single)
|
||||
LMS_CALLBACK(pre4, PRESET_4, preset4.single)
|
||||
LMS_CALLBACK(pre5, PRESET_5, preset5.single)
|
||||
LMS_CALLBACK(pre6, PRESET_6, preset6.single)
|
||||
|
||||
static void lms_left(bool pressed) {
|
||||
if (raw_mode) {
|
||||
sendBUTN(BUTN_ARROW_LEFT, pressed);
|
||||
} 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_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");
|
||||
}
|
||||
}
|
||||
LMS_CALLBACK(knob_left, KNOB_LEFT, knob_left)
|
||||
LMS_CALLBACK(knob_right, KNOB_RIGHT, knob_right)
|
||||
LMS_CALLBACK(knob_push, KNOB_PUSH, knob_push)
|
||||
|
||||
const actrls_t LMS_controls = {
|
||||
lms_volume_up, lms_volume_down, // volume up, volume down
|
||||
lms_power,
|
||||
lms_volup, lms_voldown, // volume up, volume down
|
||||
lms_toggle, lms_play, // toggle, play
|
||||
lms_pause, lms_stop, // pause, stop
|
||||
lms_rew, lms_fwd, // rew, fwd
|
||||
lms_prev, lms_next, // prev, next
|
||||
lms_up, lms_down,
|
||||
lms_left, lms_right,
|
||||
lms_pre1, lms_pre2, lms_pre3, lms_pre4, lms_pre5, lms_pre6,
|
||||
lms_knob_left, lms_knob_right, lms_knob_push,
|
||||
};
|
||||
|
||||
|
||||
@@ -254,8 +254,8 @@ frames_t _output_frames(frames_t avail) {
|
||||
|
||||
out_frames = !silence ? min(size, cont_frames) : size;
|
||||
|
||||
if (output.channels & 0x01) gainR = MONO_MUTED;
|
||||
else if (output.channels & 0x02) gainL = MONO_MUTED;
|
||||
if (output.channels & 0x01) gainR = COPY_MONO;
|
||||
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);
|
||||
|
||||
|
||||
@@ -364,13 +364,13 @@ inline
|
||||
void _apply_gain(struct buffer *outputbuf, frames_t count, s32_t gainL, s32_t gainR) {
|
||||
if (gainL == FIXED_ONE && gainR == FIXED_ONE) {
|
||||
return;
|
||||
} else if (gainL == MONO_MUTED) {
|
||||
} else if (gainL == COPY_MONO) {
|
||||
ISAMPLE_T *ptr = (ISAMPLE_T *)(void *)outputbuf->readp + 1;
|
||||
while (count--) {
|
||||
*(ptr - 1) = *ptr = gain(gainR, *ptr);
|
||||
ptr += 2;
|
||||
}
|
||||
} else if (gainR == MONO_MUTED) {
|
||||
} else if (gainR == COPY_MONO) {
|
||||
ISAMPLE_T *ptr = (ISAMPLE_T *)(void *)outputbuf->readp;
|
||||
while (count--) {
|
||||
*(ptr + 1) = *ptr = gain(gainL, *ptr);
|
||||
|
||||
@@ -472,7 +472,7 @@ void _wake_create(event_event*);
|
||||
#define MAX_SILENCE_FRAMES 2048
|
||||
|
||||
#define FIXED_ONE 0x10000
|
||||
#define MONO_MUTED (FIXED_ONE + 1)
|
||||
#define COPY_MONO (FIXED_ONE + 1)
|
||||
|
||||
#ifndef BYTES_PER_FRAME
|
||||
#define BYTES_PER_FRAME 8
|
||||
|
||||
Reference in New Issue
Block a user