Compare commits

...

43 Commits

Author SHA1 Message Date
Sébastien
4dc6424fed Add github-releases to TLS certs 2021-03-16 17:26:34 -04:00
Philippe G
a989fe06c2 add version - release 2021-03-16 13:37:43 -07:00
philippe44
1b5a877b98 Update CrossBuild.yml 2021-03-16 13:36:33 -07:00
sle118
9c9f79b0b6 Made certificate script an executable for github 2021-03-16 14:33:19 -04:00
Sébastien
6fef6d679e Update CrossBuild.yml 2021-03-16 14:26:40 -04:00
Sébastien
aa54b9dff9 Update CrossBuild.yml 2021-03-16 14:19:05 -04:00
Sébastien
05a704e7ec Update CrossBuild.yml 2021-03-16 14:16:44 -04:00
Sébastien
09e6518870 Update CrossBuild.yml 2021-03-16 14:02:54 -04:00
Sébastien
4d70d0998c Update certificates during build 2021-03-16 13:42:07 -04:00
Sébastien
9d0d957ec3 Update Certificates during build 2021-03-16 13:37:04 -04:00
philippe44
1be4c89f3c release 2021-03-15 23:20:08 -07:00
philippe44
893e67dfa4 release 2021-03-15 23:10:11 -07:00
Philippe G
eced71b2be release 2021-03-14 17:07:39 -07:00
Philippe G
1aa24393e4 release 2021-03-14 17:03:26 -07:00
philippe44
06b0d9aa3e release 2021-03-14 16:49:34 -07:00
Philippe G
6d73ba2d96 release 2021-03-14 16:28:07 -07:00
Philippe G
43785f1a7d Revert "release"
This reverts commit f772b3d07b.
2021-03-14 16:27:41 -07:00
Philippe G
f80e923c2a Merge branch 'master-cmake' of https://github.com/sle118/squeezelite-esp32 into master-cmake 2021-03-14 16:27:31 -07:00
Philippe G
f772b3d07b release 2021-03-14 16:27:05 -07:00
philippe44
a6ae5d795a Update CrossBuild.yml 2021-03-14 16:23:14 -07:00
philippe44
c08286874a Update CrossBuild.yml 2021-03-14 16:22:13 -07:00
Philippe G
7b10bee68a release 2021-03-14 15:37:11 -07:00
Philippe G
d42098d1c0 Merge branch 'master-cmake' of https://github.com/sle118/squeezelite-esp32 into master-cmake 2021-03-14 14:44:36 -07:00
Philippe G
9563f1ed44 add 32 bits edition - release 2021-03-14 14:42:25 -07:00
philippe44
1f6b24db33 Update CrossBuild.yml 2021-03-14 14:31:15 -07:00
philippe44
5f3a22bb63 Update CrossBuild.yml 2021-03-14 14:26:09 -07:00
philippe44
574c7706a0 Update CrossBuild.yml 2021-03-14 14:18:16 -07:00
Philippe G
46a43efd70 opus & vorbis 32 bits fix 2021-03-11 17:44:23 -08:00
Philippe G
e8bba8af24 AAC 32 bits mode correction 2021-03-11 12:59:34 -08:00
Philippe G
b9466bf7b2 BT non-absolute volume handling 2021-03-07 16:33:26 -08:00
Philippe G
b0d8401274 32 bits mode for AirPlay 2021-03-06 23:04:05 -08:00
Philippe G
1063cd5899 allow -Z even w/o RESAMPLE (32 bits mode) 2021-03-06 14:02:42 -08:00
Philippe G
8f4b1022e2 Merge branch 'master-cmake' of https://github.com/sle118/squeezelite-esp32 into master-cmake 2021-03-05 22:57:35 -08:00
Philippe G
6d45f6d1b6 Tweak 32 bits mode (enable 20 bits spdif) 2021-03-05 22:13:20 -08:00
philippe44
6beafaa747 More bit depth comments 2021-03-05 22:07:37 -08:00
philippe44
fe80ee3c18 Update README.md 2021-03-05 21:59:51 -08:00
philippe44
a5d6600dea Update README.md 2021-03-05 21:59:22 -08:00
philippe44
8132311c75 Update README.md 2021-03-05 21:58:51 -08:00
philippe44
9ecd7e9a79 Bits depth clarification 2021-03-05 09:16:50 -08:00
Philippe G
b3ff717d32 32 bits cleanup 2021-03-04 20:30:06 -08:00
Philippe G
15f1cebcdb ignore 2021-03-04 20:27:16 -08:00
Philippe G
6d9eaf4109 add balance option - release 2021-02-25 06:10:03 -08:00
Philippe G
3f0882ead6 combined channels - release 2021-02-20 17:34:25 -08:00
25 changed files with 258 additions and 177 deletions

View File

@@ -27,6 +27,7 @@ jobs:
max-parallel: 1
matrix:
node: [I2S-4MFlash, ESP32-A1S, SqueezeAmp]
depth: [16, 32]
steps:
- name: Set target name
run: |
@@ -40,21 +41,25 @@ jobs:
id: cache-build
uses: actions/cache@v2
with:
path: build
key: ${{ runner.os }}-${{ matrix.node }}
path: |
build
/var/lib/docker
key: ${{ runner.os }}-${{ matrix.node }}-${{ matrix.depth }}
- name: Set build parameters
run: |
git update-index --chmod=+x ./server_certs/getcert.sh
cd server_certs;./getcert.sh;cat github.pem;cd ..
shopt -s nocasematch
branch_name="${GITHUB_REF//refs\/heads\//}"
branch_name="${branch_name//[^a-zA-Z0-9\-~!@_\.]/}"
BUILD_NUMBER=${{ needs.job1.outputs.build_number }}
echo "BUILD_NUMBER=${BUILD_NUMBER}" >> $GITHUB_ENV
tag="${TARGET_BUILD_NAME}.${BUILD_NUMBER}.${branch_name}"
tag="${TARGET_BUILD_NAME}.${{matrix.depth}}.${BUILD_NUMBER}.${branch_name}"
echo "tag=${tag}" >> $GITHUB_ENV
last_commit="$(git log --pretty=format:'%s' --max-count=1)"
if [[ "$last_commit" =~ .*"Release".* ]]; then echo "release_flag=1" >> $GITHUB_ENV; else echo "release_flag=0" >> $GITHUB_ENV; fi
name="dev.${BUILD_NUMBER}#v4.0#${TARGET_BUILD_NAME}#${branch_name}"
artifact_prefix="squeezelite-esp32-${branch_name}-${TARGET_BUILD_NAME}-${build_version_prefix}${BUILD_NUMBER}"
name="dev.${BUILD_NUMBER}-${{matrix.depth}}#v4.0#${TARGET_BUILD_NAME}#${branch_name}"
artifact_prefix="squeezelite-esp32-${branch_name}-${TARGET_BUILD_NAME}-${{matrix.depth}}-${build_version_prefix}${BUILD_NUMBER}"
artifact_file_name="${artifact_prefix}.zip"
artifact_bin_file_name="${artifact_prefix}.bin"
echo "name=${name}" >> $GITHUB_ENV
@@ -80,7 +85,9 @@ jobs:
run: |
env | grep "artifact\|tag\|GITHUB\|version\|NUMBER\|TARGET" >${TARGET_BUILD_NAME}-env.txt
echo "${tag}" >version.txt
docker run --env-file=${TARGET_BUILD_NAME}-env.txt --rm -v $PWD:/project -w /project sle118/idf:release-v4.0 /bin/bash -c "cp build-scripts/${TARGET_BUILD_NAME}-sdkconfig.defaults sdkconfig && idf.py build && zip -r build_output.zip build && zip build/${artifact_file_name} partitions*.csv build/*.bin build/bootloader/bootloader.bin build/partition_table/partition-table.bin build/flash_project_args build/size_*.txt"
docker pull sle118/idf:release-v4.0
docker info
docker run --env-file=${TARGET_BUILD_NAME}-env.txt -v $PWD:/project -w /project sle118/idf:release-v4.0 /bin/bash -c "cp build-scripts/${TARGET_BUILD_NAME}-sdkconfig.defaults sdkconfig && idf.py build -DDEPTH=${{ matrix.depth }} -DBUILD_NUMBER=${BUILD_NUMBER}-${{ matrix.depth }} && zip -r build_output.zip build && zip build/${artifact_file_name} partitions*.csv build/*.bin build/bootloader/bootloader.bin build/partition_table/partition-table.bin build/flash_project_args build/size_*.txt"
# - name: Build Mock firmware
# run: |
# mkdir -p build

1
.gitignore vendored
View File

@@ -97,3 +97,4 @@ components/wifi-manager/res/backup/
test/.vscode/
node_modules/*
esp-dsp/

View File

@@ -23,6 +23,18 @@ Other features include
- Full web interface for further configuration/management
- Firmware over-the-air update
**Important note** (philippe44 writing)
The main build of squeezelite-esp32 is a 16 bits internal core with all calculations in 32 bits or float precision. This is a design choice I've made to preserve CPU performances (it is already stretching a lot the esp32 chipset) and optimize memory usage as we only have 4MB of usable RAM. Now, when I did the porting of squeezelite to esp32, I've also made the core 16 or 32 bits compatible at compile-time. So far, it works in 32 bits but very little tests have been done. You can chose to compile it in 32 bits mode by changing the cmake file in components/squeezelite. Note the following limitation in 32 bits
- no resampling
- no equalizer
- buffer are smaller, so crossfade will be at best 5s at 44.1 kHz
- SPDIF is 20 bits maximum *(1)*
- display will be slower
I've not tested all codecs, I've only verified it with TAS57xx DAC and in general I've not tested that mode more than a few minutes. I'm not very interested above 16 bits samples because it does not bring anything (I have an engineering background in theory of information). On memory Some might correctly comment that wrover module have 8MB of RAM, but the processor is only able to address 4MB and the remaining 4MB must be paginated by smaller blocks and I don't have patience to that.
## Supported Hardware
Any esp32-based hardware with at least 4MB of flash and 4MB of PSRAM will be capable of running squeezelite-esp32 and there are various boards that include such chip. A few are mentionned below, but any should work. You can find various help & instructions [here](https://forums.slimdevices.com/showthread.php?112697-ANNOUNCE-Squeezelite-ESP32-(dedicated-thread))
### Raw WROVER module
@@ -470,3 +482,6 @@ Use 'idf monitor' to monitor the application (see esp-idf documentation)
- add DEPS_CFLAGS and DEPS_LIBS to avoid pkg-config to be required
- stack consumption can be very high with some codec variants, so set NONTHREADSAFE_PSEUDOSTACK and GLOBAL_STACK_SIZE=32000 and unset VAR_ARRAYS in config.h
- libmad has been patched to avoid using a lot of stack and is not provided here. There is an issue with sync detection in 1.15.1b from where the original stack patch was done but since a few fixes have been made wrt sync detection. This 1.15.1b-10 found on debian fixes the issue where mad thinks it has reached sync but has not and so returns a wrong sample rate. It comes at the expense of 8KB (!) of code where a simple check in squeezelite/mad.c that next_frame[0] is 0xff and next_frame[1] & 0xf0 is 0xf0 does the trick ...
# Footnotes
(1) SPDIF is made by tricking the I2S bus but this consumes a fair bit of CPU as it multiplies by four the throughput on the i2s bus. To optimize some computation, the parity of the spdif frames must always be 0, so at least one bit has to be available to force it. As SPDIF samples are 20+4 bits length maximum, the LSB is used for that purpose, so the bit 24 is randomly toggling. It does not matter for 16 bits samples but it has been chosen to truncate the last 4 bits for 24 bits samples. I'm sure that some smart dude can further optimize spdif_convert() and use the user bit instead. You're welcome to do a PR but, as said above, I (philippe44) am not interested by 24 bits mental illness :-) and I've already made an effort to provide 20 bits which already way more what's needed :-)

View File

@@ -295,6 +295,9 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
if (ESP_A2D_AUDIO_STATE_STARTED == a2d->audio_stat.state) {
s_audio = AUDIO_CONNECTED;
// send memorized volume for devices that can't do absolute volume
(*bt_app_a2d_cmd_cb)(BT_SINK_VOLUME, s_volume);
// verify that we can take control
if ((*bt_app_a2d_cmd_cb)(BT_SINK_AUDIO_STARTED, s_sample_rate)) {

View File

@@ -1,5 +1,3 @@
idf_component_register( SRC_DIRS . external ac101 tas57xx
INCLUDE_DIRS . ac101
PRIV_REQUIRES
@@ -17,8 +15,6 @@ idf_component_register( SRC_DIRS . external ac101 tas57xx
EMBED_FILES vu.data
)
set_source_files_properties(mad.c
PROPERTIES COMPILE_FLAGS
-Wno-maybe-uninitialized
@@ -33,9 +29,11 @@ set_source_files_properties(flac.c
-Wno-maybe-uninitialized
)
add_definitions(-DLINKALL -DLOOPBACK -DNO_FAAD -DRESAMPLE16 -DEMBEDDED -DTREMOR_ONLY -DBYTES_PER_FRAME=4)
add_definitions(-DLINKALL -DLOOPBACK -DNO_FAAD -DEMBEDDED -DTREMOR_ONLY -DCUSTOM_VERSION=${BUILD_NUMBER})
if(${DEPTH} EQUAL "32")
add_definitions(-DBYTES_PER_FRAME=8)
else()
add_definitions(-DBYTES_PER_FRAME=4)
endif()
add_compile_options (-O3 )

View File

@@ -31,7 +31,7 @@ extern log_level loglevel;
static bool enable_bt_sink;
static bool enable_airplay;
#define RAOP_OUTPUT_SIZE (RAOP_SAMPLE_RATE * 2 * 2 * 2 * 1.2)
#define RAOP_OUTPUT_SIZE (((RAOP_SAMPLE_RATE * BYTES_PER_FRAME * 2 * 120) / 100) & ~BYTES_PER_FRAME)
#define SYNC_WIN_SLOW 32
#define SYNC_WIN_CHECK 8
#define SYNC_WIN_FAST 2
@@ -63,19 +63,19 @@ static void sink_data_handler(const uint8_t *data, uint32_t len)
while (len) {
LOCK_O;
bytes = min(_buf_space(outputbuf), _buf_cont_write(outputbuf));
bytes = min(_buf_space(outputbuf), _buf_cont_write(outputbuf)) / (BYTES_PER_FRAME / 4);
bytes = min(len, bytes);
#if BYTES_PER_FRAME == 4
memcpy(outputbuf->writep, data, bytes);
#else
{
s16_t *iptr = (s16_t*) data;
ISAMPLE_T *optr = (ISAMPLE_T*) outputbuf->writep;
size_t n = bytes / BYTES_PER_FRAME * 2;
ISAMPLE_T *optr = (ISAMPLE_T *) outputbuf->writep;
size_t n = bytes / 2;
while (n--) *optr++ = *iptr++ << 16;
}
#endif
_buf_inc_writep(outputbuf, bytes);
_buf_inc_writep(outputbuf, bytes * BYTES_PER_FRAME / 4);
space = _buf_space(outputbuf);
len -= bytes;
@@ -188,7 +188,6 @@ static bool raop_sink_cmd_handler(raop_event_t event, va_list args)
// this is async, so player might have been deleted
switch (event) {
case RAOP_TIMING: {
if (!raop_sync.enabled || output.state != OUTPUT_RUNNING || output.frames_played_dmp < output.device_frames) break;
u32_t ms, now = gettime_ms();

View File

@@ -853,8 +853,8 @@ static void visu_update(void) {
int mode = visu.mode & ~VISU_ESP32;
// not enough samples
if (visu_export.level < (mode == VISU_VUMETER ? RMS_LEN : FFT_LEN) * 2 && visu_export.running) {
// not enough frames
if (visu_export.level < (mode == VISU_VUMETER ? RMS_LEN : FFT_LEN) && visu_export.running) {
pthread_mutex_unlock(&visu_export.mutex);
return;
}
@@ -865,14 +865,14 @@ static void visu_update(void) {
if (visu_export.running) {
if (mode == VISU_VUMETER) {
s16_t *iptr = visu_export.buffer;
s16_t *iptr = (s16_t*) visu_export.buffer + (BYTES_PER_FRAME / 4) - 1;
// calculate sum(L²+R²), try to not overflow at the expense of some precision
for (int i = RMS_LEN; --i >= 0;) {
visu.bars[0].current += (*iptr * *iptr + (1 << (RMS_LEN_BIT - 2))) >> (RMS_LEN_BIT - 1);
iptr++;
iptr += BYTES_PER_FRAME / 4;
visu.bars[1].current += (*iptr * *iptr + (1 << (RMS_LEN_BIT - 2))) >> (RMS_LEN_BIT - 1);
iptr++;
iptr += BYTES_PER_FRAME / 4;
}
// convert to dB (1 bit remaining for getting X²/N, 60dB dynamic starting from 0dBFS = 3 bits back-off)
@@ -882,11 +882,13 @@ static void visu_update(void) {
else if (visu.bars[i].current < 0) visu.bars[i].current = 0;
}
} else {
s16_t *iptr = (s16_t*) visu_export.buffer + (BYTES_PER_FRAME / 4) - 1;
// on xtensa/esp32 the floating point FFT takes 1/2 cycles of the fixed point
for (int i = 0 ; i < FFT_LEN ; i++) {
// don't normalize here, but we are due INT16_MAX and FFT_LEN / 2 / 2
visu.samples[i * 2 + 0] = (float) (visu_export.buffer[2*i] + visu_export.buffer[2*i + 1]) * visu.hanning[i];
visu.samples[i * 2 + 0] = (float) (*iptr + *(iptr+BYTES_PER_FRAME/4)) * visu.hanning[i];
visu.samples[i * 2 + 1] = 0;
iptr += 2 * BYTES_PER_FRAME / 4;
}
// actual FFT that might be less cycle than all the crap below

View File

@@ -22,7 +22,7 @@ typedef int16_t s16_t;
typedef int32_t s32_t;
typedef int64_t s64_t;
typedef unsigned long long u64_t;
#ifndef PTHREAD_STACK_MIN
#define PTHREAD_STACK_MIN 256
#endif
@@ -42,7 +42,12 @@ typedef unsigned long long u64_t;
#define PLAYER_ID custom_player_id
extern u8_t custom_player_id;
#define BASE_CAP "Model=squeezeesp32,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Firmware=" VERSION
#if BYTES_PER_FRAME == 8
#define BASE_CAP "Model=squeezeesp32,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Balance=1,Depth=32,Firmware=" VERSION
#else
#define BASE_CAP "Model=squeezeesp32,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Balance=1,Depth=16,Firmware=" VERSION
#endif
// to force some special buffer attribute
#define EXT_BSS __attribute__((section(".ext_ram.bss")))
@@ -78,10 +83,10 @@ u8_t get_battery(void); // must provide 0..15 or define as 0x0
extern struct visu_export_s {
pthread_mutex_t mutex;
u32_t level, size, rate, gain;
s16_t *buffer;
void *buffer;
bool running;
} visu_export;
void output_visu_export(s16_t *frames, frames_t out_frames, u32_t rate, bool silence, u32_t gain);
void output_visu_export(void *frames, frames_t out_frames, u32_t rate, bool silence, u32_t gain);
void output_visu_init(log_level level);
void output_visu_close(void);

View File

@@ -30,7 +30,7 @@
#if BYTES_PER_FRAME == 4
#define ALIGN(n) (n)
#else
#define ALIGN(n) (n << 8)
#define ALIGN(n) (n << 16)
#endif
#define WRAPBUF_LEN 2048
@@ -332,7 +332,7 @@ static decode_state helixaac_decode(void) {
size_t bytes_total, bytes_wrap;
int res, bytes;
static AACFrameInfo info;
ISAMPLE_T *iptr;
s16_t *iptr;
u8_t *sptr;
bool endstream;
frames_t frames;
@@ -372,7 +372,7 @@ static decode_state helixaac_decode(void) {
u8_t *p = streambuf->readp + n;
int bytes = bytes_wrap - n;
if (!HAAC(a, Decode, a->hAac, &p, &bytes, (short*) a->write_buf)) {
if (!HAAC(a, Decode, a->hAac, &p, &bytes, (s16_t*) a->write_buf)) {
HAAC(a, GetLastFrameInfo, a->hAac, &info);
channels = info.nChans;
samplerate = info.sampRateOut;
@@ -443,13 +443,13 @@ static decode_state helixaac_decode(void) {
}
// decode function changes iptr, so can't use streambuf->readp (same for bytes)
res = HAAC(a, Decode, a->hAac, &sptr, &bytes, (short*) a->write_buf);
res = HAAC(a, Decode, a->hAac, &sptr, &bytes, (s16_t*) a->write_buf);
if (res < 0) {
LOG_WARN("AAC decode error %d", res);
}
HAAC(a, GetLastFrameInfo, a->hAac, &info);
iptr = (ISAMPLE_T *) a->write_buf;
iptr = (s16_t*) a->write_buf;
bytes = bytes_wrap - bytes;
endstream = false;
@@ -543,8 +543,8 @@ static decode_state helixaac_decode(void) {
iptr += count * 2;
#else
while (count--) {
*optr++ = *iptr++ << 8;
*optr++ = *iptr++ << 8;
*optr++ = ALIGN(*iptr++);
*optr++ = ALIGN(*iptr++);
}
#endif
} else if (info.nChans == 1) {
@@ -597,7 +597,7 @@ static void helixaac_open(u8_t size, u8_t rate, u8_t chan, u8_t endianness) {
// always free decoder as flush only works when no parameter has changed
HAAC(a, FreeDecoder, a->hAac);
} else {
a->write_buf = malloc(FRAME_BUF * BYTES_PER_FRAME);
a->write_buf = malloc(FRAME_BUF * 4);
a->wrap_buf = malloc(WRAPBUF_LEN);
}

View File

@@ -343,16 +343,9 @@ int main(int argc, char **argv) {
while (optind < argc && strlen(argv[optind]) >= 2 && argv[optind][0] == '-') {
char *opt = argv[optind] + 1;
if (strstr("oabcCdefmMnNpPrs"
if (strstr("oabcCdefmMnNpPrsZ"
#if ALSA
"UVO"
#endif
/*
* only allow '-Z <rate>' override of maxSampleRate
* reported by client if built with the capability to resample!
*/
#if RESAMPLE || RESAMPLE16
"Z"
#endif
, opt) && optind < argc - 1) {
optarg = argv[optind + 1];
@@ -519,6 +512,9 @@ int main(int argc, char **argv) {
case 'N':
namefile = optarg;
break;
case 'Z':
maxSampleRate = atoi(optarg);
break;
case 'W':
pcm_check_header = true;
break;
@@ -552,9 +548,6 @@ int main(int argc, char **argv) {
resample = "";
}
break;
case 'Z':
maxSampleRate = atoi(optarg);
break;
#endif
#if DSD
case 'D':

View File

@@ -188,7 +188,12 @@ static decode_state opus_decompress(void) {
// work backward to unpack samples (if needed)
iptr = (s16_t *) write_buf + count;
optr = (ISAMPLE_T *) write_buf + frames * 2;
IF_DIRECT(
optr = (ISAMPLE_T *) outputbuf->writep + frames * 2;
)
IF_PROCESS(
optr = (ISAMPLE_T *) write_buf + frames * 2;
)
if (channels == 2) {
#if BYTES_PER_FRAME == 4

View File

@@ -253,9 +253,9 @@ frames_t _output_frames(frames_t avail) {
}
out_frames = !silence ? min(size, cont_frames) : size;
if (output.channels & 0x01) gainR = COPY_MONO;
else if (output.channels & 0x02) gainL = COPY_MONO;
if (output.channels & 0x01) gainR |= MONO_FLAG;
if (output.channels & 0x02) gainL |= MONO_FLAG;
wrote = output.write_cb(out_frames, silence, gainL, gainR, cross_gain_in, cross_gain_out, &cross_ptr);

View File

@@ -112,7 +112,7 @@ static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t g
memcpy(btout + oframes * BYTES_PER_FRAME, buf, out_frames * BYTES_PER_FRAME);
}
output_visu_export((s16_t*) (btout + oframes * BYTES_PER_FRAME), out_frames, output.current_sample_rate, silence, (gainL + gainR) / 2);
output_visu_export(btout + oframes * BYTES_PER_FRAME, out_frames, output.current_sample_rate, silence, ((gainL & ~MONO_FLAG) + (gainR & ~MONO_FLAG)) / 2);
oframes += out_frames;

View File

@@ -400,42 +400,18 @@ bool output_volume_i2s(unsigned left, unsigned right) {
*/
static int _i2s_write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR,
s32_t cross_gain_in, s32_t cross_gain_out, ISAMPLE_T **cross_ptr) {
#if BYTES_PER_FRAME == 8
s32_t *optr;
#endif
if (!silence) {
if (output.fade == FADE_ACTIVE && output.fade_dir == FADE_CROSS && *cross_ptr) {
_apply_cross(outputbuf, out_frames, cross_gain_in, cross_gain_out, cross_ptr);
}
#if BYTES_PER_FRAME == 4
_apply_gain(outputbuf, out_frames, gainL, gainR);
memcpy(obuf + oframes * BYTES_PER_FRAME, outputbuf->readp, out_frames * BYTES_PER_FRAME);
#else
optr = (s32_t*) outputbuf->readp;
#endif
} else {
#if BYTES_PER_FRAME == 4
memcpy(obuf + oframes * BYTES_PER_FRAME, silencebuf, out_frames * BYTES_PER_FRAME);
#else
optr = (s32_t*) silencebuf;
#endif
}
#if BYTES_PER_FRAME == 8
IF_DSD(
if (output.outfmt == DOP) {
update_dop((u32_t *) optr, out_frames, output.invert);
} else if (output.outfmt != PCM && output.invert)
dsd_invert((u32_t *) optr, out_frames);
)
_scale_and_pack_frames(obuf + oframes * BYTES_PER_FRAME, optr, out_frames, gainL, gainR, output.format);
#endif
output_visu_export((s16_t*) (obuf + oframes * BYTES_PER_FRAME), out_frames, output.current_sample_rate, silence, (gainL + gainR) / 2);
output_visu_export(obuf + oframes * BYTES_PER_FRAME, out_frames, output.current_sample_rate, silence, ((gainL & ~MONO_FLAG) + (gainR & ~MONO_FLAG)) / 2);
oframes += out_frames;
return out_frames;
@@ -556,14 +532,16 @@ static void *output_thread_i2s(void *arg) {
//return;
}
#if BYTES_PER_FRAME == 4
// run equalizer
equalizer_process(obuf, oframes * BYTES_PER_FRAME, output.current_sample_rate);
#endif
// we assume that here we have been able to entirely fill the DMA buffers
if (spdif) {
spdif_convert((ISAMPLE_T*) obuf, oframes, (u32_t*) sbuf, &count);
i2s_write(CONFIG_I2S_NUM, sbuf, oframes * 16, &bytes, portMAX_DELAY);
bytes /= 4;
bytes /= 16 / BYTES_PER_FRAME;
#if BYTES_PER_FRAME == 4
} else if (i2s_config.bits_per_sample == 32) {
i2s_write_expand(CONFIG_I2S_NUM, obuf, oframes * BYTES_PER_FRAME, 16, 32, &bytes, portMAX_DELAY);
@@ -643,8 +621,9 @@ extern const u16_t spdif_bmclookup[256];
*/
void spdif_convert(ISAMPLE_T *src, size_t frames, u32_t *dst, size_t *count) {
u16_t hi, lo, aux;
register size_t cnt = *count;
// frames are 2 channels of 16 bits
// frames are 2 channels of 16/32 bits
frames *= 2;
while (frames--) {
@@ -653,28 +632,38 @@ void spdif_convert(ISAMPLE_T *src, size_t frames, u32_t *dst, size_t *count) {
lo = spdif_bmclookup[(u8_t) *src];
#else
hi = spdif_bmclookup[(u8_t)(*src >> 24)];
lo = spdif_bmclookup[(u8_t) *src >> 16];
lo = spdif_bmclookup[(u8_t)(*src >> 16)];
#endif
// invert if last preceeding bit is 1
lo ^= ~((s16_t)hi) >> 16;
// 16 bits sample:
// first 16 bits
*(dst+0) = ((u32_t)lo << 16) | hi;
// 4 bits auxillary-audio-databits, the first used as parity
#if BYTES_PER_FRAME == 4
aux = 0xb333 ^ (((u32_t)((s16_t)lo)) >> 17);
#else
// we use 20 bits samples as we need to force parity
aux = spdif_bmclookup[(u8_t)(*src >> 12)];
aux = (u8_t) (aux ^ (~((s16_t)lo) >> 16));
aux |= (0xb3 ^ (((u16_t)((s8_t)aux)) >> 9)) << 8;
#endif
// VUCP-Bits: Valid, Subcode, Channelstatus, Parity = 0
// As parity is always 0, we can use fixed preambles
if (++(*count) > 383) {
if (++cnt > 383) {
*(dst+1) = VUCP | (PREAMBLE_B << 16 ) | aux; //special preamble for one of 192 frames
*count = 0;
cnt = 0;
} else {
*(dst+1) = VUCP | ((((*count) & 0x01) ? PREAMBLE_W : PREAMBLE_M) << 16) | aux;
*(dst+1) = VUCP | (((cnt & 0x01) ? PREAMBLE_W : PREAMBLE_M) << 16) | aux;
}
src++;
dst += 2;
}
*count = cnt;
}
const u16_t spdif_bmclookup[256] = { //biphase mark encoded values (least significant bit first)

View File

@@ -23,14 +23,8 @@
#include "squeezelite.h"
#if BYTES_PER_FRAM == 4
#define MAX_VAL16 0x7fffffffLL
#define MAX_SCALESAMPLE 0x7fffffffffffLL
#define MIN_SCALESAMPLE -MAX_SCALESAMPLE
#else
#define MAX_SCALESAMPLE 0x7fffffffffffLL
#define MIN_SCALESAMPLE -MAX_SCALESAMPLE
#endif
// inlining these on windows prevents them being linkable...
#if !WIN
@@ -50,6 +44,34 @@ s32_t to_gain(float f) {
}
void _scale_and_pack_frames(void *outputptr, s32_t *inputptr, frames_t cnt, s32_t gainL, s32_t gainR, output_format format) {
// in-place copy input samples if mono/combined is used (never happens with DSD active)
if ((gainR & MONO_FLAG) && (gainL & MONO_FLAG)) {
s32_t *ptr = inputptr;
frames_t count = cnt;
gainL &= ~MONO_FLAG; gainR &= ~MONO_FLAG;
while (count--) {
// use 64 bits integer for purists but should really not care
*ptr = *(ptr + 1) = ((s64_t) *ptr + (s64_t) *(ptr + 1)) / 2;
ptr += 2;
}
} else if (gainL & MONO_FLAG) {
s32_t *ptr = inputptr + 1;
frames_t count = cnt;
gainL &= ~MONO_FLAG;
while (count--) {
*(ptr - 1) = *ptr;
ptr += 2;
}
} else if (gainR & MONO_FLAG) {
s32_t *ptr = inputptr;
frames_t count = cnt;
gainR &= ~MONO_FLAG;
while (count--) {
*(ptr + 1) = *ptr;
ptr += 2;
}
}
switch(format) {
#if DSD
case U32_LE:
@@ -364,13 +386,21 @@ 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 == COPY_MONO) {
} if ((gainR & MONO_FLAG) && (gainL & MONO_FLAG)) {
ISAMPLE_T *ptrL = (ISAMPLE_T *)(void *)outputbuf->readp;
ISAMPLE_T *ptrR = (ISAMPLE_T *)(void *)outputbuf->readp + 1;
gainL &= ~MONO_FLAG; gainR &= ~MONO_FLAG;
while (count--) {
*ptrL = *ptrR = (gain(gainL, *ptrL) + gain(gainR, *ptrR)) / 2;
ptrL += 2; ptrR += 2;
}
} else if (gainL & MONO_FLAG) {
ISAMPLE_T *ptr = (ISAMPLE_T *)(void *)outputbuf->readp + 1;
while (count--) {
*(ptr - 1) = *ptr = gain(gainR, *ptr);
ptr += 2;
}
} else if (gainR == COPY_MONO) {
} else if (gainR & MONO_FLAG) {
ISAMPLE_T *ptr = (ISAMPLE_T *)(void *)outputbuf->readp;
while (count--) {
*(ptr + 1) = *ptr = gain(gainL, *ptr);

View File

@@ -29,7 +29,7 @@ static struct visu_export_s *visu = &visu_export;
static log_level loglevel = lINFO;
void output_visu_export(s16_t *frames, frames_t out_frames, u32_t rate, bool silence, u32_t gain) {
void output_visu_export(void *frames, frames_t out_frames, u32_t rate, bool silence, u32_t gain) {
// no data to process
if (silence) {
@@ -44,10 +44,10 @@ void output_visu_export(s16_t *frames, frames_t out_frames, u32_t rate, bool sil
// stuff buffer up and wait for consumer to read it (should reset level)
if (visu->level < visu->size) {
u32_t space = min(visu->size - visu->level, out_frames * 2) * 2;
u32_t space = min(visu->size - visu->level, out_frames) * BYTES_PER_FRAME;
memcpy(visu->buffer + visu->level, frames, space);
visu->level += space / 2;
visu->level += space / BYTES_PER_FRAME;
visu->running = true;
visu->rate = rate ? rate : 44100;
visu->gain = gain;
@@ -71,7 +71,7 @@ void output_visu_init(log_level level) {
visu->size = VISUEXPORT_SIZE;
visu->running = false;
visu->rate = 44100;
visu->buffer = malloc(VISUEXPORT_SIZE * sizeof(s16_t) * 2);
LOG_INFO("Initialize VISUEXPORT %u 16 bits samples", VISUEXPORT_SIZE);
visu->buffer = malloc(VISUEXPORT_SIZE * BYTES_PER_FRAME);
LOG_INFO("Initialize VISUEXPORT %u %u bits samples", VISUEXPORT_SIZE, BYTES_PER_FRAME * 4);
}

View File

@@ -122,7 +122,7 @@ void send_packet(u8_t *packet, size_t len) {
static void sendHELO(bool reconnect, const char *fixed_cap, const char *var_cap, u8_t mac[6]) {
#ifndef BASE_CAP
#define BASE_CAP "Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Firmware=" VERSION
#define BASE_CAP "Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Balance=1,Firmware=" VERSION
#endif
#define SSL_CAP "CanHTTPS=1"
const char *base_cap;
@@ -914,7 +914,11 @@ void slimproto(log_level level, char *server, u8_t mac[6], const char *name, con
LOCK_O;
snprintf(fixed_cap, FIXED_CAP_LEN, ",ModelName=%s,MaxSampleRate=%u", modelname ? modelname : MODEL_NAME_STRING,
#if RESAMPLE || RESAMPLE16
((maxSampleRate > 0) ? maxSampleRate : output.supported_rates[0]));
#else
((maxSampleRate > 0 && maxSampleRate < output.supported_rates[0]) ? maxSampleRate : output.supported_rates[0]));
#endif
for (i = 0; i < MAX_CODECS; i++) {
if (codecs[i] && codecs[i]->id && strlen(fixed_cap) < FIXED_CAP_LEN - 10) {

View File

@@ -24,9 +24,9 @@
// make may define: PORTAUDIO, SELFPIPE, RESAMPLE, RESAMPLE_MP, VISEXPORT, GPIO, IR, DSD, LINKALL to influence build
#define MAJOR_VERSION "1.9"
#define MINOR_VERSION "2"
#define MICRO_VERSION "1145"
#define MAJOR_VERSION "0"
#define MINOR_VERSION "0"
#define MICRO_VERSION ""
#if defined(CUSTOM_VERSION)
#define VERSION "v" MAJOR_VERSION "." MINOR_VERSION "-" MICRO_VERSION STR(CUSTOM_VERSION)
@@ -472,7 +472,7 @@ void _wake_create(event_event*);
#define MAX_SILENCE_FRAMES 2048
#define FIXED_ONE 0x10000
#define COPY_MONO (FIXED_ONE + 1)
#define MONO_FLAG 0x20000
#ifndef BYTES_PER_FRAME
#define BYTES_PER_FRAME 8

View File

@@ -453,7 +453,7 @@ void stream_file(const char *header, size_t header_len, unsigned threshold) {
buf_flush(streambuf);
LOCK;
stream.header_len = header_len;
memcpy(stream.header, header, header_len);
*(stream.header+header_len) = '\0';
@@ -492,7 +492,7 @@ void stream_sock(u32_t ip, u16_t port, const char *header, size_t header_len, un
// wait till we are not polling anymore
while (polling && running) { usleep(10000); }
#endif
int sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {

View File

@@ -236,7 +236,12 @@ static decode_state vorbis_decode(void) {
// work backward to unpack samples (if needed)
iptr = (s16_t *) write_buf + count;
optr = (ISAMPLE_T *) write_buf + frames * 2;
IF_DIRECT(
optr = (ISAMPLE_T *) outputbuf->writep + frames * 2;
)
IF_PROCESS(
optr = (ISAMPLE_T *) write_buf + frames * 2;
)
if (channels == 2) {
#if BYTES_PER_FRAME == 4

View File

@@ -38,67 +38,69 @@
<hr>
[% END %]
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_EQUALIZER" desc="" %]
<div>[% "PLUGIN_SQUEEZEESP32_EQUALIZER_SAVE" | string %]</div>
[% END %]
[% IF pref_equalizer %]
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_EQUALIZER" desc="" %]
<div>[% "PLUGIN_SQUEEZEESP32_EQUALIZER_SAVE" | string %]</div>
[% END %]
<script TYPE="text/javascript">
if (Ext) {
Ext.onReady(function () {
new Ext.util.TaskRunner().start({
run: checkEq,
interval: 1000
});
});
function checkEq() {
var eqValues = [];
this.lastValues = this.lastValues || [];
for (var x = 0; x < 10; x++) {
eqValues[x] = Ext.get('pref_equalizer.' + x).dom.value || 0;
}
if (eqValues.join() != this.lastValues.join()) {
this.lastValues = eqValues;
SqueezeJS.Controller.request({
params: ['[% playerid %]', ['squeezeesp32', 'seteq', eqValues.join()]]
<script TYPE="text/javascript">
if (Ext) {
Ext.onReady(function () {
new Ext.util.TaskRunner().start({
run: checkEq,
interval: 1000
});
});
function checkEq() {
var eqValues = [];
this.lastValues = this.lastValues || [];
for (var x = 0; x < 10; x++) {
eqValues[x] = Ext.get('pref_equalizer.' + x).dom.value || 0;
}
if (eqValues.join() != this.lastValues.join()) {
this.lastValues = eqValues;
SqueezeJS.Controller.request({
params: ['[% playerid %]', ['squeezeesp32', 'seteq', eqValues.join()]]
});
}
}
}
}
</script>
[% WRAPPER settingSection %]
[% WRAPPER settingGroup title='31Hz' desc="" %]
</script>
[% WRAPPER settingSection %]
[% WRAPPER settingGroup title='31Hz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.0" id="pref_equalizer.0" value="[% pref_equalizer.0 %]" size="2"">
[% END %]
[% WRAPPER settingGroup title='62Hz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.1" id="pref_equalizer.1" value="[% pref_equalizer.1 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='125Hz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.2" id="pref_equalizer.2" value="[% pref_equalizer.2 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='250Hz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.3" id="pref_equalizer.3" value="[% pref_equalizer.3 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='500Hz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.4" id="pref_equalizer.4" value="[% pref_equalizer.4 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='1kHz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.5" id="pref_equalizer.5" value="[% pref_equalizer.5 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='2kHz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.6" id="pref_equalizer.6" value="[% pref_equalizer.6 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='4kHz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.7" id="pref_equalizer.7" value="[% pref_equalizer.7 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='8kHz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.8" id="pref_equalizer.8" value="[% pref_equalizer.8 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='16kHz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.9" id="pref_equalizer.9" value="[% pref_equalizer.9 %]" size="2">
[% END %]
[% END %]
[% WRAPPER settingGroup title='62Hz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.1" id="pref_equalizer.1" value="[% pref_equalizer.1 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='125Hz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.2" id="pref_equalizer.2" value="[% pref_equalizer.2 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='250Hz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.3" id="pref_equalizer.3" value="[% pref_equalizer.3 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='500Hz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.4" id="pref_equalizer.4" value="[% pref_equalizer.4 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='1kHz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.5" id="pref_equalizer.5" value="[% pref_equalizer.5 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='2kHz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.6" id="pref_equalizer.6" value="[% pref_equalizer.6 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='4kHz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.7" id="pref_equalizer.7" value="[% pref_equalizer.7 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='8kHz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.8" id="pref_equalizer.8" value="[% pref_equalizer.8 %]" size="2">
[% END %]
[% WRAPPER settingGroup title='16kHz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.9" id="pref_equalizer.9" value="[% pref_equalizer.9 %]" size="2">
[% END %]
[% END %]
[% END %]
[% PROCESS settings/footer.html %]

View File

@@ -14,7 +14,7 @@ my $prefs = preferences('plugin.squeezeesp32');
my $log = logger('plugin.squeezeesp32');
{
__PACKAGE__->mk_accessor('rw', 'tone_update');
__PACKAGE__->mk_accessor('rw', qw(tone_update depth));
}
sub new {
@@ -64,6 +64,10 @@ sub minBass { -13 }
sub init {
my $client = shift;
my ($id, $caps) = @_;
my ($depth) = $caps =~ /Depth=(\d+)/;
$client->depth($depth || 16);
if (!$handlersAdded) {
@@ -107,6 +111,22 @@ sub initPrefs {
$client->SUPER::initPrefs;
}
sub power {
my $client = shift;
my $on = shift;
my $res = $client->SUPER::power($on, @_);
return $res unless defined $on;
if ($on) {
$client->update_artwork(1);
} else {
$client->clear_artwork(1);
}
return $res;
}
# Allow the player to define it's display width (and probably more)
sub playerSettingsFrame {
my $client = shift;
@@ -232,16 +252,16 @@ sub send_artwork {
}
sub clear_artwork {
my ($client, $request) = @_;
my ($client, $force, $from) = @_;
my $artwork = $prefs->client($client)->get('artwork');
if ($artwork && $artwork->{'enable'}) {
main::INFOLOG && $log->is_info && $log->info("artwork stop/clear " . $request->getRequestString());
main::INFOLOG && $log->is_info && $log->info("artwork stop/clear " . ($from || ""));
$client->pluginData('artwork_md5', '');
# refresh screen and disable artwork when artwork was full screen (hack)
if (!$artwork->{'x'} && !$artwork->{'y'}) {
$client->sendFrame(grfa => \("\x00"x4)) unless $artwork->{'x'} || $artwork->{'y'};
if ((!$artwork->{'x'} && !$artwork->{'y'}) || $force) {
$client->sendFrame(grfa => \("\x00"x4));
$client->display->update;
}
}

View File

@@ -76,12 +76,14 @@ sub handler {
}
my $equalizer = $cprefs->get('equalizer');
for my $i (0 .. $#{$equalizer}) {
$equalizer->[$i] = $paramRef->{"pref_equalizer.$i"} || 0;
}
$cprefs->set('equalizer', $equalizer);
$client->update_tones($equalizer);
if ($client->depth == 16) {
my $equalizer = $cprefs->get('equalizer');
for my $i (0 .. $#{$equalizer}) {
$equalizer->[$i] = $paramRef->{"pref_equalizer.$i"} || 0;
}
$cprefs->set('equalizer', $equalizer);
$client->update_tones($equalizer);
}
}
if ($client->displayWidth) {
@@ -91,7 +93,7 @@ sub handler {
$paramRef->{'pref_artwork'} = $cprefs->get('artwork');
}
$paramRef->{'pref_equalizer'} = $cprefs->get('equalizer');
$paramRef->{'pref_equalizer'} = $cprefs->get('equalizer') if $client->depth == 16;
return $class->SUPER::handler($client, $paramRef);
}

View File

@@ -65,7 +65,7 @@ sub onStopClear {
my $client = $request->client || return;
if ($client->isa('Plugins::SqueezeESP32::Player')) {
$client->clear_artwork($request);
$client->clear_artwork(0, $request->getRequestString());
}
}

1
server_certs/getcert.sh Normal file → Executable file
View File

@@ -43,4 +43,5 @@ rm *.txt
# seed the start pem
get_all_pem github.com github-com
get_all_pem s3.amazonaws.com s3-amazon-com
get_all_pem github-releases.githubusercontent.com githubusercontent-com
cat *.pem >github.pem