bring up to date to 0.52 and begin testing on generic esp32 board. The source

contains options for adapting to LyraT boards, in which case the thing should
be compiled using ESP's audio development system (esp-adf) instead of the
default esp-idf.  (also, the "sdkconfig" file will have to be rebuilt).

As they stand the sources load a pre-compiled patch which is munged as a C string
in the file "testpatch.c".  Optionally Pd can be reconfigured to load patches over
wifi.
This commit is contained in:
Miller Puckette 2024-09-16 17:50:47 +02:00
parent 5236d62f98
commit a82b66eb39
18 changed files with 1619 additions and 711 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
build

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "pd"]
path = pd
url = https://github.com/pure-data/pure-data

View file

@ -2,6 +2,5 @@
# in this exact order for cmake to work correctly # in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
include($ENV{ADF_PATH}/CMakeLists.txt)
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(espd) project(espd)

View file

@ -1,79 +0,0 @@
Commands I issue to shell to compile (customize to your own installation):
export IDF_TOOLS_PATH=/home/msp/bis/work/esp/toolchain
export ADF_PATH=/home/msp/bis/work/esp/esp-adf
export IDF_PATH=/home/msp/bis/work/esp/esp-idf-v4.4.2
. $ADF_PATH/esp-idf/export.sh
idf.py menuconfig
idf.py build
idf.py -p /dev/ttyUSB0 flash monitor
idf.py -p /dev/ttyUSB0 monitor
**** START READING HERE ****
This is a very sketchy description of the "espd" version of Pd, which runs
on Espressif LyraT or LyraT-mini boards. To use these you will almost certainly
have to compile your own version, at least to specify the WIFI settings which
are set in the file main/espd.h .
The instructions here _should_ work on macintoshes and PCs with appropriate
changes (in the shell commands for instance). In addition to a linux machine
you'll need an Espressif LyraT or LyraT mini board.
To run espd, you must compile and load it on the board, biit the board, and then
run a patch on the host computer that waits for the board to make a TCP
connection to it. Once connected, the host patch then sends Pd messages to
load a different patch on the esp. The two patches then can communicate over
the same RCP connection.
If the connection is ever broken the board reboots itself and tries to establish
a new connection. Each time the host patch gets a new connection it then has to
reload the ESP patch.
As it stands all the vanilla Pd objects are compiled into espd except for the
FFT objects and (oddly) netsend/netreceive. You can rebuild it with a different
xhoice of objects compiled in, including your own objects.
Steps to get this running: first install the espd compile chain and the
"ADF" audio development platform. The ESP documentation is excellent. Start
here:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/linux-macos-setup.html
another (third-party) URL that might be useful:
https://gitdemo.readthedocs.io/en/latest/build-system.html
The compilation chain depends on an "sdkconfig" file - samples for the two
boards are included as "sdkconfig.lyrat" and "sdkconfig.lyratmini" - you can
rename one of these as "sdkconfig" before invoking the compiler.
In addition to the sources youre looking at you'll need Pd, preferably the
latest version, although I'm testing this with Pd commit
05bf346fa32510fd191fe77de24b3ea1c481f5ff . You can "git" clone pd into a
subdirectory "pd" of this directory.
Then you must apply four small patches to the Pd source, found in the
subdirectory "patches".
To compile, set up your envoronment variables and issue commands to compile,
flash, and run the monitor program to see debugging output (see top of this page
to see what I typw on my system). This should be done from a shell window that
is in this (espd) directory.
Then set up a host patch (examples in the subdirectory host). This patch
listens on port 4498 (by default). When a connection os made, it loads a test
patch on the esp, by sending the message "pd begin-new poodle .", then the contents
of the patch, then "pd end-new"
DOLIST
toggles to indicate connectedness
why is first message after restarting card dropped?
move patch-loader out of tcpconnect
sleeping between attempts to connect to host
sleep message to pd object
later:
fold in the network Pd objects?
adapt to non-lyraT boards

81
README.txt Normal file
View file

@ -0,0 +1,81 @@
This is a very sketchy description of the "espd" version of Pd, which runs on
Espressif ESP32 bords, eoither generic ones (where you have to add your own
audio hardware) or LyraT or LyraT-mini boards (with built-in audio). To use
these you will almost certainly have to compile your own version, at least
eitehr to include your own patch or to specify the WIFI settings in the file
main/espd.h .
The instructions here work for me on linux; they _should_ work on macintoshes
and PCs with appropriate changes (in the shell commands for instance).
To send a patch over wifi, you must compile and load espd on the board, boot the
board, and then run a patch on the host computer that waits for the board to
make a TCP connection to it. Once connected, the host patch then sends Pd
messages to load a different patch on the esp. The two patches then can
communicate over the same RCP connection.
If the patch is built-in you can skip the previous step. You can still compile
in wifi if you want and send Pd messages to the board over it.
If the connection is ever broken the board reboots itself and (if WIFI is
compiled in) tries to establish a new WIFI connection. Each time the host patch
gets a new connection it then has to reload the ESP patch.
As it stands all the vanilla Pd objects are compiled into espd except for the
FFT objects and (oddly) netsend/netreceive. You can rebuild it with a different
choice of objects compiled in, including your own objects.
Steps to get this running: first install the espd compile chain and (for LyraT)
the "ADF" audio development platform. The ESP documentation is excellent.
Start here:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/linux-macos-setup.html
another (third-party) URL that might be useful:
https://gitdemo.readthedocs.io/en/latest/build-system.html
The compilation chain depends on an "sdkconfig" file. The included one is for a
generic ESP board. Samples for the two LyraT boards are included as
"sdkconfig.lyrat" and "sdkconfig.lyratmini" - you can rename one of these as
"sdkconfig" before invoking the compiler.
In addition to the sources youre looking at you'll need Pd, preferably the
latest version, although I'm testing this with Pd commit
177350fc4999b74ea28a12ba2981baa6ae04c6f0 (0.55-1 with a couple of tweaks added).
You can "git clone" pd into a subdirectory "pd" of this directory.
Then you must apply three small patches to the Pd source, found in the
subdirectory "patches".
To compile, set up your environment variables and issue commands to compile,
flash, and run the monitor program to see debugging output (see bottom of this
page to see what I type on my system). This should be done from a shell window
that is in this (espd) directory.
Then, if you are using wifi, set up a host patch that listens on port 4498 (by
default). When the board is booted it will connect to that port. When you get
the connection, you can load a test patch on the esp, by sending the message "pd
begin-new poodle .", then the contents of the patch, then "pd end-new" . Whether
you do this or rely on a pre-compiled patch, you can send messages to any named object (such as a "receive") on the ESP32 board.
Commands I issue to shell to compile (customize to your own installation):
For generic ESP:
export IDF_TOOLS_PATH=~/bis/var/esp/tools
export IDF_PATH=~/bis/var/esp/esp-idf
. $IDF_PATH/export.sh
for LyraT boards:
export IDF_TOOLS_PATH=~/bis/var/esp/tools
export ADF_PATH=~/bis/var/esp/esp-adf
. $ADF_PATH/esp-idf/export.sh
then (for either type of board):
idf.py menuconfig
idf.py build
idf.py -p /dev/ttyUSB0 flash
idf.py -p /dev/ttyUSB0 monitor

View file

@ -49,6 +49,7 @@ set(COMPONENT_SRCS "espd.c pdmain.c \
../pd/src/x_vexp.c \ ../pd/src/x_vexp.c \
../pd/src/x_vexp_fun.c \ ../pd/src/x_vexp_fun.c \
../pd/src/x_vexp_if.c \ ../pd/src/x_vexp_if.c \
../pd/src/s_inter_gui.c \
../wifi/wifi.c \ ../wifi/wifi.c \
../wifi/net.c \ ../wifi/net.c \
") ")
@ -56,7 +57,8 @@ set(COMPONENT_SRCS "espd.c pdmain.c \
set(COMPONENT_ADD_INCLUDEDIRS ".") set(COMPONENT_ADD_INCLUDEDIRS ".")
set(COMPONENT_ADD_CFLAGS "-DPD -DHAVE_UNISTD_H -DHAVE_ALLOCA_H -DPD_HEADLESS\ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPD -DHAVE_UNISTD_H -DHAVE_ALLOCA_H -DPD_HEADLESS -DPD_INTERNAL -DSYMTABHASHSIZE=512 -DSTUPID_SORT -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -Wno-format -Wno-stringop-truncation -Wno-unused-const-variable")
-DSYMTABHASHSIZE=512 -DSTUPID_SORT -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -Wno-format -Wno-stringop-truncation Wno-unused-const-variable")
# set(COMPONENT_ADD_CFLAGS "-DPD -DHAVE_UNISTD_H -DHAVE_ALLOCA_H -DPD_HEADLESS -DPD_INTERNAL -DSYMTABHASHSIZE=512 -DSTUPID_SORT -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -Wno-format -Wno-stringop-truncation -Wno-unused-const-variable")
register_component() register_component()

View file

@ -9,25 +9,19 @@
#include "espd.h" #include "espd.h"
#include <string.h> #include <string.h>
#include <math.h>g
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "driver/i2s.h"
#include "esp_log.h" #include "esp_log.h"
#include "audio_element.h"
#include "audio_pipeline.h"
#include "audio_event_iface.h"
#include "audio_mem.h"
#include "audio_common.h"
#include "i2s_stream.h"
#include "mp3_decoder.h"
#include "filter_resample.h"
#include "board.h"
#include "esp_peripherals.h"
#include "periph_sdcard.h"
#include "nvs.h" #include "nvs.h"
#include "nvs_flash.h" #include "nvs_flash.h"
#include "esp_timer.h" #include "esp_timer.h"
#ifdef PD_USE_CONSOLE
#include "driver/uart.h"
#include "esp_console.h"
#endif
static const char *TAG = "ESPD"; static const char *TAG = "ESPD";
#define TEST_I2S_NUM I2S_NUM_0 #define TEST_I2S_NUM I2S_NUM_0
@ -37,68 +31,113 @@ void pdmain_init( void);
void sd_init( void); void sd_init( void);
#define INCHANS 1 #define USEADC
#define OUTCHANS 1
#define BLKSIZE 64 #define BLKSIZE 64
float soundin[OUTCHANS * BLKSIZE], soundout[OUTCHANS * BLKSIZE]; float soundin[OUTCHANS * BLKSIZE], soundout[OUTCHANS * BLKSIZE];
void senddacs( void) void senddacs( void)
{ {
int i, ret; int i, ret;
size_t written; static int count;
short poodle[OUTCHANS * BLKSIZE]; size_t transferred;
uint32_t poodle[BLKSIZE];
for (i = 0; i < BLKSIZE; i+= OUTCHANS) for (i = 0; i < BLKSIZE; i++)
{ {
int ch1 = 32767*soundout[i]; int ch1 = floor(0.5 + 32768.*soundout[i]),
if (ch1 > 32767) ch2 = floor(0.5 + 32768.*soundout[i+BLKSIZE]);
ch1 = 32767; static int lastch1, lastch2;
else if (ch1 < -32768)
ch1 = -32768;
poodle[i] = ch1;
/*
ch1 = 32767*soundout[BLKSIZE+i];
if (ch1 > 32767) if (ch1 > 32767)
ch1 = 32767; ch1 = 32767;
else if (ch1 < -32768) else if (ch1 < -32768)
ch1 = -32768; ch1 = -32768;
poodle[i+1] = ch2; */ ch1 &= 0xffff;
if (ch2 > 32767)
soundout[i] = 0; ch2 = 32767;
else if (ch2 < -32768)
ch2 = -32768;
ch2 &= 0xffff;
#if 0
poodle[i] = ((lastch1 << 17) & 0xfffe0000) | ((lastch2 << 1) & 0x10000) |
((lastch2 << 1) & 0xfffe) | ((ch1 >> 15) & 1);
#endif
poodle[i] = (ch1<<16) | ch2;
lastch1 = ch1;
lastch2 = ch2;
soundout[i] = soundout[i+64] = 0;
}
if (count++ > 2000)
{
ESP_LOGI(TAG, "sample %lx", poodle[0]);
count = 0;
} }
ret = i2s_write(TEST_I2S_NUM, poodle, sizeof(poodle), &written, ret = i2s_write(TEST_I2S_NUM, poodle, sizeof(poodle), &transferred,
portMAX_DELAY); portMAX_DELAY);
if (ret != ESP_OK) if (ret != ESP_OK)
ESP_LOGE(TAG, "error writing"); ESP_LOGE(TAG, "error writing");
#ifdef USEADC
ret = i2s_read(TEST_I2S_NUM, poodle, sizeof(poodle), &transferred,
portMAX_DELAY);
if (ret != ESP_OK)
ESP_LOGE(TAG, "error reading");
for (i = 0; i < BLKSIZE; i++)
{
uint32_t ch1 = poodle[i] & 0xffff, ch2 = (poodle[i]>>16) & 0xffff ;
if (ch1 & 0x8000)
soundin[i] = (ch1*(1./32768.)) - 2;
else soundin[i] = (ch1*(1./32768.));
if (ch2 & 0x8000)
soundin[i+BLKSIZE] = (ch2*(1./32768.)) - 2;
else soundin[i+BLKSIZE] = (ch2*(1./32768.));
}
#endif /* USEADC */
} }
/* allow deprecated form if new one unavailable */
#ifndef I2S_COMM_FORMAT_STAND_I2S
#define I2S_COMM_FORMAT_STAND_I2S I2S_COMM_FORMAT_I2S
#endif
static void initdacs( void) static void initdacs( void)
{ {
i2s_config_t i2s_cfg = { i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_RX, .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX
.sample_rate = 48000, #ifdef USEADC
.bits_per_sample = 16, | I2S_MODE_RX
/* .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, */ #endif
.channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT, ),
.communication_format = I2S_COMM_FORMAT_STAND_I2S, .sample_rate = 48000,
.dma_buf_count = 16, .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.dma_buf_len = 256, .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.use_apll = 1, .communication_format =
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL2, (i2s_comm_format_t)(I2S_COMM_FORMAT_STAND_I2S),
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, /* high interrupt priority */
.dma_buf_count = 16,
.dma_buf_len = 256,
.use_apll=0,
.tx_desc_auto_clear= true,
.fixed_mclk=-1 };
i2s_pin_config_t i2s_pin_cfg = {
#if 1 /* generic board on big breadboard */
.bck_io_num = 13, /* bit clock */
.ws_io_num = 33, /* Word select, aka left right clock */
.data_out_num = 32, /* Data out from ESP32, to DIN on 38357A */
.data_in_num = 35 /* data from ADC */
#endif
#if 0
.bck_io_num = 33, /* bit clock */
.ws_io_num = 25, /* Word select, aka left right clock */
.data_out_num = 32, /* Data out from ESP32, to DIN on 38357A */
.data_in_num = I2S_PIN_NO_CHANGE /* no ADC */
#endif
}; };
i2s_pin_config_t i2s_pin_cfg = {0};
ESP_LOGI(TAG, "[ 1 ] Start audio codec chip"); ESP_LOGI(TAG, "[ 1 ] Start audio codec chip");
audio_board_handle_t board_handle = audio_board_init(); i2s_driver_install(TEST_I2S_NUM, &i2s_config, 0, NULL);
audio_hal_ctrl_codec(board_handle->audio_hal, AUDIO_HAL_CODEC_MODE_BOTH, AUDIO_HAL_CTRL_START); i2s_set_pin(TEST_I2S_NUM, &i2s_pin_cfg);
i2s_driver_install(I2S_NUM_0, &i2s_cfg, 0, NULL);
get_i2s_pins(I2S_NUM_0, &i2s_pin_cfg);
i2s_set_pin(I2S_NUM_0, &i2s_pin_cfg);
i2s_mclk_gpio_select(I2S_NUM_0, GPIO_NUM_0);
} }
static int audiostate; static int audiostate;
@ -139,10 +178,39 @@ void pd_fromhost(char *data, size_t size)
xSemaphoreGive(pd_bt_mutex); xSemaphoreGive(pd_bt_mutex);
} }
#ifdef PD_USE_CONSOLE
static QueueHandle_t uart_queue;
static void console_init( void)
{
const int uart_buffer_size = 256;
ESP_ERROR_CHECK(uart_driver_install(CONFIG_ESP_CONSOLE_UART_NUM,
uart_buffer_size, uart_buffer_size, 10, &uart_queue, 0));
}
#endif
/* dispatch messages enqueued above */ /* dispatch messages enqueued above */
void pd_pollhost( void) void pd_pollhost( void)
{ {
int lastchar; int lastchar;
#ifdef PD_USE_CONSOLE
uint8_t data[128];
int length = 0;
ESP_ERROR_CHECK(uart_get_buffered_data_len(CONFIG_ESP_CONSOLE_UART_NUM,
(size_t*)&length));
if (length > 0)
{
int i;
/* ESP_LOGI(TAG, "serial in %d", length); */
length = uart_read_bytes(CONFIG_ESP_CONSOLE_UART_NUM, data, length, 100);
for (i = 0; i < length; i++)
{
char foo[80];
ESP_LOGI(TAG, " %d", data[i] & 0xff);
sprintf(foo, "key %d;", data[i] & 0xff);
pd_sendmsg(foo, strlen(foo));
}
}
#endif
if (!pd_bt_mutex) if (!pd_bt_mutex)
pd_bt_mutex = xSemaphoreCreateMutex(); pd_bt_mutex = xSemaphoreCreateMutex();
if (xSemaphoreTake(pd_bt_mutex, 0) != pdTRUE) if (xSemaphoreTake(pd_bt_mutex, 0) != pdTRUE)
@ -174,7 +242,7 @@ void pdmain_print( const char *s)
if (strlen(y) > 0) if (strlen(y) > 0)
pd_bt_writeback((unsigned char *)y, strlen(y)); pd_bt_writeback((unsigned char *)y, strlen(y));
#endif #endif
#if 1 #ifdef PD_USE_WIFI
net_sendudp(y, strlen(y), CONFIG_ESP_WIFI_SENDPORT); net_sendudp(y, strlen(y), CONFIG_ESP_WIFI_SENDPORT);
net_sendtcp(y, strlen(y)); net_sendtcp(y, strlen(y));
#endif #endif
@ -182,11 +250,6 @@ void pdmain_print( const char *s)
void trymem(int foo); void trymem(int foo);
/* allow deprecated form if new one unavailable */
#ifndef I2S_COMM_FORMAT_STAND_I2S
#define I2S_COMM_FORMAT_STAND_I2S I2S_COMM_FORMAT_I2S
#endif
void app_main(void) void app_main(void)
{ {
esp_log_level_set("*", ESP_LOG_WARN); esp_log_level_set("*", ESP_LOG_WARN);
@ -198,13 +261,18 @@ void app_main(void)
#ifdef PD_USE_BLUETOOTH #ifdef PD_USE_BLUETOOTH
bt_init(); bt_init();
#endif #endif
#ifdef PD_USE_SDCARD
sd_init(); sd_init();
#endif
#ifdef PD_USE_WIFI #ifdef PD_USE_WIFI
ESP_LOGI(TAG, "[ 1a ] start network"); ESP_LOGI(TAG, "[ 1a ] start network");
wifi_init(); wifi_init();
net_init(); net_init();
net_hello(); net_hello();
#endif #endif
#ifdef PD_USE_CONSOLE
console_init();
#endif
ESP_LOGI(TAG, "[ 2 ] now write some shit"); ESP_LOGI(TAG, "[ 2 ] now write some shit");
@ -221,11 +289,13 @@ void app_main(void)
pd_pollhost(); pd_pollhost();
pdmain_tick(); pdmain_tick();
senddacs(); senddacs();
#ifdef PD_USE_WIFI
net_alive(); net_alive();
#endif
} }
} }
#ifdef PD_USE_SDCARD
void sd_init( void) void sd_init( void)
{ {
/* initialize SD card */ /* initialize SD card */
@ -238,6 +308,7 @@ void sd_init( void)
audio_board_sdcard_init(set, SD_MODE_1_LINE); audio_board_sdcard_init(set, SD_MODE_1_LINE);
ESP_LOGI(TAG, "[ 1b ] done starting network"); ESP_LOGI(TAG, "[ 1b ] done starting network");
} }
#endif
static void espd_printtimediff( void) static void espd_printtimediff( void)
{ {

View file

@ -1,5 +1,6 @@
/* #define PD_USE_BLUETOOTH */ /* #define PD_USE_BLUETOOTH */
#define PD_USE_WIFI /* #define PD_USE_WIFI */
#define PD_USE_CONSOLE
/* task priorities */ /* task priorities */
@ -21,6 +22,9 @@ void bt_init( void);
void pd_bt_writeback(unsigned char *s, int length); void pd_bt_writeback(unsigned char *s, int length);
#endif #endif
#define INCHANS 2
#define OUTCHANS 2
#ifdef PD_USE_WIFI #ifdef PD_USE_WIFI
void wifi_init(void); /* wifi.c - manage 802.11 connection */ void wifi_init(void); /* wifi.c - manage 802.11 connection */
void net_init( void); /* init */ void net_init( void); /* init */

5
main/locale.h Normal file
View file

@ -0,0 +1,5 @@
#define CONFIG_ESP_WIFI_SSID "rock_lobster"
#define CONFIG_ESP_WIFI_PASSWORD "g3tUr0wnw1f1"
#define CONFIG_ESP_WIFI_SENDADDR "10.0.0.215"
#define CONFIG_ESP_WIFI_SENDPORT 4498
#define CONFIG_ESP_WIFI_LISTENPORT 4499

View file

@ -3,6 +3,7 @@
#include "../pd/src/m_imp.h" #include "../pd/src/m_imp.h"
#include "../pd/src/g_canvas.h" #include "../pd/src/g_canvas.h"
#include "../pd/src/g_undo.h" #include "../pd/src/g_undo.h"
#include "espd.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
@ -18,6 +19,10 @@ void glob_open(t_pd *ignore, t_symbol *name, t_symbol *dir, t_floatarg f);
void pdmain_print( const char *s); void pdmain_print( const char *s);
void espd_printtimediff( void); void espd_printtimediff( void);
/*
sed command to prepare patch:
sed 's/;$/;\\/' foo.pd | sed 's/#N //'
*/
#if 0 #if 0
static const char patchfile[] = "\ static const char patchfile[] = "\
@ -28,7 +33,8 @@ canvas 274 279 752 643 12;\n\
#X connect 0 0 1 0;\n\ #X connect 0 0 1 0;\n\
#X connect 1 0 2 0;\n\ #X connect 1 0 2 0;\n\
"; ";
#endif
#if 0
static const char patchfile[] = "\ static const char patchfile[] = "\
canvas 0 50 450 300 12;\n\ canvas 0 50 450 300 12;\n\
#X obj 190 104 loadbang;\n\ #X obj 190 104 loadbang;\n\
@ -39,6 +45,9 @@ canvas 0 50 450 300 12;\n\
#X connect 3 0 2 0;\n\ #X connect 3 0 2 0;\n\
"; ";
#endif #endif
#if 1
#include "testpatch.c"
#endif
void trymem(int foo) void trymem(int foo)
{ {
@ -76,7 +85,7 @@ void pdmain_init( void)
STUFF->st_soundout = soundout; STUFF->st_soundout = soundout;
STUFF->st_soundin = soundin; STUFF->st_soundin = soundin;
#if 0 #if 1
{ {
t_binbuf *b = binbuf_new(); t_binbuf *b = binbuf_new();
glob_setfilename(0, gensym("main-patch"), gensym(".")); glob_setfilename(0, gensym("main-patch"), gensym("."));
@ -242,8 +251,8 @@ void conf_init(void)
*/ */
/* ------- STUBS that do nothing ------------- */ /* ------- STUBS that do nothing ------------- */
int sys_get_outchannels(void) {return(2); } int sys_get_outchannels(void) {return(OUTCHANS); }
int sys_get_inchannels(void) {return(2); } int sys_get_inchannels(void) {return(INCHANS); }
float sys_getsr( void) {return (48000);} float sys_getsr( void) {return (48000);}
int sys_getblksize(void) { return (DEFDACBLKSIZE); } int sys_getblksize(void) { return (DEFDACBLKSIZE); }
@ -252,12 +261,17 @@ int sys_verbose = 0;
int sys_noloadbang = 0; int sys_noloadbang = 0;
int audio_shouldkeepopen(void) { return (0);} int audio_shouldkeepopen(void) { return (0);}
int audio_isopen( void) { return (1); }
void sys_reopen_audio ( void) { }
void sys_close_audio ( void) { }
t_symbol *sys_libdir = &s_; t_symbol *sys_libdir = &s_;
void sys_vgui(const char *format, ...) {} void sys_vgui(const char *format, ...) {}
void sys_gui(const char *s) { } void sys_gui(const char *s) { }
int sys_havegui(void) {return (0);} int sys_havegui(void) {return (0);}
int sys_havetkproc(void) {return (0);}
int sys_pollgui( void) { return (0); } int sys_pollgui( void) { return (0); }
void sys_lock(void) {} void sys_lock(void) {}
@ -323,14 +337,13 @@ void x_midi_newpdinstance( void) {}
t_symbol *iemgui_raute2dollar(t_symbol *s) {return(s);} t_symbol *iemgui_raute2dollar(t_symbol *s) {return(s);}
t_symbol *iemgui_dollar2raute(t_symbol *s) {return(s);} t_symbol *iemgui_dollar2raute(t_symbol *s) {return(s);}
t_class *clone_class;
/* --------------- m_sched.c -------------------- */ /* --------------- m_sched.c -------------------- */
#define TIMEUNITPERMSEC (32. * 441.) #define TIMEUNITPERMSEC (32. * 441.)
#define TIMEUNITPERSECOND (TIMEUNITPERMSEC * 1000.) #define TIMEUNITPERSECOND (TIMEUNITPERMSEC * 1000.)
void dsp_tick(void); void dsp_tick(void);
static int sched_diddsp; static int sched_diddsp;
int sys_quit = 0; int sys_quit = 0;
void sched_init(void) {}
typedef void (*t_clockmethod)(void *client); typedef void (*t_clockmethod)(void *client);
@ -573,14 +586,24 @@ void canvas_connect(t_canvas *x, t_floatarg fwhoout, t_floatarg foutno,
if (EDITOR->paste_canvas == x) whoout += EDITOR->paste_onset, if (EDITOR->paste_canvas == x) whoout += EDITOR->paste_onset,
whoin += EDITOR->paste_onset; whoin += EDITOR->paste_onset;
for (src = x->gl_list; whoout; src = src->g_next, whoout--) for (src = x->gl_list; whoout; src = src->g_next, whoout--)
if (!src->g_next) goto bad; /* bug fix thanks to Hannes */ if (!src->g_next) {
src = NULL;
logpost(sink, PD_DEBUG, "cannot connect non-existing object");
goto bad; /* bug fix thanks to Hannes */
}
for (sink = x->gl_list; whoin; sink = sink->g_next, whoin--) for (sink = x->gl_list; whoin; sink = sink->g_next, whoin--)
if (!sink->g_next) goto bad; if (!sink->g_next) {
sink = NULL;
logpost(src, PD_DEBUG, "cannot connect to non-existing object");
goto bad;
}
/* check they're both patchable objects */ /* check they're both patchable objects */
if (!(objsrc = pd_checkobject(&src->g_pd)) || if (!(objsrc = pd_checkobject(&src->g_pd)) ||
!(objsink = pd_checkobject(&sink->g_pd))) !(objsink = pd_checkobject(&sink->g_pd))) {
goto bad; logpost(src?src:sink, PD_DEBUG, "cannot connect unpatchable object");
goto bad;
}
/* if object creation failed, make dummy inlets or outlets /* if object creation failed, make dummy inlets or outlets
as needed */ as needed */
@ -594,10 +617,14 @@ void canvas_connect(t_canvas *x, t_floatarg fwhoout, t_floatarg foutno,
if (!(oc = obj_connect(objsrc, outno, objsink, inno))) goto bad; if (!(oc = obj_connect(objsrc, outno, objsink, inno))) goto bad;
if (glist_isvisible(x) && x->gl_havewindow) if (glist_isvisible(x) && x->gl_havewindow)
{ {
sys_vgui( char tag[128];
".x%lx.c create line %d %d %d %d -width %d -tags [list l%lx cord]\n", char*tags[] = {tag, "cord"};
glist_getcanvas(x), 0, 0, 0, 0, sprintf(tag, "l%p", oc);
(obj_issignaloutlet(objsrc, outno) ? 2 : 1) * x->gl_zoom, oc); pdgui_vmess(0, "crr iiii ri rS",
glist_getcanvas(x), "create", "line",
0, 0, 0, 0,
"-width", (obj_issignaloutlet(objsrc, outno) ? 2 : 1) * x->gl_zoom,
"-tags", 2, tags);
canvas_fixlinesfor(x, objsrc); canvas_fixlinesfor(x, objsrc);
} }
return; return;
@ -646,6 +673,16 @@ t_namelist *namelist_append(t_namelist *listwas, const char *s, int allowdup)
return (listwas); return (listwas);
} }
void namelist_free(t_namelist *listwas)
{
t_namelist *nl, *nl2;
for (nl = listwas; nl; nl = nl2)
{
nl2 = nl->nl_next;
t_freebytes(nl->nl_string, strlen(nl->nl_string) + 1);
t_freebytes(nl, sizeof(*nl));
}
}
/* change '/' characters to the system's native file separator */ /* change '/' characters to the system's native file separator */
void sys_bashfilename(const char *from, char *to) void sys_bashfilename(const char *from, char *to)
@ -692,9 +729,8 @@ int sys_isabsolutepath(const char *dir)
} }
} }
/* expand env vars and ~ at the beginning of a path and make a copy to return */ /* expand env vars and ~ at the beginning of a path and make a copy to return */
static void sys_expandpath(const char *from, char *to, int bufsize) void sys_expandpath(const char *from, char *to, int bufsize)
{ {
if ((strlen(from) == 1 && from[0] == '~') || (strncmp(from,"~/", 2) == 0)) if ((strlen(from) == 1 && from[0] == '~') || (strncmp(from,"~/", 2) == 0))
{ {
@ -780,6 +816,8 @@ int sys_fclose(FILE *stream)
int sys_usestdpath = 0; int sys_usestdpath = 0;
/* try to open a file in the directory "dir", named "name""ext", /* try to open a file in the directory "dir", named "name""ext",
for reading. "Name" may have slashes. The directory is copied to for reading. "Name" may have slashes. The directory is copied to
"dirresult" which must be at least "size" bytes. "nameresult" is set "dirresult" which must be at least "size" bytes. "nameresult" is set
@ -787,8 +825,9 @@ int sys_usestdpath = 0;
The "bin" flag requests opening for binary (which only makes a difference The "bin" flag requests opening for binary (which only makes a difference
on Windows). */ on Windows). */
int sys_trytoopenone(const char *dir, const char *name, const char* ext, int sys_trytoopenit(const char *dir, const char *name, const char* ext,
char *dirresult, char **nameresult, unsigned int size, int bin) char *dirresult, char **nameresult, unsigned int size, int bin,
int okgui)
{ {
int fd; int fd;
char buf[MAXPDSTRING]; char buf[MAXPDSTRING];
@ -812,8 +851,9 @@ int sys_trytoopenone(const char *dir, const char *name, const char* ext,
!S_ISDIR(statbuf.st_mode)); !S_ISDIR(statbuf.st_mode));
if (!ok) if (!ok)
{ {
if (sys_verbose) post("tried %s; stat failed or directory", if (okgui)
dirresult); logpost(NULL, PD_VERBOSE, "tried %s; stat failed or directory",
dirresult);
close (fd); close (fd);
fd = -1; fd = -1;
} }
@ -821,7 +861,8 @@ int sys_trytoopenone(const char *dir, const char *name, const char* ext,
#endif #endif
{ {
char *slash; char *slash;
if (sys_verbose) post("tried %s and succeeded", dirresult); if (okgui)
logpost(NULL, PD_VERBOSE, "tried %s and succeeded", dirresult);
sys_unbashfilename(dirresult, dirresult); sys_unbashfilename(dirresult, dirresult);
slash = strrchr(dirresult, '/'); slash = strrchr(dirresult, '/');
if (slash) if (slash)
@ -836,7 +877,8 @@ int sys_trytoopenone(const char *dir, const char *name, const char* ext,
} }
else else
{ {
if (sys_verbose) post("tried %s and failed", dirresult); if (okgui)
logpost(NULL, PD_VERBOSE, "tried %s and failed", dirresult);
} }
return (-1); return (-1);
} }
@ -844,7 +886,8 @@ int sys_trytoopenone(const char *dir, const char *name, const char* ext,
/* check if we were given an absolute pathname, if so try to open it /* check if we were given an absolute pathname, if so try to open it
and return 1 to signal the caller to cancel any path searches */ and return 1 to signal the caller to cancel any path searches */
int sys_open_absolute(const char *name, const char* ext, int sys_open_absolute(const char *name, const char* ext,
char *dirresult, char **nameresult, unsigned int size, int bin, int *fdp) char *dirresult, char **nameresult, unsigned int size, int bin, int *fdp,
int okgui)
{ {
if (sys_isabsolutepath(name)) if (sys_isabsolutepath(name))
{ {
@ -857,44 +900,44 @@ int sys_open_absolute(const char *name, const char* ext,
dirlen = MAXPDSTRING-1; dirlen = MAXPDSTRING-1;
strncpy(dirbuf, name, dirlen); strncpy(dirbuf, name, dirlen);
dirbuf[dirlen] = 0; dirbuf[dirlen] = 0;
*fdp = sys_trytoopenone(dirbuf, name+(dirlen+1), ext, *fdp = sys_trytoopenit(dirbuf, name+(dirlen+1), ext,
dirresult, nameresult, size, bin); dirresult, nameresult, size, bin, 1);
return (1); return (1);
} }
else return (0); else return (0);
} }
static int do_open_via_path(const char *dir, const char *name, int do_open_via_path(const char *dir, const char *name,
const char *ext, char *dirresult, char **nameresult, unsigned int size, const char *ext, char *dirresult, char **nameresult, unsigned int size,
int bin, t_namelist *searchpath) int bin, t_namelist *searchpath, int okgui)
{ {
t_namelist *nl; t_namelist *nl;
int fd = -1; int fd = -1;
/* first check if "name" is absolute (and if so, try to open) */ /* first check if "name" is absolute (and if so, try to open) */
if (sys_open_absolute(name, ext, dirresult, nameresult, size, bin, &fd)) if (sys_open_absolute(name, ext, dirresult, nameresult, size, bin, &fd, 1))
return (fd); return (fd);
/* otherwise "name" is relative; try the directory "dir" first. */ /* otherwise "name" is relative; try the directory "dir" first. */
if ((fd = sys_trytoopenone(dir, name, ext, if ((fd = sys_trytoopenit(dir, name, ext,
dirresult, nameresult, size, bin)) >= 0) dirresult, nameresult, size, bin, 1)) >= 0)
return (fd); return (fd);
/* next go through the temp paths from the commandline */ /* next go through the temp paths from the commandline */
for (nl = STUFF->st_temppath; nl; nl = nl->nl_next) for (nl = STUFF->st_temppath; nl; nl = nl->nl_next)
if ((fd = sys_trytoopenone(nl->nl_string, name, ext, if ((fd = sys_trytoopenit(nl->nl_string, name, ext,
dirresult, nameresult, size, bin)) >= 0) dirresult, nameresult, size, bin, 1)) >= 0)
return (fd); return (fd);
/* next look in built-in paths like "extra" */ /* next look in built-in paths like "extra" */
for (nl = searchpath; nl; nl = nl->nl_next) for (nl = searchpath; nl; nl = nl->nl_next)
if ((fd = sys_trytoopenone(nl->nl_string, name, ext, if ((fd = sys_trytoopenit(nl->nl_string, name, ext,
dirresult, nameresult, size, bin)) >= 0) dirresult, nameresult, size, bin, 1)) >= 0)
return (fd); return (fd);
/* next look in built-in paths like "extra" */ /* next look in built-in paths like "extra" */
if (sys_usestdpath) if (sys_usestdpath)
for (nl = STUFF->st_staticpath; nl; nl = nl->nl_next) for (nl = STUFF->st_staticpath; nl; nl = nl->nl_next)
if ((fd = sys_trytoopenone(nl->nl_string, name, ext, if ((fd = sys_trytoopenit(nl->nl_string, name, ext,
dirresult, nameresult, size, bin)) >= 0) dirresult, nameresult, size, bin, 1)) >= 0)
return (fd); return (fd);
*dirresult = 0; *dirresult = 0;
@ -907,9 +950,11 @@ int open_via_path(const char *dir, const char *name, const char *ext,
char *dirresult, char **nameresult, unsigned int size, int bin) char *dirresult, char **nameresult, unsigned int size, int bin)
{ {
return (do_open_via_path(dir, name, ext, dirresult, nameresult, return (do_open_via_path(dir, name, ext, dirresult, nameresult,
size, bin, STUFF->st_searchpath)); size, bin, STUFF->st_searchpath, 1));
} }
void open_via_helppath(const char *name, const char *dir) {}
/* --------------------- s_inter.c --------------- */ /* --------------------- s_inter.c --------------- */
/* get "real time" in seconds; take the /* get "real time" in seconds; take the

126
main/testpatch.c Normal file
View file

@ -0,0 +1,126 @@
static const char patchfile[] = "\\
canvas 527 84 1160 639 12;\
#X obj 696 339 print;\
#X obj 381 596 dac~;\
#X obj 1065 171 adc~;\
#X obj 993 226 print~;\
#X obj 97 41 r key;\
#X msg 366 28 \; pd dsp 1;\
#X obj 382 494 *~ 0;\
#X obj 389 361 -~ 0.5;\
#X obj 283 411 *~ 1e+20;\
#X obj 283 437 clip~ 0 1;\
#X obj 382 520 -~ 0;\
#X obj 381 557 *~ 0;\
#X obj 449 553 *~ 0;\
#X obj 521 536 t b f;\
#X obj 521 562 1;\
#X obj 521 588 -;\
#X obj 105 75 sel 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113, f 142;\
#X obj 1057 231 print~;\
#X msg 116 120 0;\
#X msg 161 120 1;\
#X msg 196 120 2;\
#X msg 233 121 4;\
#X msg 276 121 8;\
#X msg 351 120 16;\
#X msg 423 120 32;\
#X msg 482 119 64;\
#X msg 558 121 64;\
#X msg 598 123 16384;\
#X msg 736 133 440;\
#X msg 788 136 0;\
#X msg 828 138 1;\
#X obj 564 265 == 1;\
#X obj 452 259 / 64, f 8;\
#X obj 452 285 t f f;\
#X obj 555 154 t b f;\
#X obj 695 164 t b f;\
#X obj 787 175 t b f;\
#X obj 281 469 -~;\
#X obj 281 495 *~ 0;\
#X obj 516 349 unpack 0 0 0 4 0, f 20;\
#X obj 520 315 pack 0 0 0 0 0;\
#X msg 895 143 0;\
#X msg 935 145 1;\
#X obj 894 182 t b f;\
#X obj 383 468 +~;\
#X obj 388 336 phasor~ 2;\
#X msg 696 131 2;\
#X connect 2 0 3 0;\
#X connect 2 1 17 0;\
#X connect 4 0 16 0;\
#X connect 6 0 10 0;\
#X connect 7 0 8 0;\
#X connect 7 0 37 1;\
#X connect 7 0 44 1;\
#X connect 8 0 9 0;\
#X connect 9 0 37 0;\
#X connect 10 0 11 0;\
#X connect 10 0 12 0;\
#X connect 11 0 1 0;\
#X connect 12 0 1 1;\
#X connect 13 0 14 0;\
#X connect 13 1 15 1;\
#X connect 14 0 15 0;\
#X connect 15 0 11 1;\
#X connect 16 0 18 0;\
#X connect 16 0 5 0;\
#X connect 16 1 19 0;\
#X connect 16 2 20 0;\
#X connect 16 3 21 0;\
#X connect 16 4 22 0;\
#X connect 16 5 23 0;\
#X connect 16 6 24 0;\
#X connect 16 7 25 0;\
#X connect 16 8 26 0;\
#X connect 16 9 27 0;\
#X connect 16 10 46 0;\
#X connect 16 11 28 0;\
#X connect 16 12 29 0;\
#X connect 16 13 30 0;\
#X connect 16 14 41 0;\
#X connect 16 15 42 0;\
#X connect 16 16 3 0;\
#X connect 16 17 17 0;\
#X connect 18 0 32 0;\
#X connect 19 0 32 0;\
#X connect 20 0 32 0;\
#X connect 21 0 32 0;\
#X connect 22 0 32 0;\
#X connect 23 0 32 0;\
#X connect 24 0 32 0;\
#X connect 25 0 32 0;\
#X connect 26 0 34 0;\
#X connect 27 0 34 0;\
#X connect 28 0 35 0;\
#X connect 29 0 36 0;\
#X connect 30 0 36 0;\
#X connect 31 0 40 1;\
#X connect 32 0 33 0;\
#X connect 33 0 40 0;\
#X connect 33 1 31 0;\
#X connect 34 0 32 0;\
#X connect 34 1 32 1;\
#X connect 35 0 32 0;\
#X connect 35 1 40 3;\
#X connect 36 0 32 0;\
#X connect 36 1 40 2;\
#X connect 37 0 38 0;\
#X connect 38 0 44 0;\
#X connect 39 0 6 1;\
#X connect 39 1 10 1;\
#X connect 39 2 13 0;\
#X connect 39 2 12 1;\
#X connect 39 3 45 0;\
#X connect 39 4 38 1;\
#X connect 40 0 0 0;\
#X connect 40 0 39 0;\
#X connect 41 0 43 0;\
#X connect 42 0 43 0;\
#X connect 43 0 32 0;\
#X connect 43 1 40 4;\
#X connect 44 0 6 0;\
#X connect 45 0 7 0;\
#X connect 46 0 35 0;\
";

View file

@ -1,26 +0,0 @@
From ca00daa0c5e51ab263a4c7bf239197bdb97e3a98 Mon Sep 17 00:00:00 2001
From: Miller Puckette <msp@ucsd.edu>
Date: Sat, 11 Dec 2021 09:48:29 -0800
Subject: [PATCH 4/4] fix espd-specific compile warning that generates an
error?
---
src/x_text.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/x_text.c b/src/x_text.c
index 9bc91247..ce8e348c 100644
--- a/src/x_text.c
+++ b/src/x_text.c
@@ -98,7 +98,7 @@ static void textbuf_open(t_textbuf *x)
x, 600, 340, x->b_sym->s_name,
sys_hostfontsize(glist_getfont(x->b_canvas),
glist_getzoom(x->b_canvas)));
- sprintf(buf, ".x%lx", x);
+ sprintf(buf, ".x%lx", (unsigned long)x);
x->b_guiconnect = guiconnect_new(&x->b_ob.ob_pd, gensym(buf));
textbuf_senditup(x);
}
--
2.33.1

1
pd Submodule

@ -0,0 +1 @@
Subproject commit d6326559b2b26038d70f538725e0974c39de1fc4

1529
sdkconfig

File diff suppressed because it is too large Load diff

View file

@ -1,9 +0,0 @@
# Override some defaults so BT stack is enabled
# and WiFi disabled by default in this example
CONFIG_BT_ENABLED=y
CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=
CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=y
CONFIG_BTDM_CONTROLLER_MODE_BTDM=
CONFIG_CLASSIC_BT_ENABLED=y
CONFIG_WIFI_ENABLED=n
CONFIG_BT_SPP_ENABLED=y

View file

@ -1,5 +1,5 @@
#N canvas 332 97 403 426 12; #N canvas 332 97 393 697 12;
#X obj 53 351 dac~ 1; #X obj 53 386 dac~ 1;
#X obj 44 130 r a; #X obj 44 130 r a;
#X obj 52 326 *~; #X obj 52 326 *~;
#X obj 158 87 loadbang; #X obj 158 87 loadbang;
@ -9,10 +9,14 @@
#X obj 49 228 *~ 0.0001; #X obj 49 228 *~ 0.0001;
#X msg 156 123 dsp 1; #X msg 156 123 dsp 1;
#X obj 156 147 s pd; #X obj 156 147 s pd;
#X obj 72 295 osc~ 440; #X obj 72 268 r f;
#X obj 82 262 r f; #X obj 144 352 r b;
#X obj 54 354 +~;
#X obj 144 378 f;
#X obj 144 404 / 100;
#X obj 72 295 phasor~ 440;
#X connect 1 0 5 0; #X connect 1 0 5 0;
#X connect 2 0 0 0; #X connect 2 0 12 0;
#X connect 3 0 8 0; #X connect 3 0 8 0;
#X connect 3 0 4 0; #X connect 3 0 4 0;
#X connect 4 0 5 0; #X connect 4 0 5 0;
@ -21,5 +25,9 @@
#X connect 6 0 7 0; #X connect 6 0 7 0;
#X connect 7 0 2 0; #X connect 7 0 2 0;
#X connect 8 0 9 0; #X connect 8 0 9 0;
#X connect 10 0 2 1; #X connect 10 0 15 0;
#X connect 11 0 10 0; #X connect 11 0 13 0;
#X connect 12 0 0 0;
#X connect 13 0 14 0;
#X connect 14 0 12 1;
#X connect 15 0 2 1;

View file

@ -1,36 +1,90 @@
#N canvas 182 66 791 556 12; #N canvas 110 26 1262 545 12;
#X msg 373 294 listen 4498; #X msg 373 294 listen 4498;
#X obj 374 331 netreceive -u -f; #X obj 374 331 netreceive -u -f;
#X listbox 481 365 26 0 0 0 - - - 0; #X listbox 481 365 26 0 0 0 - - - 0;
#X listbox 374 398 26 0 0 0 - - - 0; #X listbox 374 398 26 0 0 0 - - - 0;
#X obj 374 355 list; #X obj 374 355 list;
#X obj 374 426 bng 15 250 50 0 empty empty empty 17 7 0 10 #fcfcfc #000000 #000000; #X obj 372 426 bng 15 250 50 0 empty empty empty 17 7 0 10 #fcfcfc #000000 #000000;
#X obj 373 268 loadbang; #X obj 373 268 loadbang;
#X msg 55 38 listen 4498; #X msg 55 38 listen 4498;
#X msg 62 65 listen 0; #X msg 62 65 listen 0;
#X floatatom 124 422 5 0 0 0 - - - 0; #X floatatom 120 478 5 0 0 0 - - - 0;
#X obj 47 424 list; #X obj 43 480 list;
#X listbox 47 448 20 0 0 0 - - - 0; #X listbox 43 504 20 0 0 0 - - - 0;
#X obj 227 75 text define patch; #X obj 227 75 text define patch;
#X obj 129 289 text sequence patch; #X obj 125 345 text sequence patch;
#X msg 130 263 line 0 \, auto; #X msg 126 319 line 0 \, auto;
#X obj 148 314 print; #X obj 144 370 print;
#X obj 48 398 netreceive; #X obj 44 454 netreceive;
#X msg 111 199 send pd foo 1; #X msg 107 255 send pd foo 1;
#X msg 127 231 send pd begin-new poodle .; #X msg 123 287 send pd begin-new poodle .;
#X msg 119 341 send pd end-new; #X msg 115 397 send pd end-new;
#X obj 55 12 loadbang; #X obj 55 12 loadbang;
#X msg 101 119 send a 0; #X msg 97 175 send a 0;
#X msg 96 95 send a 70; #X msg 96 95 send a 70;
#X msg 102 144 send f 440; #X msg 98 200 send f 440;
#X msg 106 170 send f 660; #X msg 102 226 send f 660;
#X obj 228 15 loadbang; #X obj 228 15 loadbang;
#X msg 229 44 read esp-patch.pd; #X msg 229 44 read esp-patch.pd;
#X obj 379 78 r amp;
#X msg 379 104 set \$1;
#X obj 379 130 s amp-set;
#X floatatom 655 144 8 0 100 1 amp amp-set amp 0;
#X obj 95 121 r amp;
#X msg 93 146 send a \$1;
#X msg 476 198 set \$1;
#X floatatom 589 180 11 0 100 1 bias bias-set bias 0;
#X obj 476 172 r bias;
#X obj 476 224 s bias-set;
#X obj 181 129 r bias;
#X msg 179 154 send b \$1;
#X msg 510 285 set \$1;
#X floatatom 623 267 10 0 1000 1 freq freq-set freq 0;
#X obj 510 259 r freq;
#X obj 510 311 s freq-set;
#X obj 268 131 r freq;
#X msg 268 157 send f \$1;
#X obj 370 494 timer;
#X obj 372 464 t b b;
#X floatatom 370 520 5 0 0 0 - - - 0;
#X obj 627 465 / 32768;
#X obj 627 491 s freq;
#X msg 626 439 8;
#X floatatom 599 29 5 0 100 0 - - - 0;
#X obj 599 54 expr 100*sqrt($f1/32768);
#X floatatom 622 82 11 0 100 0 - - - 0;
#X obj 599 106 s amp;
#X floatatom 821 349 5 0 1000 0 - - - 0;
#X obj 821 400 / 32768;
#X obj 821 426 * 100;
#X obj 821 374 + 0.25;
#X obj 821 479 s bias;
#X floatatom 832 452 10 0 0 0 - - - 0;
#X obj 817 312 r int-bias;
#X msg 941 34 \; int-bias 223 \; amp 0 \; freq 0;
#X msg 929 279 \; int-bias \$1 \; amp 0 \; freq 0;
#X msg 905 151 15;
#X msg 938 151 31;
#X obj 905 177 t b f;
#X floatatom 930 252 5 0 0 0 - - - 0;
#X msg 1003 153 55;
#X msg 970 151 47;
#X obj 847 178 del 250;
#X obj 983 185 r momentary;
#X msg 1089 155 255;
#X msg 847 204 255;
#X msg 1048 154 127;
#X obj 1107 106 + 255;
#X floatatom 1112 69 5 0 0 0 - - - 0;
#X msg 1166 155 639;
#X msg 983 417 \; int-bias 255 \; amp 0 \; freq 0;
#X msg 1134 153 510;
#X connect 0 0 1 0; #X connect 0 0 1 0;
#X connect 1 0 4 0; #X connect 1 0 4 0;
#X connect 1 1 2 0; #X connect 1 1 2 0;
#X connect 3 0 5 0; #X connect 3 0 5 0;
#X connect 4 0 3 0; #X connect 4 0 3 0;
#X connect 5 0 46 0;
#X connect 6 0 0 0; #X connect 6 0 0 0;
#X connect 7 0 16 0; #X connect 7 0 16 0;
#X connect 8 0 16 0; #X connect 8 0 16 0;
@ -50,3 +104,45 @@
#X connect 24 0 16 0; #X connect 24 0 16 0;
#X connect 25 0 26 0; #X connect 25 0 26 0;
#X connect 26 0 12 0; #X connect 26 0 12 0;
#X connect 27 0 28 0;
#X connect 28 0 29 0;
#X connect 31 0 32 0;
#X connect 32 0 16 0;
#X connect 33 0 36 0;
#X connect 35 0 33 0;
#X connect 37 0 38 0;
#X connect 38 0 16 0;
#X connect 39 0 42 0;
#X connect 41 0 39 0;
#X connect 43 0 44 0;
#X connect 44 0 16 0;
#X connect 45 0 47 0;
#X connect 46 0 45 0;
#X connect 46 1 45 1;
#X connect 48 0 49 0;
#X connect 50 0 48 0;
#X connect 51 0 52 0;
#X connect 52 0 53 0;
#X connect 52 0 54 0;
#X connect 55 0 58 0;
#X connect 56 0 57 0;
#X connect 57 0 59 0;
#X connect 57 0 60 0;
#X connect 58 0 56 0;
#X connect 61 0 55 0;
#X connect 64 0 66 0;
#X connect 65 0 66 0;
#X connect 66 0 70 0;
#X connect 66 1 67 0;
#X connect 67 0 63 0;
#X connect 68 0 66 0;
#X connect 69 0 66 0;
#X connect 70 0 73 0;
#X connect 71 0 66 0;
#X connect 72 0 66 0;
#X connect 73 0 67 0;
#X connect 74 0 66 0;
#X connect 75 0 66 0;
#X connect 76 0 75 0;
#X connect 77 0 66 0;
#X connect 79 0 66 0;

View file

@ -36,7 +36,8 @@ void tcpreceivertask(void *z)
} }
ESP_LOGI(TAG, "connecting..."); ESP_LOGI(TAG, "connecting...");
while (err = connect(newsocket, &dest_addr, sizeof(dest_addr)) < 0) while ((err = connect(newsocket,
(struct sockaddr *)&dest_addr, sizeof(dest_addr)) < 0))
{ {
ESP_LOGE(TAG, "Socket unable to connect: errno %d - retrying", errno); ESP_LOGE(TAG, "Socket unable to connect: errno %d - retrying", errno);
close(newsocket); close(newsocket);
@ -187,7 +188,7 @@ void net_hello( void)
char buf[80]; char buf[80];
uint8_t mac[6]; uint8_t mac[6];
{ {
esp_base_mac_addr_get(&mac); esp_base_mac_addr_get(mac);
sprintf(buf, "hello %02x:%02x:%02x:%02x:%02x:%02x %s;\n", sprintf(buf, "hello %02x:%02x:%02x:%02x:%02x:%02x %s;\n",
mac[0],mac[1],mac[2],mac[3],mac[4],mac[5], wifi_ipaddr); mac[0],mac[1],mac[2],mac[3],mac[4],mac[5], wifi_ipaddr);
net_sendtcp(buf, strlen(buf)); net_sendtcp(buf, strlen(buf));
@ -201,7 +202,7 @@ void net_alive( void)
uint8_t mac[6]; uint8_t mac[6];
if (elapsed > 1000000) if (elapsed > 1000000)
{ {
esp_base_mac_addr_get(&mac); esp_base_mac_addr_get(mac);
sprintf(buf, "alive %02x:%02x:%02x:%02x:%02x:%02x;\n", sprintf(buf, "alive %02x:%02x:%02x:%02x:%02x:%02x;\n",
mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]); mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);
net_sendudp(buf, strlen(buf), CONFIG_ESP_WIFI_SENDPORT); net_sendudp(buf, strlen(buf), CONFIG_ESP_WIFI_SENDPORT);