DIYstompboxes.com

DIY Stompboxes => Digital & DSP => Topic started by: Digital Larry on March 06, 2020, 08:46:35 AM

Title: ESP32-A1S audio dev board
Post by: Digital Larry on March 06, 2020, 08:46:35 AM
Finally got this in from Shenzhen (cough).

https://www.hackster.io/news/seeed-drops-new-esp32-audio-development-kit-for-audio-related-iot-projects-ad38d1f02637

Thought I'd do sort of a journal here as to what it takes to get going on it.  CAVEAT: I can't guarantee I won't give up.

The first things it takes are patience and perseverance as the getting started guide available off the Seeed page is outdated and will fail.

I tried setting up on Windows 10 at first, got failures even after following suggestions in the error logs, tried it on Ubuntu, same deal, Googled the error and found the answer on Github, you have to start with the ESP-IDF 2.3 installer.  So back to Windows where I managed to complete that exercise after about an hour.

Many of the links off the Espressif site are 404.  Looking at their forum, there are a lot of apologetic "we're working on it" kinds of messages.  Don't know how the coronavirus issue may be affecting that but it seems to go back further than a month or two.

Whenever I start these kind of things any more I just open a document and slap everything that happens in there.  Too diificult to remember all the twists and turns.

Anyway, next up I am going to try "Hello World".
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 07, 2020, 07:26:28 AM
Following..... I have one of those in the mail, at some place between China and Europe
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 07, 2020, 08:58:52 AM
All right, sounds good to have a partner in crime.  I got Hello World to run.  The "blink" example also ran, but didn't blink the LED on this particular board.

Following the ESP-IDF guide actually does seem to work.  Next you have to install the ESP-ADF libraries.  No Windows-specific instructions are given, but I think all one is trying to do is to check out some files from Git.  Some interpolation with reality is needed (directories aren't exactly as documented, etc.).  Similar to working with any online Linux instructable article.  I do have an old box running Ubuntu 18.04 but it sounds like a garbage truck when the disk is accessed which is increasingly disconcerting after I built an essentially silent Windows PC with SSD/M2 storage.  I also installed Ubuntu under Windows 10 just in case.

I haven't figured out how one connects the wifi yet.  Although you get a serial monitor via USB, it's not like you get to a prompt like you'd expect on Linux.  Truth be told, I have not worked with an RTOS before so this is going to be some exercise for my aging brain.  When I was messing with Faust on the Bela, that was cool because you can get Faust to represent controls on a web server connection, meaning you can just point your browser at the device's IP/some port and voila there is your UI.  Vastly preferable to trying to wire up pots via I2C for my home recording application.  Contrary to the intent of this forum I am not trying to make a stompbox out of this (sorry).

One bright note is that the English ESP-ADF Espressif forum seems to be active.  Most people there appear to be using it for speech recognition or smart speakers or I don't know what.

DL



Title: Re: ESP32-A1S audio dev board
Post by: free electron on March 07, 2020, 12:51:00 PM
For the ESP32 stuff on Linux i'm using VScode with PlatformIO plugin. Using this combo ESP32 can be programmed within Arduino framework or plain ESP-IDF. Installation is very easy, just install VScode, then PlatformIO extension, then add espressif32  platform.
https://docs.platformio.org/en/latest/platforms/espressif32.html
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 08, 2020, 11:24:33 AM
Suscribed!
I am too waiting for my esp32 a1s dev board.
I tried to install esp idf on win 10 and failed miserably.
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 08, 2020, 01:26:52 PM
Quote from: dschwartz on March 08, 2020, 11:24:33 AM
Suscribed!
I am too waiting for my esp32 a1s dev board.
I tried to install esp idf on win 10 and failed miserably.

See if this info helps.

Known issue with 2.2 installer.

https://github.com/espressif/esp-idf/issues/4744

I followed these steps (to use the 2.3 Windows installer) and now have the esp-idf 4.0 installed.
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 08, 2020, 02:10:26 PM
Awesome..
thanks!!!
I'll try that tonight
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 09, 2020, 12:40:14 AM
All right, just thought I'd jump in here with a bit of a warning.  Although you can install ESP-IDF and with some imagination, ESP-ADF in Windows, no such luck for Faust.  So I'm gonna start all over using the Ubuntu subsystem on Windows.  I'm reasonably sure it will work as I think I did it before on my laptop.  Sigh.  Also, the ESP-ADF examples don't seem to know about the ESP32-A1S board - only the various Lyra boards are included in the makeconfig setup.  So, it looks like for the purposes of Faust anyway, ESP-ADF is not strictly a requirement.

DL
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 09, 2020, 12:49:52 AM
What about using the Arduino IDE to program it?
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 09, 2020, 01:10:52 AM
Quote from: dschwartz on March 09, 2020, 12:49:52 AM
What about using the Arduino IDE to program it?
If you can figure it out, be my guest.  Problem is that Faust has its own world that doesn't run on Windows.  I just tried setting ESP-IDF up on Ubuntu 18.04 under Windows 10 and finally got all the packages installed to build hello_world, but Ubuntu under Windows 10 appears to not recognize the USB ports directly (so that ESP-IDF can flash the program).  I guess for the short term I will try getting everything to work on my "real" Ubuntu box even though it makes a ton of obnoxious noise.  If it works then I can worry about maybe getting an SSD for it.  That's about all I can take for one evening.

There may be some hope here...  will try again tomorrow.
https://docs.microsoft.com/en-us/archive/blogs/wsl/serial-support-on-the-windows-subsystem-for-linux
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 09, 2020, 03:35:57 PM
excuse my ignorance if i'm wrong.. but isn't there web based Faust editor? that will generate ESP32- compatible code ?

https://faust.grame.fr/tools/playground/index.html

https://faust.grame.fr/tools/editor/

Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 09, 2020, 04:24:24 PM
Yes, I've used it.  Only works on Chrome (or, at least that was the case last year).  That might work.  There's an advantage in that it lets you see the block diagram easily.  The disadvantage is mostly in workflow, in that AFAIK when you generate code this way, then you download the C++ in a ZIP, then... etc. etc.  A little inefficient. 

But keep in mind I just have my own biases and way of working and I don't always know what the best setup will be without trying some things that don't work first.  Feel free to explore whatever options you wish.  I'm semi-distracted by a million other things.

:icon_mrgreen:

DL
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 09, 2020, 09:29:20 PM
BTW have you seen this?

https://www.deeptronic.com/electronic-circuit-design/esp32-a1s-guitar-multi-effect-engine-with-microphone-and-midi-i-o/

I m a total newbie with MCUs ...i managed to install the arduino IDE and the ESP32 board library...of course, no esp32 a1s board is available on the list..but at least i think i should be able to make blinky work...someday...with a similar board definition like the standard esp32 dev board.
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 10, 2020, 12:08:09 AM
Hah, that looks pretty rad.  I'm not so interested in making a pedal honestly.  I just want a relatively powerful Faust host that is not a PC with an audio interface hanging off it (so I can patch it into my guitar preamp's effects loop easily).  I'm also maybe going to buy a MOD Dwarf assuming they have reasonably low latency.  Faust can also create LV2 plugins which would work with that so far as I know.  I do have a Macbook with Ubuntu on it, and a 4-in 4-out audio interface, what the heck I might use that.  Too many options!  Ahhhhhhh!

Sounds like the guy making the project you linked to wants to keep the code to himself, which is fine, but I don't really want to deep dive into developing a bunch of nuts and bolts stuff.  I just want to design the FX in Faust.
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 10, 2020, 03:13:23 AM
So I got my board yesterday and I was playing with it for some time.

- I successfully installed ESP-IDF on Windows 10, after 3 attempts.
-"Hello world" is running.
-"Blink" is working after some testing. Hint: The on-board LEDs are GPIO 19 and 21. If you change this in the code, they blink.

I did not try ADF yet.
I tried to use the online Faust editor, ... but as fas as I can tell it only supports the "export" using WM8978 codec. I couldn't find a way to generate C++ code compatible with the AC101.

Next: Try to install and run faust2esp32.
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 10, 2020, 09:26:57 AM
Few corresponding notes (I didn't work on this last night at all).

The ESP32-A1S is not an Espressif product, whereas the Lyra line is.
If you're interested in Faust, you can sign up for the Faust user's mailing list.
There's also a Faust Slack channel you can get an invite to once on the mailing list and there's a section there devoted to the ESP32.  Lots of low level discussions going on, e.g. using wifi seems to cause some noise in audio, etc.
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 11, 2020, 10:00:03 AM
I managed to get ESP IDF 4.0 up and running on my window 10..with the python fix it was a breeze (although it took quite a while)

Also installed Eclipse IDE for C/C++ .. havent tried it yet, but i guess i will have to configure it later.
Also have Github installed..

But i'm a bit confused.. on espresiff "get started" page ( https://docs.espressif.com/projects/esp-idf/en/v3.3.1/get-started/windows-setup.html ) says i have to setup the toolchain before the ESP..another 600MB .exe to install...uugh.. does it never ends?

anyway, being 43 years old, it feels nice to learn something new and feel your brain cells having a good workout again.
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 11, 2020, 10:05:17 AM
I think this documentation is not for version 4.0.  This is the one for 4.0:

https://docs.espressif.com/projects/esp-idf/en/v4.0/get-started/windows-setup.html (https://docs.espressif.com/projects/esp-idf/en/v4.0/get-started/windows-setup.html)

If you used the "ESP-IDF Tools Installer" you should be good to go.
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 11, 2020, 10:34:28 AM
yes,
esp-idf-tools-setup-2.2.exe

Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 11, 2020, 10:44:31 AM
I had problems with the ESP-IDF 2.2 Windows installer.  The 2.3 installer which worked is here: 

https://dl.espressif.com/dl/esp-idf-tools-setup-2.3.exe
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 11, 2020, 10:40:08 PM
Yeahhh!
Blinky and hello world running on the board!!
Had some issues defining the COM ports on win 10, but at last!! I'm not a digital virgin anymore!!

Next steps, install ESP ADF, figure out how to work with the codec and make an adc-dac "bypass"
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 12, 2020, 10:10:04 AM
great!

In the meantime, I've managed to install Faust in WLS and run faust2ESP32 to generate the files to be added to esp project, but I can't make the whole thing to compile....

I'm getting some linking errors, and I am not sure if I placed all files in the required places. This is getting tricky
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 12, 2020, 10:18:59 AM
Ok, I got it sorted out.... I had to add the Faust cpp files into CMakeLists.txt

So, I successfully compiled my first faust program. But I don't have my board here, so tonight I will try to upload and test.
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 12, 2020, 04:06:27 PM
Now i got stuck again..
Installed ESP-ADF in the same parent directory as ESP-IDF.

Then cloned the GIT files for audio_hal to work with AC101.

I can't build anything..

I don't know where i should be on the command shell, or put the ADF examples files to apply idf.py build...
Should i run them at the root directory? (where IDF and ADF  folders are? it worked for the IDF examples...)

on the "getting started" it says something about setting %ADF_PATH somewhere in some config file..but the instructions are nowhere to be found..
Any help?
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 12, 2020, 04:37:32 PM
Good and bad news.

The good ones: I have sucessfully installed ESP-IDF and Faust (not ADF yet)  in Ubuntu under Windows (WSL), and successfully compiled AND FLASHED "hello world" and "blink".
The key to make the flashing work is to set manually the baud rate. So, first locate your COM port, and chmod the corresponding /dev/ttyS* with 666.
Then run (in my case COM10)

idf.py -p /dev/ttyS10 -b 115200 flash

at least it worked for me, and flashed successfully.

The bad news: I couldn't get any faust example to work. It compiled correctly (after some dependencies fix), put after uploading to the board it does nothing. I suspect I didn't initialize the AC101 properly. Will have to test more.

Mat
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 13, 2020, 01:08:03 AM
Thanks for the tip on specifying the baud rate on the command line.  That worked.

I'm still using WSL on Windows 10.  I got the latest Faust code, did:

make
sudo make install

and while I have access to faust2esp32, I get this when trying to compile the sample program:


gary@Windows10-Pro-STUDIO:~/ESP32-A1S/esp-idf/main$ !faust
faust2esp32 -lib FaustSawtooth.dsp
ERROR : unable to open file stdfaust.lib
gary@Windows10-Pro-STUDIO:~/ESP32-A1S/esp-idf/main$


This is a really basic issue and I know I had Faust running under WSL on my laptop.  Not sure where stdfaust.lib lives (couldn't find it) or how to point to it.

OK I did

sudo apt install faust

and it's there now.
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 13, 2020, 04:04:21 AM
Good to see we are progressing collectively.

Today I was able to get the first sound out of it, using Faust.

The key was to get the initialization of the AC101 done properly. I followed the instructions of
https://faust.grame.fr/doc/tutorials/#dsp-on-the-esp32-with-faust (https://faust.grame.fr/doc/tutorials/#dsp-on-the-esp32-with-faust)
To get the Faust "hello sawtooth"
But I changed all the codec includes to point to AC101.h, and then in the main program I initialized the codec like this:


        AC101 ac101;
        while (not ac101.begin())
        {
                printf("Failed!\n");
                vTaskDelay(1000/portTICK_PERIOD_MS);
        }
        printf("Success!\n");
        ac101.SetVolumeSpeaker(32);
        ac101.SetVolumeHeadphone(32);
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 14, 2020, 03:02:01 AM
I'm stuck now.....

I can't make a simple audio passthrough, I don't get any sound coming from the input. It must be something related to the codec configuration, I guess...

The lack of documentation around these basics is killing me... it's just shooting in the dark.

Mat
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 14, 2020, 08:43:23 AM
Quote from: potul on March 14, 2020, 03:02:01 AM
I'm stuck now.....

I can't make a simple audio passthrough, I don't get any sound coming from the input. It must be something related to the codec configuration, I guess...

The lack of documentation around these basics is killing me... it's just shooting in the dark.

Mat
Unless you can read chinese ! lOL
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 14, 2020, 10:02:26 AM
Take a look at this, apparently "donny681" has come up with an ESP32-A1S specific version of the ADF?  Can't say I've tried it.

https://esp32.com/viewtopic.php?t=8105

I'll also inquire on the Faust Slack channel.  They did after all advertise support for this dang thing.  I also purchased a LyraT board.  All of these have different codecs and some are supported by Espressif drectly and some not.  The A1S is not an Espressif board as you've no doubt figured out.

======
Update - since this is a bleeding edge project, I suggest you get on the Faust User's mailing list

https://sourceforge.net/projects/faudiostream/lists/faudiostream-users

and then request access to the Slack channel.  I just asked over there and within a few minutes got a suggestion to look at:

https://github.com/phkehl/esp32-a1s-audio_hal

Specifically, it looks like:

https://github.com/phkehl/esp32-a1s-audio_hal/blob/master/driver/ac101.c

has some calls which might work, e.g.


case AUDIO_HAL_CODEC_MODE_LINE_IN:
es_mode_t  = AC_MODULE_LINE;
break;



    if (mode == AC_MODULE_LINE) {
res |= AC101_Write_Reg(0x51, 0x0408);
res |= AC101_Write_Reg(0x40, 0x8000);
res |= AC101_Write_Reg(0x50, 0x3bc0);
    }


etc.

Yet more info from the Faust Slack channel:

Quotetry using the flag -ac101 when calling faust2esp32.  This will create an AC101.cpp/h file pair which defaults to line in/out.
and not only that but (from the guy who wrote the driver):

Quoteif you run ac101.begin() the codec gets initialized for line-in and line-out at 48000 sample rate. to use the mic inputs you'll need to enable these and optionally set their gain in the appropriate register and unmute them in the adc mixer register.

the driver that"s included in faust is located here. https://github.com/thopman/AC101 (https://github.com/thopman/AC101)
if you find any issues or have any improvements you can let me know on github.
Title: Re: ESP32-A1S audio dev board
Post by: pruttelherrie on March 14, 2020, 12:50:01 PM
My A1S is still on its way from China, but in the meantime I found this AC101 library for pure Arduino (no ADF) as I understand it: https://github.com/Yveaux/AC101

It contains the initialisation for the codec.
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 14, 2020, 04:38:54 PM
OK, I've achieved sawtooth synth nirvana so far.  It takes real careful following of the instructions here:

https://faust.grame.fr/doc/tutorials/index.html#dsp-on-the-esp32-with-faust

because you have to jump around between directories, and move files around a little.

Also you need to edit the CMakeLists.txt in the code folder as follows, which is not in the instructions.


gary@Windows10-Pro-STUDIO:~/ESP32-A1S/esp-idf/faustexample/hello_world$ cat main/CMakeLists.txt
idf_component_register(SRCS "main.cpp" "AC101.cpp" "FaustSawtooth.cpp"
                    INCLUDE_DIRS "")
gary@Windows10-Pro-STUDIO:~/ESP32-A1S/esp-idf/faustexample/hello_world$


So, here are the instructions for creating this on Windows 10 Subsystem for Linux (WSL), assuming you already followed the directions at Espressif to install the ESP-IDF.  I don't think ESP-ADF is used in this context.

To install Faust;

sudo apt update
sudo apt install faust


When you open the Ubuntu window, in order to set environment variables:
cd ESP32-A1S/
cd esp-idf/
. ./export.sh


To start a new project from "Hello World"
cp -r $IDF_PATH/examples/get-started/hello_world .
cd hello_world/


Or, just switch to your desired project folder.

Set up configuration
make menuconfig

[make code changes]
idf.py build

[flash to board]
idf.py -p /dev/ttyS4 -b 115200 flash

At this point you can follow the Faust tutorial to create the Faust dsp file and then compile it to create a ZIP with C++ classes.

Be sure to use the -ac101 option with faust2esp32.

Here's my final main.cpp:

/* Hello World Example

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"

#include "AC101.h"
#include "FaustSawtooth.h"

extern "C" {
    void app_main(void);
}

void app_main(void)
{
    AC101 AC101;
    AC101.begin();
    int SR = 48000;
    int BS = 8;
    FaustSawtooth faustSawtooth(SR,BS);
    faustSawtooth.start();

    while(1) {
        faustSawtooth.setParamValue("freq",rand()%(2000-50 + 1) + 50);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}


Eventually I will make this into an end to end tutorial about using this with Ubuntu and Windows Ubuntu.

Let me know if I left anything out and I'll clarify.

DL


Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 14, 2020, 06:38:20 PM
Awesome!
I thought i had to install Ubuntu. Is WSL enough?
It is included in windows 10 isn't it?
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 14, 2020, 07:23:41 PM
You might have to install it from the Microsoft store or something.
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 15, 2020, 02:11:28 AM
Quote from: Digital Larry on March 14, 2020, 04:38:54 PM
OK, I've achieved sawtooth synth nirvana so far. 

so we are at the same point now...

I have seen your hints on how to get the input to work... I will give them a try. Some of them I already did without luck, but there are some new things to try. Will keep you posted on the results.
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 15, 2020, 02:14:22 AM
Quote from: dschwartz on March 14, 2020, 06:38:20 PM
Awesome!
I thought i had to install Ubuntu. Is WSL enough?
It is included in windows 10 isn't it?

you first enable WSL from the control panel in windows, and after rebooting you have to get Ubuntu from the Windows Store.

Title: Re: ESP32-A1S audio dev board
Post by: potul on March 15, 2020, 03:29:52 AM
No success so far with the audio input. What I just realized is that I get an initialization error of the I2C driver... I wonder if this is related.

Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 15, 2020, 08:53:21 AM
I've just been messing with a couple of oscillators and trying to add a phaser or flanger to it.  Reverb didn't work.  Echo didn't work.  Had some weird behavior and errors on the console monitor.  Part of it might be somewhat vague documentation of the Faust libraries, and some of it might be the fact that Faust support for this particular platform is pretty fresh. 

One of the developers did tell me that the http control interface isn't there, and OSC is not yet integrated.  I did get an invitation to work on the OSC stuff.  Having a little board with no obvious way to get a UI out of it sets me back farther than using the FV-1, so I'm not entirely sure what I feel like doing at this point.

Anyone riding along who wonders if "we're there yet", I'd have to say, "Dad has to pull over and ask for directions".

:icon_lol: :icon_question:

DL

[update] I was getting a warning that the configured flash size (2048 MB) didn't match the detected size (4096MB).  I ran "make menuconfig" and updated the flash size to 4096 MB and am not having the watchdog reset any more.
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 15, 2020, 11:16:32 AM
Quote from: potul on March 15, 2020, 03:29:52 AM
No success so far with the audio input. What I just realized is that I get an initialization error of the I2C driver... I wonder if this is related.
Where are you seeing that?
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 15, 2020, 12:38:15 PM
at the moment begin() is called, it returns an error in the console... and the board initialization is not finished and returns a "true" (should be false).
Even with this, the sawtooth example works.... But that's the only thing I could make work using faust. I'm also getting watchdog issues, I will try the memory configuration, as I also see this warning message.

So, it gives this message as soon as InitI2C() gets called.

E (337) i2c: i2c driver install error




Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 15, 2020, 01:33:03 PM
Yeah I got two sawtooth oscillators running into two sweeping resonant LPFs OK.

Tried adding a phaser2_stereo and getting watchdog errors here as well.  Chatting with the developer on Slack, but he's just one guy.  The more feedback we give him, (possibly) the better chance it can get fixed.

Faust code:

import("stdfaust.lib");
freq1 = nentry("freq1",880,20,10000,0.01) : si.smoo;
freq2 = nentry("freq2",440,20,20000,0.01) : si.smooth(0.99997);
gain = nentry("gain",1,0,1,0.01) : si.smoo;
osc1 = os.sawtooth(freq1)*gain;
osc2 = os.sawtooth(freq2)*gain;
lfo1 = os.osc(5.25) * 400 + 500;
lfo2 = os.osc(3.15) * 800 + 900;
lpf1 = fi.resonlp(lfo1, 0.95, 1.0);
lpf2 = fi.resonlp(lfo2, 0.8, 1.0);
// note, lfos are not used in this patch
process = (osc1),(osc2) :> pf.phaser2_stereo(3, 0.95, 40, 420, 2.8, 2000, 1.5, 1, 0.25,  0);


Flash monitor trace:

gary@Windows10-Pro-STUDIO:~/ESP32-A1S/esp-idf/faustexample/phaser/phaser$ idf.py -p /dev/ttyS4 monitor
Checking Python dependencies...
Python requirements from /home/gary/ESP32-A1S/esp-idf/requirements.txt are satisfied.
Executing action: monitor
Running idf_monitor in directory /home/gary/ESP32-A1S/esp-idf/faustexample/phaser/phaser
Executing "/usr/bin/python /home/gary/ESP32-A1S/esp-idf/tools/idf_monitor.py -p /dev/ttyS4 -b 115200 /home/gary/ESP32-A1S/esp-idf/faustexample/phaser/phaser/build/faustexample-phaser.elf -m '/usr/bin/python' '/home/gary/ESP32-A1S/esp-idf/tools/idf.py' '-p' '/dev/ttyS4'"...
--- idf_monitor on /dev/ttyS4 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x1f (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:6900
load:0x40078000,len:15428
ho 0 tail 12 room 4
load:0x40080400,len:4596
entry 0x400806e8
I (73) boot: Chip Revision: 1
I (73) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (40) boot: ESP-IDF v4.0-dirty 2nd stage bootloader
I (40) boot: compile time 09:48:34
I (49) boot: Enabling RNG early entropy source...
I (49) boot: SPI Speed      : 40MHz
I (49) boot: SPI Mode       : DIO
I (53) boot: SPI Flash Size : 4MB
I (58) boot: Partition Table:
I (61) boot: ## Label            Usage          Type ST Offset   Length
I (68) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (76) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (83) boot:  2 factory          factory app      00 00 00010000 00100000
I (91) boot: End of partition table
I (95) boot_comm: chip revision: 1, min. application chip revision: 0
I (102) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x0ecc8 ( 60616) map
I (133) esp_image: segment 1: paddr=0x0001ecf0 vaddr=0x3ffb0000 size=0x01320 (  4896) load
I (135) esp_image: segment 2: paddr=0x00020018 vaddr=0x400d0018 size=0x23dd4 (146900) map
0x400d0018: _stext at ??:?
I (192) esp_image: segment 3: paddr=0x00043df4 vaddr=0x3ffb1320 size=0x00e38 (  3640) load
I (194) esp_image: segment 4: paddr=0x00044c34 vaddr=0x40080000 size=0x00400 (  1024) load
0x40080000: _WindowOverflow4 at /home/gary/ESP32-A1S/esp-idf/components/freertos/xtensa_vectors.S:1778
I (199) esp_image: segment 5: paddr=0x0004503c vaddr=0x40080400 size=0x0f7cc ( 63436) load
I (244) boot: Loaded app from partition at offset 0x10000
I (245) boot: Disabling RNG early entropy source...
I (245) psram: This chip is ESP32-D0WD
I (251) spiram: Found 64MBit SPI RAM device
I (254) spiram: SPI RAM mode: flash 40m sram 40m
I (259) spiram: PSRAM initialized, cache is in low/high (2-core) mode.
I (267) cpu_start: Pro cpu up.
I (270) cpu_start: Application information:
I (275) cpu_start: Project name:     faustexample-phaser
I (281) cpu_start: App version:      v4.0-dirty
I (286) cpu_start: Compile time:     Mar 15 2020 09:48:50
I (292) cpu_start: ELF file SHA256:  2f7b6d33060bb31a...
I (298) cpu_start: ESP-IDF:          v4.0-dirty
I (304) cpu_start: Starting app cpu, entry point is 0x40081368
0x40081368: call_start_cpu1 at /home/gary/ESP32-A1S/esp-idf/components/esp32/cpu_start.c:272
I (0) cpu_start: App cpu up.
I (1195) spiram: SPI SRAM memory test OK
I (1196) heap_init: Initializing. RAM available for dynamic allocation:
I (1196) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (1202) heap_init: At 3FFB31C0 len 0002CE40 (179 KiB): DRAM
I (1209) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (1215) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (1222) heap_init: At 4008FBCC len 00010434 (65 KiB): IRAM
I (1228) cpu_start: Pro cpu start user code
I (1246) spi_flash: detected chip: generic
I (1247) spi_flash: flash io: dio
I (1256) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (3257) AC101: reset succeed
I (3377) AC101: init done
I (3377) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (3377) I2S: DMA Malloc info, datalen=blocksize=64, dma_buf_count=3
I (3377) I2S: DMA Malloc info, datalen=blocksize=64, dma_buf_count=3
I (3387) I2S: APLL: Req RATE: 48000, real rate: 47999.992, BITS: 32, CLKM: 1, BCK_M: 8, MCLK: 24575996.000, SCLK: 3071999.500000, diva: 1, divb: 0
E (8387) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (8387) task_wdt:  - IDLE0 (CPU 0)
E (8387) task_wdt: Tasks currently running:
E (8387) task_wdt: CPU 0: Faust DSP Task
E (8387) task_wdt: CPU 1: IDLE1
E (13387) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (13387) task_wdt:  - IDLE0 (CPU 0)
E (13387) task_wdt: Tasks currently running:
E (13387) task_wdt: CPU 0: Faust DSP Task
E (13387) task_wdt: CPU 1: IDLE1
E (18387) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (18387) task_wdt:  - IDLE0 (CPU 0)
E (18387) task_wdt: Tasks currently running:
E (18387) task_wdt: CPU 0: Faust DSP Task
E (18387) task_wdt: CPU 1: IDLE1
E (23387) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (23387) task_wdt:  - IDLE0 (CPU 0)
E (23387) task_wdt: Tasks currently running:
E (23387) task_wdt: CPU 0: Faust DSP Task
E (23387) task_wdt: CPU 1: IDLE1
E (28387) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (28387) task_wdt:  - IDLE0 (CPU 0)
E (28387) task_wdt: Tasks currently running:
E (28387) task_wdt: CPU 0: Faust DSP Task
E (28387) task_wdt: CPU 1: IDLE1
E (33387) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (33387) task_wdt:  - IDLE0 (CPU 0)
E (33387) task_wdt: Tasks currently running:
E (33387) task_wdt: CPU 0: Faust DSP Task
E (33387) task_wdt: CPU 1: IDLE1
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 15, 2020, 09:18:56 PM
Spent a bit of time on Slack with a Faust ESP32 library developer.  Apparently my code works OK on his board!  But I keep getting a glitch/timeout (watchdog timer error) the minute I add a phaser block.  So, something is obviously different, just haven't discovered what it is.  I enabled the SPI RAM and tried to find whatever block in the phaser generated C++ code that might need to use it, and tagged it for use as external (per the Faust ESP32 tutorial).  None of it made any difference.

I did google the exact wdt error and got all sorts of information, mostly related to the Arduino IDE set up and how to kick/feed the watchdog timer to prevent this.  I may see if some of that works.

Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 16, 2020, 12:52:29 AM
Quote from: potul on March 15, 2020, 12:38:15 PM
at the moment begin() is called, it returns an error in the console... and the board initialization is not finished and returns a "true" (should be false).
Even with this, the sawtooth example works.... But that's the only thing I could make work using faust. I'm also getting watchdog issues, I will try the memory configuration, as I also see this warning message.

So, it gives this message as soon as InitI2C() gets called.

E (337) i2c: i2c driver install error
Could you do me a favor and paste up a few of the watchdog timer errors you're seeing?  I noticed here that they are 5 seconds apart, corresponding to a couple of the maybe two dozen watchdog related settings in sdkconfig.

Also please run:

grep WDT sdkconfig

and let me know what you get.  Here's mine:


CONFIG_BOOTLOADER_WDT_ENABLE=y
# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set
CONFIG_BOOTLOADER_WDT_TIME_MS=9000
CONFIG_ESP_INT_WDT=y
CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
CONFIG_ESP_INT_WDT_CHECK_CPU1=y
CONFIG_ESP_TASK_WDT=y
# CONFIG_ESP_TASK_WDT_PANIC is not set
CONFIG_ESP_TASK_WDT_TIMEOUT_S=5
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y
CONFIG_INT_WDT=y
CONFIG_INT_WDT_TIMEOUT_MS=300
CONFIG_INT_WDT_CHECK_CPU1=y
CONFIG_TASK_WDT=y
# CONFIG_TASK_WDT_PANIC is not set
CONFIG_TASK_WDT_TIMEOUT_S=5
CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y
CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 16, 2020, 05:36:27 AM
I'm thinking on reinstalling everything, now that I know how to do it... because I'm getting some weird errors but after doing a lot of install/unisntall something maybe got wrong...

Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 16, 2020, 09:41:38 AM
Practice makes perfect!  I did it about 5 times myself. 
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 16, 2020, 11:10:32 AM
I reinstalled everything, and still getting the I2C driver error. I'm about to give up on this board.

On the other hand, yesterday I was able to install the modified ADF and run a couple of examples (mp3 player) fine, without errors.... So I'm not sure why I get these errors when using the Faust included driver.

Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 16, 2020, 11:19:27 AM
Don't blame you.  I wasn't expecting it to be this hard either.  I'm probably going to continue to interact with the Faust developers, who knows, maybe the answer (to my issues) is "just around the bend".  I also think I'm going to pull out the old Macbook I installed Ubuntu Studio on and develop some Faust apps just to get my Faust chops back up (not that they were ever that great).

Until such time as OSC is supported on the ESP32 Faust port, it's of limited value to me anyway as I need more than a few buttons and pots and blinking lights for a UI.

Out of curiosity, does your ESP32 board have 8 push buttons on the bottom edge or just 6 and then 2 more towards the middle?  There are at least 2 versions of the board out there.  Mine has the 8 buttons in a row.
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 16, 2020, 11:57:57 AM
Mine has 8 in a row.

Quick update.... I just got a small victory one minute ago. I was able to get an audio passthrough working, from line in into headphones out, using Faust.

I had to modify the AC101 driver to ignore the I2C error... for some reason, the board is giving an error, but it gets initialized correclty. So I just ignore it.

I'm trying now to run something else with Faust and see if it works. I will keep you posted.
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 16, 2020, 12:45:20 PM
well... I can't make anything else work..... looks like Faust support is not really there yet.

I think I give up. Going back to my FV-1 projects. Maybe I will retake it in some months when things are more advanced.
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 16, 2020, 01:29:41 PM
With faust it looks it has failed..
But still is a good option for a simple delay isn't it?
Title: Re: ESP32-A1S audio dev board
Post by: free electron on March 16, 2020, 02:51:19 PM
I'd try to increase the BS from 8 to say 256. With only 8 samples block the latency is small, but the load on the core will be quite significant. Especially having so many abstracted layers and RTOS running on the MCU. I'm not surprised it starts to trigger the watchdog on any even not too complex operations. The longer the sample block the more efficient the dsp operations are, but at the cost of latency. So one has to find a good compromise.
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 16, 2020, 03:57:10 PM
Quote from: free electron on March 16, 2020, 02:51:19 PM
I'd try to increase the BS from 8 to say 256. With only 8 samples block the latency is small, but the load on the core will be quite significant. Especially having so many abstracted layers and RTOS running on the MCU. I'm not surprised it starts to trigger the watchdog on any even not too complex operations. The longer the sample block the more efficient the dsp operations are, but at the cost of latency. So one has to find a good compromise.
I'll give that a try.  I haven't worked with RTOS before, so am just coming up to speed on program structure etc.  Looks like we're on lockdown for at least 3 weeks, other than scavenging for toilet paper, don't have to go out for anything for a few days.
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 17, 2020, 11:47:34 AM
Maybe I'm expecting too much from the ESP32.  The announcement at the Faust site talks about how much faster it is than a Teensy, and then there's a reverb example for Teensy.  I can get small algos to work OK but as I add blocks, I get watchdog timer errors, so I increase the block size, which gave me stack overflow errors (although going from 8 to 256 was OK and let me get the phaser2_demo block running), so I increased the stack size, which gave me i2s errors: 

E (3380) I2S: /home/gary/ESP32-A1S/esp-idf/components/driver/i2s.c:1062 (i2s_driver_install):I2S buffer length at most 1024 and more than 8
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
===
A guy has made a Eurorack module out of an ESP32 module, but it's not clear exactly how much power it needs.  A sampler doesn't really do a lot of number crunching.  I like working with Faust and want to push certain things as far as they will go, but for my non pedal needs it may be better to just do all this on a spare PC with a USB audio/MIDI interface.
=========
Another suggestion I just got was to set the compiler flag -Os (make menuconfig) which turns off the debug mode of the compiler.  This helped a little bit.

So, I think that the ESP32-A1S is up to some small tasks like running LFOs and wiggling filters around.  The external memory support is still somewhat lacking.  I couldn't get any reverb or delay example to work even with manual tweaking of the generated C++ code.  I might try flanger as I would like an envelope controlled flanger.

This chip is probably OK for a Eurorack CV generator/processor, but as far as audio FX go, I'm not even sure it outdoes an FV-1.  Of course if it can receive MIDI somehow, you can make it do synthy things.  That is not my goal though.

All that said, it is still a work in progress, and it's nice to be able to at least chat with the developers and let them know someone cares about what they are doing!
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 18, 2020, 11:03:15 AM
Oh no..
i got to blinky, and seeing your posts, it looks like it is not a chip for a noob like me  :icon_redface:

Still..it should be not as complicated to use it on non-dsp functions like a  programmable switcher or to control I2S digipots, via BT ?
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 19, 2020, 09:58:06 PM
Quote from: dschwartz on March 18, 2020, 11:03:15 AM
Oh no..
i got to blinky, and seeing your posts, it looks like it is not a chip for a noob like me  :icon_redface:

Still..it should be not as complicated to use it on non-dsp functions like a  programmable switcher or to control I2S digipots, via BT ?
Well, anything takes a bit of learning.  This one can use the Arduino environment and as far as reading pots or wiggling GPIO lines it seems straightforward.

DL
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 21, 2020, 11:47:19 AM
Update on the ESP32-A1S and Faust.

#1, as they said on the Faust page, it's "in development".  Even though the announcement was made last July, I kinda get the feeling I may be one of the first people to actually be trying it.

#2, as a result of joining the Faust Slack channel, I've been able to interact with a few of the Faust developers and give them some feedback on the ESP32 port.  I even accidentally found a bug which they quickly fixed.

#3, at present, none of the generated code knows about the 8 MB of external RAM, so it tries to allocate any RAM (like for echo/delay blocks) in the internal RAM.  This is limited to about 150 msec which is fine for chorus/flange and slapback but not much else.

#4, I've encountered some other errors, such as watchdog timeout, when the algorithm I put together could not complete in the available time slot.  My example was a couple sawtooth oscillators going into a phaser going into a wah wah.  I don't consider that very much, but it's not easy to tell how close you are to the limits with the generated code.

#5, there is a profiling tool you can get for RTOS development, but it's something like $2500 (cough)

I'm still interested in messing around with the ESP32 because the promise of a stable, low latency "thing" for even certain types of FX appeals to me.  I've also fired up my old Macbook Pro running Ubuntu Studio 19.10 to create Faust apps that I can put in the FX loop of my modeling preamp using a USB audio interface.  So I can still scratch my Faust itch in a relatively less limited environment.

I also have half a mind to try to get the "Univibe" code from musicdsp.org running on it.  This is a circuit simulation approach AFAICT.

https://www.musicdsp.org/en/latest/Effects/277-univox-univibe-emulator.html
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 28, 2020, 05:32:32 PM
Hey Larry
Did you tried this?
https://github.com/hamuro80/blackstomp

This guy has been working a lot with the esp32a1s
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on March 28, 2020, 06:34:58 PM
Quote from: dschwartz on March 28, 2020, 05:32:32 PM
Hey Larry
Did you tried this?
https://github.com/hamuro80/blackstomp

This guy has been working a lot with the esp32a1s
Interesting, I don't really see any effects code.  I'm not really interested in building a pedal... the board I have has stereo I/O already.  Yes it's just a dev board but that's all I need.
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on March 28, 2020, 07:23:34 PM
Yes, it's the bare bones, it has the dsp block empty
Title: Re: ESP32-A1S audio dev board
Post by: potul on March 31, 2020, 03:39:29 AM
Quote from: dschwartz on March 28, 2020, 05:32:32 PM
Hey Larry
Did you tried this?
https://github.com/hamuro80/blackstomp

This guy has been working a lot with the esp32a1s

thanks for the link. Although it's not solving our Faust issue, it's a good starting point to code some effects in plain C, using the arduino IDE

I will probably use it to recycle some code I built long ago for the dsPIC series...

Mat
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on April 05, 2020, 08:53:47 PM
Quote from: potul on March 31, 2020, 03:39:29 AM
Quote from: dschwartz on March 28, 2020, 05:32:32 PM
Hey Larry
Did you tried this?
https://github.com/hamuro80/blackstomp

This guy has been working a lot with the esp32a1s

thanks for the link. Although it's not solving our Faust issue, it's a good starting point to code some effects in plain C, using the arduino IDE

I will probably use it to recycle some code I built long ago for the dsPIC series...

Mat
Any success?
I loaded the sketch via arduino to my esp32 board and it worked!
I set the MIC1 as the input for left to right and now i have a nice mic-headphone amplifier..but i can't find any useful example dsp code to put in there and learn the mechanic of it.
Title: Re: ESP32-A1S audio dev board
Post by: potul on April 06, 2020, 02:33:29 AM
I've been busy with other stuff, so I didn't progress much on this one.
I would start with programming a basic delay line in C (search for C examples, you don't need them to be ESP32 specific). Well you might need to check how to use the memory in the ESP32 board for the delay.

Once you have a working delay line, you can use it for all kind of effects.

Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 06, 2020, 10:37:28 AM
Daniel,

I was thinking of trying the Univibe code here:

https://www.musicdsp.org/en/latest/Effects/277-univox-univibe-emulator.html

I've been plugging away gradually at getting better at Faust.  There is a Faust IDE now which has a code editor, block diagram viewer, oscilloscope and spectrogram viewer and ability to process WAV files, looped or not, or a live microphone.

https://ccrma.stanford.edu/~rmichon/publications/doc/WAC-19-ide.pdf

Yesterday I also discovered that you need to crank the line in gain all the way up to get any level through the board.  I'm settling for a single flanger at the moment.  One challenge for using this board as a pedal is "how do you get pot controls into it"?  I looked at the audio board schematic.  There's a header on the board that brings out a few GPIOs but AFAIK none of these are the ones that go to the ADC.  So you'd probably be left using an external A2D->I2C chip and then bring that in, with accompanying low level programming, which is NOT where my head is at.  One could conceivably use the 6 buttons on the board for up/down on 3 params, or add a display and "whatever" but again that's not something I feel up to tackling.

Nevertheless, so far, I got a really nice single flanger running and a little later today I'll upload the code that did it.

DL
DL

Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 08, 2020, 11:15:19 AM
Yesterday I tried out the wifi smart_config example included with ESP-IDF.  This uses an Android/IOS app to connect the ESP32 to your WLAN, and it works pretty well.  I also incorporated the code (miraculously) into my Faust based project, but haven't tested it yet.  The only reason this would matter to anyone is that it theoretically allows OSC to be used for parameter adjustment, so no pots or ADC needed.  Not great for a pedal, but for a little board on a piece of plexiglass sitting by my guitar rig it's OK.  Only challenge is that the ESP32 port of Faust doesn't currently include OSC, but a guy is working on it, and I'm ready to assist.

Ultimately, who knows if the external RAM can be made to work easily with Faust, and how much CPU horsepower the thing really has?  My Faust based examples seemed to run out of power (hitting watchdog resets) fairly quickly, while there's that "Blackstomp" pedal that seems to be much more powerful.  My only hesitation with that one rests partially in belief, since whoever published the video didn't include any FX source code.

DL
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 12, 2020, 11:44:16 AM
I remember in the early days of messing with the FV-1 getting mad because I thought the chip was getting the best of me.  Well I showed the FV-1.  A similar thing is happening with the ESP32.  I have no intention of going commercial, and I am not sure I really NEED to develop FX for this little board, but there is a certain advantage compared to writing Jack apps for Linux, because that tends to have unpredictable xruns, aka audio glitches, which I have very low tolerance for.  And the ESP32 was starting to make me MAD!

I was able to integrate some open source button processing code I found on Github, and work through how to get it to work on the AI Thinker board.  I only chose the AI Thinker board because that's what was shown on the Faust page describing ESP32 support.  If you want to get much out of the AI Thinker web site you'd better be able to read Chinese.  Even all of their "app notes" are simply links off to Espressif's app notes for the Lyra line of boards.

So, now I can process 6 buttons on the board.  In the context of a flanger, I'd use these for up/down control of:
a) initial delay (flanger tune)
b) LFO rate
c) LFO width

Yeah, mix and feedback would be nice to have as well (sigh).  Maybe there's a way without having to connect anything else up to the board.  Anyway, stay tuned, not all is lost.

DL
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on April 12, 2020, 09:59:09 PM
If you can't do it, no one can.. you're the best!

We really appreciate your contribution to the community here!!
You could make 1 button to toggle between "increase/ decrease", and the other 5 for each parameter..
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 13, 2020, 12:29:31 AM
Haha... send money!

I'm not all that hot on a push button interface... it's just stopgap until I think of something else.  There's a 12 channel I2C ADC for pretty cheap, I think 6 or 8 pots might be OK.  I know I said I didn't want to build anything, but I do change my mind a lot.  OSC would be the best option but it's not implemented yet in Faust on the ESP32 AFAIK.

DL
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on April 13, 2020, 12:53:14 AM
And a multiplexer for 1 available adc gpio?
Title: Re: ESP32-A1S audio dev board
Post by: MoruyaGuitarist on April 13, 2020, 12:44:19 PM
Not that this is going to be a huge help or possibly already been thought of - It only takes a flip flop chip and 2 spare NAND gates to convert a rotary encoder into an up & down signal. Encoders are used one all the commercial pedals and equipment instead of using pots. The ones like below also have the momentary push button also commonly used for guitar effects.

https://electronics.stackexchange.com/questions/231803/rotary-encoder-to-2-buttons
(https://electronics.stackexchange.com/questions/231803/rotary-encoder-to-2-buttons)




https://au.element14.com/bourns/pec11r-4115f-s0018/incremental-encoder-2ch-18pulse/dp/2474846?gclid=EAIaIQobChMI9IKwvufl6AIV1XwrCh0dKg4_EAQYAyABEgJNTfD_BwE&mckv=s_dc|pcrid|380892800521|pkw||pmt||slid||product|2474846|pgrid|76493923343|ptaid|aud-451860875263:pla-363010435644|&CMP=KNC-GAU-GEN-SHOPPING-TEST-NEW
(https://au.element14.com/bourns/pec11r-4115f-s0018/incremental-encoder-2ch-18pulse/dp/2474846?gclid=EAIaIQobChMI9IKwvufl6AIV1XwrCh0dKg4_EAQYAyABEgJNTfD_BwE&mckv=s_dc%7Cpcrid%7C380892800521%7Cpkw%7C%7Cpmt%7C%7Cslid%7C%7Cproduct%7C2474846%7Cpgrid%7C76493923343%7Cptaid%7Caud-451860875263:pla-363010435644%7C&CMP=KNC-GAU-GEN-SHOPPING-TEST-NEW)
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 13, 2020, 01:41:43 PM
Yeah, thanks for the info.  I get all tweaked out about UI concerns.  For example, the FV-1 having only 3 pots requires a fair number of tradeoffs once you go past trivial FX implementations.  I'm not sure how far I'm going to get with FX on the ESP32, but for example, the envelope controlled flanger already has 7 or 8 controls in the Jack/Qt version I did.  I'm not trying to make a guitar modeler with the ESP32.  At this time I'm hoping it can be convinced to do different types of modulation algos to use in my Eleven rack FX loop.

With pots and buttons and encoders and LEDs there's always the "what am I adjusting" dilemma unless you attach an LCD readout or put labels on the pots, the function of which would always be changing depending on which patch was uploaded.  I'm actually OK with the idea of adding some pots and an I2C LCD of some sort.  Whether or not that is the ultimate solution one could achieve with an ESP32, I don't know.

I really liked the UI on my Line6 M9 as regards using a few pots and switches and an LCD to allow you to tweak a LOT of different things.

I did look at the Blackstomp project that the one guy put up and it's interesting.  It uses the ESP32-A1S module directly so you get access to a bunch of analog inputs that the AI Thinker audio board does not bring out.  That circuit actually does look pretty cool, although I cannot figure out how you upload code to it as there is no USB interface.

DL
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on April 13, 2020, 01:54:50 PM
I have spoken with the blackstomp creator and he tells me that it will be a propietary code, so he will sell pre-programmed esp32s included with the kit, and supply a programming environment for dsp codes ..or something like that.
Anyway, the pcb is pretty straightforward..you could add a serial port and use a rs232 usb/serial programmer ..

Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 13, 2020, 02:19:19 PM
Quote from: dschwartz on April 13, 2020, 01:54:50 PM
I have spoken with the blackstomp creator and he tells me that it will be a propietary code, so he will sell pre-programmed esp32s included with the kit, and supply a programming environment for dsp codes ..or something like that.
Anyway, the pcb is pretty straightforward..you could add a serial port and use a rs232 usb/serial programmer ..
Interesting.  Yeah a preprogrammed ESP32 is not so exciting for me, or even some other programming environment, but you're right, I could get some USB to UART cable.  For the time being I am going to keep working with the audio dev board I have and see how far I can get with Faust. 

DL
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 13, 2020, 04:40:39 PM
All right, here's my code for a basic mono flanger which uses the 6 pushbuttons of the AI-Thinker ESP32-A1s audio/wifi/bluetooth dev board to adjust LFO width, speed, and flanger center delay.

The code layout is structured as a typical esp-idf project, with all the source in a "main" folder below the project folder.

Run this command to create basicFlanger.cpp and AC101.cpp:


faust2esp32 -lib -ac101 basicFlanger.dsp


This will create a ZIP file - you have to get the files out of it.

Here are the other important contents of the "main" folder.

CMakeLists.txt

idf_component_register(SRCS "main.cpp" "AC101.cpp" "basicFlanger.cpp" "button.c" INCLUDE_DIRS "")

main.cpp


/* stereoFlanger main

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "esp_system.h"
#include "esp_log.h"
#include "esp_spi_flash.h"
#include "driver/gpio.h"
#include "soc/timer_group_struct.h"
#include "soc/timer_group_reg.h"

#define DELAYMIN 64
#define DELAYMAX 864
#define LFORATEMIN 0.02
#define LFORATEFACTOR 1.2
#define LFORATEMAX 8.0
#define LFOWIDTHMIN 0.02
#define LFOWIDTHFACTOR 1.2
#define LFOWIDTHMAX 1.0

extern "C" {
#include "button.h"
}

#include "AC101.h"
#include "basicFlanger.h"

extern "C" {
    void app_main(void);
    void initialise_wifi(void);
    QueueHandle_t * button_init(unsigned long long );
}

void app_main(void)
{
    int SR = 32000;
//  BS = 256 seems to be about the maximum you can set it.
//  maybe 384.  I'm setting it higher to try to avoid WDT CPU0 Idle errors
//  when I add more blocks to the DSP file
//  BS = 512 causes stack overflow and reboot
    int BS = 128;

int delay = DELAYMIN;
float rate = 1.0;
float width = 0.25;

    AC101 AC101;
//    initialise_wifi();
    AC101.begin();
    AC101.SetVolumeHeadphone(63);
button_event_t ev;
QueueHandle_t button_events = button_init(PIN_BIT(5) | PIN_BIT(13) | PIN_BIT(18)  | PIN_BIT(19) | PIN_BIT(23) | PIN_BIT(36));

    basicFlanger basicFlanger(SR,BS); 
    basicFlanger.start();
       
    while (true) {
if (xQueueReceive(button_events, &ev, 1000/portTICK_PERIOD_MS)) {
// ESP_LOGI("Queue rx", "pin %d", ev.pin);
if ((ev.pin == 36) && (ev.event == BUTTON_DOWN)) {
if (delay > DELAYMIN)
{
delay--;
}
basicFlanger.setParamValue("Delay", delay);
ESP_LOGI("Flanger delay", "Down-> %d", delay);
}
if ((ev.pin == 13) && (ev.event == BUTTON_DOWN)) {
if (delay < DELAYMAX)
{
delay++;
}
basicFlanger.setParamValue("Delay", delay);
ESP_LOGI("Flanger delay", "Up-> %d", delay);
}
if ((ev.pin == 5) && (ev.event == BUTTON_DOWN)) {
if (width < LFOWIDTHMAX)
{
width = width * LFOWIDTHFACTOR;
}
else
{
width = LFOWIDTHMAX;
}
if (width < LFOWIDTHMIN)
{
width = LFOWIDTHMIN;
}
basicFlanger.setParamValue("Width", width);
ESP_LOGI("LFO Width", "Up=>%f", width);
}
if ((ev.pin == 18) && (ev.event == BUTTON_DOWN)) {
if (width > LFOWIDTHMIN)
{
width = width/LFOWIDTHFACTOR;
}
else
{
width = 0.0;
}
basicFlanger.setParamValue("Width", width);
ESP_LOGI("LFO Width", "Down=>%f", width);
}
if ((ev.pin == 19) && (ev.event == BUTTON_DOWN)) {
if (rate > LFORATEMIN)
{
rate = rate/LFORATEFACTOR;
}
else
{
rate = 0.0;
}
basicFlanger.setParamValue("Rate", rate);
ESP_LOGI("LFO Rate", "Down->%f", rate);
}
if ((ev.pin == 23) && (ev.event == BUTTON_DOWN)) {
if (rate <  LFORATEMIN)
{
rate = LFORATEMIN;
}
if (rate <  LFORATEMAX)
{
rate = rate * LFORATEFACTOR;
}
basicFlanger.setParamValue("Rate", rate);
ESP_LOGI("LFO Rate", "Up->%f", rate);
}
}
    }
}


button.c

#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"
#include "esp_log.h"

#include "button.h"

#define TAG "BUTTON"

typedef struct {
uint8_t pin;
    bool inverted;
uint16_t history;
    uint64_t down_time;
} debounce_t;

int pin_count = -1;
debounce_t * debounce;
QueueHandle_t * queue;

static void update_button(debounce_t *d) {
    d->history = (d->history << 1) | gpio_get_level(d->pin);
}

#define MASK   0b1111000000111111
static bool button_rose(debounce_t *d) {
    if ((d->history & MASK) == 0b0000000000111111) {
        d->history = 0xffff;
        return 1;
    }
    return 0;
}
static bool button_fell(debounce_t *d) {
    if ((d->history & MASK) == 0b1111000000000000) {
        d->history = 0x0000;
        return 1;
    }
    return 0;
}
static bool button_down(debounce_t *d) {
    if (d->inverted) return button_fell(d);
    return button_rose(d);
}
static bool button_up(debounce_t *d) {
    if (d->inverted) return button_rose(d);
    return button_fell(d);
}

#define LONG_PRESS_DURATION (1000)

static uint32_t millis() {
    return esp_timer_get_time() / 1000;
}

static void send_event(debounce_t db, int ev) {
    button_event_t event = {
        .pin = db.pin,
        .event = ev,
    };
    xQueueSend(queue, &event, portMAX_DELAY);
}

static void button_task(void *pvParameter)
{
    while (1) {
        for (int idx=0; idx<pin_count; idx++) {
            update_button(&debounce[idx]);
            if (debounce[idx].down_time && (millis() - debounce[idx].down_time > LONG_PRESS_DURATION)) {
                debounce[idx].down_time = 0;
//               ESP_LOGI(TAG, "%d LONG", debounce[idx].pin);
                int i=0;
                while (!button_up(&debounce[idx])) {
//                    ESP_LOGI(TAG, "debounce %d i: %d", debounce[idx].pin, i);
    if (!i) send_event(debounce[idx], BUTTON_DOWN);
                    i++;
                    if (i>=5) i=0;
                    vTaskDelay(20/portTICK_PERIOD_MS);   // debug, originally 10
                    update_button(&debounce[idx]);
                }
//                ESP_LOGI(TAG, "%d UP", debounce[idx].pin);
                send_event(debounce[idx], BUTTON_UP);
            } else if (button_down(&debounce[idx])) {
                debounce[idx].down_time = millis();
//                ESP_LOGI(TAG, "%d DOWN", debounce[idx].pin);
                send_event(debounce[idx], BUTTON_DOWN);
            } else if (button_up(&debounce[idx])) {
                debounce[idx].down_time = 0;
//                ESP_LOGI(TAG, "%d UP", debounce[idx].pin);
                send_event(debounce[idx], BUTTON_UP);
            }
        }
        vTaskDelay(10/portTICK_PERIOD_MS);
    }
}

QueueHandle_t * button_init(unsigned long long pin_select) {
    if (pin_count != -1) {
        ESP_LOGI(TAG, "Already initialized");
        return NULL;
    }

    ESP_LOGI(TAG, "configuring GPIOs");
    // Configure the pins
    gpio_config_t io_conf;
    io_conf.mode = GPIO_MODE_INPUT;   
io_conf.pull_up_en = 1;
io_conf.pull_down_en = 0;
    io_conf.pin_bit_mask = pin_select;
    gpio_config(&io_conf);

    // Scan the pin map to determine number of pins
    pin_count = 0;
    for (int pin=0; pin<=39; pin++) {
        if ((1ULL<<pin) & pin_select) {
            pin_count++;
        }
    }
ESP_LOGI(TAG, "Pin count: %d", pin_count);

    // Initialize global state and queue
    debounce = calloc(pin_count, sizeof(debounce_t));
    queue = xQueueCreate(4, sizeof(button_event_t));

    // Scan the pin map to determine each pin number, populate the state
    uint32_t idx = 0;
    for (int pin=0; pin<=39; pin++) {
        if ((1ULL<<pin) & pin_select) {
            ESP_LOGI(TAG, "Registering button input: %d", pin);
            debounce[idx].pin = pin;
            debounce[idx].down_time = 0;
            debounce[idx].inverted = true;
            if (debounce[idx].inverted) debounce[idx].history = 0xffff;
            idx++;
        }
    }

    // Spawn a task to monitor the pins
    xTaskCreate(&button_task, "button_task", 4096, NULL, 10, NULL);

    return queue;
}


button.h

#define PIN_BIT(x) (1ULL<<x)

#define BUTTON_DOWN (1)
#define BUTTON_UP (2)

typedef struct {
uint8_t pin;
    uint8_t event;
} button_event_t;

QueueHandle_t * button_init(unsigned long long );


basicFlanger.dsp

import("stdfaust.lib");
flaDelay = hslider("[3]Delay", 156, 5, 1000, 1) : si.smoo;
flaFeedback = hslider("[4]Flange Fb", 0.8, 0, 0.97, 0.01) : si.smoo;
flaDepth = hslider("[5]Flange Dep", 0.95, 0, 1.0, 0.01) : si.smoo;
flaLFORate = hslider("[6]Rate", 0.25, 0, 3, 0.01) : si.smoo;
flaLFOWidth = hslider("[7]Width", 0.5, 0, 1.0, 0.01) : si.smoo;
flaLFO = os.lf_triangle(flaLFORate);
flaMod = flaLFOWidth * (flaLFO/2) ;
flanger = pf.flanger_mono(512, flaDelay * (1 + flaMod), flaDepth, flaFeedback, 1);
//=============================================
process =  _,_: + :> flanger <: _,_;
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on April 13, 2020, 04:47:05 PM
Wowww
Amazing!!!
I'm trying to wrap my head around the button.c code..

It is just for debounce ?
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 13, 2020, 05:18:00 PM
Here's the source of the button code:

https://github.com/craftmetrics/esp32-button

Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 13, 2020, 10:43:05 PM
Here's two flangers in series, identical except the sweep is in the opposite direction from each other.


import("stdfaust.lib");
flaDelay = hslider("[3]Delay", 156, 5, 1000, 1) : si.smoo;
flaFeedback = hslider("[4]Flange Fb", 0.8, 0, 0.97, 0.01) : si.smoo;
flaDepth = hslider("[5]Flange Dep", 0.95, 0, 1.0, 0.01) : si.smoo;
flaLFORate = hslider("[6]Rate", 0.25, 0, 3, 0.01) : si.smoo;
flaLFOWidth = hslider("[7]Width", 0.5, 0, 1.0, 0.01) : si.smoo;
flaLFO = os.lf_triangle(flaLFORate);
flaMod = flaLFOWidth * (flaLFO/2) ;
flanger(x) = pf.flanger_mono(512, flaDelay * (1 + (x * flaMod)), flaDepth, flaFeedback, 1);
flange = hgroup("Flange", flanger(1) : flanger(-1));
//=============================================
process =  _,_: + :> flange <: _,_;
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 14, 2020, 10:25:38 AM
I just found a configuration option (under "make menuconfig") that allows you to set the external SPI RAM to be usable by malloc().  At first glance this allows configuration of delays up to about 2.5 seconds using ef.echo(), whereas previously I could only get about 150 msec.  However, 3.5 seconds is too much.  This is OK.  The FV-1 only has 1 second in most cases unless you undersample.

Under:

Component config → ESP32-specific → SPI RAM config


Select:

(X) Make RAM allocatable using malloc() as well


One thing I like to do with delays is hang a different modulation or filter off each of several taps.  I was about to hang it up on this thing!

I was able to get a jcrev simple reverb block working.  Next I tried a mono_freeverb and wasn't quite as lucky.  Sound is distorted and I started getting watchdog timer errors, indicating most likely that there's too much processing being attempted.
Title: Re: ESP32-A1S audio dev board
Post by: audioartillery on April 14, 2020, 04:38:26 PM
Quote from: Digital Larry on April 06, 2020, 10:37:28 AMThere's a header on the board that brings out a few GPIOs but AFAIK none of these are the ones that go to the ADC.  So you'd probably be left using an external A2D->I2C chip and then bring that in, with accompanying low level programming, which is NOT where my head is at.

I had a similar problem on my Blackaddr-based build.  It had some ADC lines exposed but not enough, so I put down an i2c controlled mux.  Not really a big deal to sample all the pots and switches.

Might be just as easy to put down a small Arduino and rig up some i2c or SPI communication with that, then let it manage the UI.
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 14, 2020, 06:59:52 PM
Rumor has it that this board is susceptible to audio crosstalk from both wifi and I2C, which would be too bad.  Not sure why I'd want to add an Arduino, things are tough enough learning freeRTOS.  :icon_cool:  In any case, there are 2 cores and DSP and UI code can be isolated to one or the other.  I'm still having a good time messing around with it just the way it is.
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on April 15, 2020, 12:46:09 PM
i think using the LPU processor is a thing reserved for geniuses only.. but i know you are one :P
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 15, 2020, 01:01:18 PM
Quote from: dschwartz on April 15, 2020, 12:46:09 PM
i think using the LPU processor is a thing reserved for geniuses only.. but i know you are one :P
Yeah sure, of course I am.  What's an LPU?   ;D

Here's what I really am.  I studied DSP at university (that's the British way of saying "in college") many many (many) years ago.  I thought it was amazing but it was all theoretical and simulation.  We didn't have anything to run our guitars through.  Then I had an engineering career that didn't get into that too much (although it did just a little).  Now I'm on the far side of my career and things have progressed to the point where I can mess with all this stuff using easily available relatively cheap development platforms.  So I'm making up for lost time.

I can't read anything and get much out of it without getting my hands on... and that's what you see in this thread.  I am persistent and stubborn and like learning new things but also making stuff go wee weee weeee peyoowwww bing doot doot while I'm at it.

DL
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on April 15, 2020, 01:19:09 PM
Quote from: Digital Larry on April 15, 2020, 01:01:18 PM
Quote from: dschwartz on April 15, 2020, 12:46:09 PM
i think using the LPU processor is a thing reserved for geniuses only.. but i know you are one :P
Yeah sure, of course I am.  What's an LPU?   ;D

Here's what I really am.  I studied DSP at university (that's the British way of saying "in college") many many (many) years ago.  I thought it was amazing but it was all theoretical and simulation.  We didn't have anything to run our guitars through.  Then I had an engineering career that didn't get into that too much (although it did just a little).  Now I'm on the far side of my career and things have progressed to the point where I can mess with all this stuff using easily available relatively cheap development platforms.  So I'm making up for lost time.

I can't read anything and get much out of it without getting my hands on... and that's what you see in this thread.  I am persistent and stubborn and like learning new things but also making stuff go wee weee weeee peyoowwww bing doot doot while I'm at it.

DL

sounds like a genius to me....curious, stubborn and hands on..

i think the second processor is sometimes referred as LPU (low power unit)  or it was ULP?? idk...
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 18, 2020, 10:55:17 AM
I got some primordial OSC code from a student on the Faust Slack channel and am going to try incorporating this into my flanger/echo patch today.  I was able to get messages from TouchOSC over my WiFi LAN down to the ESP32 board.  Now I just need to hook them up to control sound parameters.  Well, I was looking for an excuse not to leave the house anyway right?  On a little Android 8" tablet that nobody was using any more I can get around 20 rotary controls and a few push buttons.  This is way easier than dealing with I2C and (gasp) "soldering" (shudders).   8)

While this is not the same as native OSC support in Faust, such as you have on a Bela or other more mainstream Faust targets, it's also more flexible as it passes through your own C++ code so you're not limited to having it only affect the sound algorithm.  At this point I don't know what else I'd be wanting it for, although something like saving presets might be possible.

DL
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 19, 2020, 01:37:30 PM
OK, I got buttons working, I got OSC working.  I've been using the ef.echo() function from Faust libraries but unfortunately, the output comes after the feedback control, which means that as the feedback goes down, so does your overall echo level.  I'd rather have an independent control of echo level and feedback.  So I have to build my own block out of something else.

I am trying the de.sdelay() which lets you change delay time without glitches or pitch bending.  I think it does this by using two different delay lines and fading between them when you change the delay time.  Some of its behavior is a little weird though, for example:

a) Delay = 50%, echoes are at 50%
b) Change delay to 75%, sound echoing from before is still repeating at 50%
c) Newly added sounds repeat at 75% (I think)
d) Change delay to 25%, now sounds from (a) and (c) are repeating at 25% (being chopped off)

That's what I THINK is happening anyway.  There are a number of different delay types to choose from, or if I get suitably desperate I could try to assemble my own from low levels.  I actually don't mind delays which pitch shift, but I think I'd need to slow down the control signal a bit more since at present it's a bit jumpy (just using si.smoo() - if you use si.smooth() then you can adjust the rise time explicitly).

Next up, initially I was configuring the OSC controls in touchOSC to send a message like "/flanger/flgDelay" and then, in the udp server block which handles OSC, look for that and then send a parameter adjustment message to the Faust code, using "flangeDelay".  However I realize it would make more sense to just look for "/flanger/" in the messages, trim off the end if there is a match, and send the rest to the Faust block rather than doing an intermediate lookup to change the variable name.

DL
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on April 19, 2020, 03:33:47 PM
Are you accessing the external ram for the delays?
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 19, 2020, 06:43:57 PM
Quote from: dschwartz on April 19, 2020, 03:33:47 PM
Are you accessing the external ram for the delays?
Yes, I can get about 2.5 seconds of delay.
Title: Re: ESP32-A1S audio dev board
Post by: Ben N on April 20, 2020, 03:21:28 AM
Quote from: Digital Larry on April 15, 2020, 01:01:18 PM
I can't read anything ...

Ah, a guitar player.  ;D
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 21, 2020, 11:42:22 AM
Once again I'm exploring the edges of what will run on this chip.

At the moment I have a nice flanger with adjustments on:
- initial delay time
- lfo rate
- lfo width
- depth (wet mix)
- feedback

This is fed by a delay line with adjustments on:
- delay time
- feedback level

As Faust's built-in "ef.echo()" function does not have a level control, only delay time and feedback controls, I had to build my own out of de.sdelay() and the dreaded "recursion" operator.  I finally figured out how to put the delay into the feedback loop.  Then I went to add a 4 pole low pass filter and started getting watchdog timer errors.  This means "you're trying to execute too much code".  I whittled that down to a 2 pole filter and it worked again.  Then I went to add a level control and it stopped working.

There are some benchmarking tools for Faust generated code but I'll be danged if I have any clue as to how to use them.

Since I've done a lot of work with the Spin FV-1 I'll just note some apparent advantages of each platform, please note, "it's just my opinion, man..."

Advantages of Spin FV-1
- seems like it can do more processing before running out of CPU cycles, e.g. reverbs, complex modulations, multiple filters
- easier to incorporate into your own designs due to SOIC package and integrated A/D/A circuitry.
- probably a shorter learning curve, hard to be objective about it though.  Everything you learn about the FV-1 has to do with the FV-1's audio algorithms, while some things you have to learn about the ESP32 have to do with setting up the development environment, learning how freeRTOS works, etc.
- has awesome graphical tool SpinCAD Designer to help you come up with algorithms
- highly optimized instruction set for DSP
- very obvious when you've run out of code execution space - it won't assemble
- better S/N (at least compared to the AI Thinker board)
- can store programs in a cheap EEPROM and switch between them easily.

Advantages of ESP32-A1S board
- up to 2.5 seconds of delay time if you enable malloc() to work with SPIRAM
- can connect to your LAN via Wi-Fi so you can use OSC to go past 3-control limitation of FV-1
- cheaper than FV-1
- works with awesome but possibly incomprehensible "Faust" language for developing portable algorithms
- more flexible control I/O arrangement... but you either have to find analog input pins to connect pots or use I2C to get those in and pass parameter changes to the DSP code.

===============
I also have the LyraT board which supposedly has better S/N as the codec chip is not on the ESP32 module and they seem to have done a better job of providing it with an isolated power supply, etc.

I think that the ESP32 based boards are likely suitable for single-effect types of applications with a lot of controls.  I was quite often frustrated by the 3-pot limitation on the FV-1 as I could easily come up with complex algorithms that could have used more.  Even if ultimately I decide that I don't need all these controls, or might combine 2 into 1, it's really hard to know unless you have more flexibility at the initial stages.

DL
Title: Re: ESP32-A1S audio dev board
Post by: hgamal on April 21, 2020, 09:32:59 PM
Hi Larry,

Quote from: Digital Larry on April 13, 2020, 04:40:39 PM
All right, here's my code for a basic mono flanger which uses the 6 pushbuttons of the AI-Thinker ESP32-A1s audio/wifi/bluetooth dev board to adjust LFO width, speed, and flanger center delay.
...

I've tried to run your code and I've got: "***ERROR*** A stack overflow in task Faust DSP Task has been detected."

Any suggestion?

complete log follows:


I (75) boot: Chip Revision: 1
I (75) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (43) boot: ESP-IDF v3.3.1 2nd stage bootloader
I (43) boot: compile time 21:54:41
I (52) boot: Enabling RNG early entropy source...
I (52) boot: SPI Speed      : 40MHz
I (52) boot: SPI Mode       : DIO
I (55) boot: SPI Flash Size : 4MB
I (60) boot: Partition Table:
I (63) boot: ## Label            Usage          Type ST Offset   Length
I (70) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (85) boot:  2 factory          factory app      00 00 00010000 00100000
I (93) boot: End of partition table
I (97) boot_comm: chip revision: 1, min. application chip revision: 0
I (104) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x156a8 ( 87720) map
I (144) esp_image: segment 1: paddr=0x000256d0 vaddr=0x3ffb0000 size=0x01f78 (  8056) load
I (147) esp_image: segment 2: paddr=0x00027650 vaddr=0x40080000 size=0x00400 (  1024) load
0x40080000: _WindowOverflow4 at /home/hgamal/esp/esp-idf/components/freertos/xtensa_vectors.S:1779

I (151) esp_image: segment 3: paddr=0x00027a58 vaddr=0x40080400 size=0x085b8 ( 34232) load
I (174) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x23138 (143672) map
0x400d0018: _flash_cache_start at ??:?

I (225) esp_image: segment 5: paddr=0x00053158 vaddr=0x400889b8 size=0x060e8 ( 24808) load
0x400889b8: rtc_init at /home/hgamal/esp/esp-idf/components/soc/esp32/rtc_init.c:78

I (244) boot: Loaded app from partition at offset 0x10000
I (244) boot: Disabling RNG early entropy source...
I (244) psram: This chip is ESP32-D0WD
I (250) spiram: Found 64MBit SPI RAM device
I (253) spiram: SPI RAM mode: flash 40m sram 40m
I (259) spiram: PSRAM initialized, cache is in low/high (2-core) mode.
I (266) cpu_start: Pro cpu up.
I (270) cpu_start: Application information:
I (274) cpu_start: Project name:     hello-world
I (280) cpu_start: App version:      1
I (284) cpu_start: Compile time:     Apr 21 2020 21:54:44
I (290) cpu_start: ELF file SHA256:  23fecd3f8d509e36...
I (296) cpu_start: ESP-IDF:          v3.3.1
I (301) cpu_start: Starting app cpu, entry point is 0x40081264
0x40081264: call_start_cpu1 at /home/hgamal/esp/esp-idf/components/esp32/cpu_start.c:269

I (0) cpu_start: App cpu up.
I (1192) spiram: SPI SRAM memory test OK
I (1192) heap_init: Initializing. RAM available for dynamic allocation:
I (1193) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (1199) heap_init: At 3FFB3070 len 0002CF90 (179 KiB): DRAM
I (1205) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (1211) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (1218) heap_init: At 4008EAA0 len 00011560 (69 KiB): IRAM
I (1224) cpu_start: Pro cpu start user code
I (1229) spiram: Adding pool of 4096K of external SPI memory to heap allocator
I (244) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (245) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (1255) AC101: reset succeed
I (1375) AC101: init done
I (1375) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1375) BUTTON: configuring GPIOs
I (1375) gpio: GPIO[5]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:1073433824
E (1385) gpio: gpio_set_intr_type(102): GPIO interrupt type error
I (1395) gpio: GPIO[13]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:1073433824
E (1405) gpio: gpio_set_intr_type(102): GPIO interrupt type error
I (1415) gpio: GPIO[18]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:1073433824
E (1425) gpio: gpio_set_intr_type(102): GPIO interrupt type error
I (1425) gpio: GPIO[19]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:1073433824
E (1435) gpio: gpio_set_intr_type(102): GPIO interrupt type error
I (1445) gpio: GPIO[23]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:1073433824
E (1455) gpio: gpio_set_intr_type(102): GPIO interrupt type error
I (1465) gpio: GPIO[36]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:1073433824
E (1475) gpio: gpio_set_intr_type(102): GPIO interrupt type error
I (1475) BUTTON: Pin count: 6
I (1485) BUTTON: Registering button input: 5
I (1485) BUTTON: Registering button input: 13
I (1495) BUTTON: Registering button input: 18
I (1495) BUTTON: Registering button input: 19
I (1505) BUTTON: Registering button input: 23
I (1505) BUTTON: Registering button input: 36
I (1515) I2S: DMA Malloc info, datalen=blocksize=1024, dma_buf_count=3
I (1515) I2S: DMA Malloc info, datalen=blocksize=1024, dma_buf_count=3
I (1525) I2S: PLL_D2: Req RATE: 32000, real rate: 32894.000, BITS: 32, CLKM: 19, BCK: 4, MCLK: 8192000.000, SCLK: 2105216.000000, diva: 64, divb: 34
***ERROR*** A stack overflow in task Faust DSP Task has been detected.
abort() was called at PC 0x400880f4 on core 1
0x400880f4: vApplicationStackOverflowHook at /home/hgamal/esp/esp-idf/components/esp32/panic.c:715
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 22, 2020, 04:38:08 AM
Hi Haroldo,

Here is my boot trace, let's see if there are some obvious differences.

a) I'm using ESP-IDF 4.0, you've got 3.3-something
b) you're calling rtc_init, I may have disabled rtc in my sdkconfig.
c) you seem to be getting GPIO interrupt type errors - don't know why
d) (make menuconfig): Component config → ESP32-specific : I have set CPU clock to 240 MHz, which was not the default

That's all I can see at the moment, please check as there may be something else.


I (69) boot: Chip Revision: 1
I (70) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot: ESP-IDF v4.0-dirty 2nd stage bootloader
I (39) boot: compile time 01:21:45
I (47) boot: Enabling RNG early entropy source...
I (48) boot: SPI Speed      : 40MHz
I (48) boot: SPI Mode       : DIO
I (52) boot: SPI Flash Size : 4MB
I (56) boot: Partition Table:
I (59) boot: ## Label            Usage          Type ST Offset   Length
I (67) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (74) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (81) boot:  2 factory          factory app      00 00 00010000 00100000
I (89) boot: End of partition table
I (93) boot_comm: chip revision: 1, min. application chip revision: 0
I (100) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x0d908 ( 55560) map
I (132) esp_image: segment 1: paddr=0x0001d930 vaddr=0x3ffb0000 size=0x02040 (  8256) load
I (136) esp_image: segment 2: paddr=0x0001f978 vaddr=0x40080000 size=0x00400 (  1024) load
0x40080000: _WindowOverflow4 at /home/gary/ESP32-A1S/esp-idf/components/freertos/xtensa_vectors.S:1778

I (139) esp_image: segment 3: paddr=0x0001fd80 vaddr=0x40080400 size=0x00290 (   656) load
I (148) esp_image: segment 4: paddr=0x00020018 vaddr=0x400d0018 size=0x1fbe0 (130016) map
0x400d0018: _stext at ??:?

I (210) esp_image: segment 5: paddr=0x0003fc00 vaddr=0x40080690 size=0x0d570 ( 54640) load
I (244) boot: Loaded app from partition at offset 0x10000
I (244) boot: Disabling RNG early entropy source...
I (245) psram: This chip is ESP32-D0WD
I (249) spiram: Found 64MBit SPI RAM device
I (254) spiram: SPI RAM mode: flash 40m sram 40m
I (259) spiram: PSRAM initialized, cache is in low/high (2-core) mode.
I (266) cpu_start: Pro cpu up.
I (270) cpu_start: Application information:
I (275) cpu_start: Project name:     basicFlanger
I (280) cpu_start: App version:      v4.0-dirty
I (285) cpu_start: Compile time:     Apr 22 2020 01:21:57
I (292) cpu_start: ELF file SHA256:  b74d35872ec7cb77...
I (298) cpu_start: ESP-IDF:          v4.0-dirty
I (303) cpu_start: Starting app cpu, entry point is 0x40081374
0x40081374: call_start_cpu1 at /home/gary/ESP32-A1S/esp-idf/components/esp32/cpu_start.c:272

I (0) cpu_start: App cpu up.
I (1190) spiram: SPI SRAM memory test OK
I (1191) heap_init: Initializing. RAM available for dynamic allocation:
I (1191) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (1197) heap_init: At 3FFB5050 len 0002AFB0 (171 KiB): DRAM
I (1204) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (1210) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (1217) heap_init: At 4008DC00 len 00012400 (73 KiB): IRAM
I (1223) cpu_start: Pro cpu start user code
I (1228) spiram: Adding pool of 4096K of external SPI memory to heap allocator
I (1249) spi_flash: detected chip: generic
I (1249) spi_flash: flash io: dio
I (1259) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (1259) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (2269) AC101: reset succeed
I (2389) AC101: init done
I (2389) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (2389) BUTTON: configuring GPIOs
I (2389) gpio: GPIO[5]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:5
I (2399) gpio: GPIO[13]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:5
I (2409) gpio: GPIO[18]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:5
I (2419) gpio: GPIO[19]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:5
I (2429) gpio: GPIO[23]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:5
I (2439) gpio: GPIO[36]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:5
I (2449) BUTTON: Pin count: 6
I (2449) BUTTON: Registering button input: 5
I (2459) BUTTON: Registering button input: 13
I (2459) BUTTON: Registering button input: 18
I (2469) BUTTON: Registering button input: 19
I (2469) BUTTON: Registering button input: 23
I (2479) BUTTON: Registering button input: 36
I (2479) I2S: DMA Malloc info, datalen=blocksize=1024, dma_buf_count=3
I (2489) I2S: DMA Malloc info, datalen=blocksize=1024, dma_buf_count=3
I (2499) I2S: APLL: Req RATE: 32000, real rate: 32000.006, BITS: 32, CLKM: 1, BCK_M: 8, MCLK: 16384003.000, SCLK: 2048000.375000, diva: 1, divb: 0
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 22, 2020, 05:17:18 PM
I'm nearing the end of the road on the ESP32.  It's a fun little board but I think it doesn't have enough CPU cycles to do what I want.  It's great that I could get OSC working, but given the simplicity of the patches supported, it's not a great differentiator.  I may still keep these 2 boards I have and put them by my Eurorack stuff, just to have a flanger or a delay which is always there.  I already have a few Eurorack modules with FV-1s in them.

I'm also committed to doing things in Faust for the time being, and it's hard to tell whether this is part of the problem or not.  Their materials say "could be as good or better than hand written DSP code" but that's a fairly vague argument.

I'll probably push what I was able to accomplish on the ESP32 up to Github before too long, but I don't think I'm going to continue very far down this path.  Doesn't mean you couldn't get a nice flanger or simple echo working for not much money.

Next up, I just ordered the "Elk OS Development Bundle" for $299 which leverages a Raspberry Pi running a Xenomai RT Time kernel thing.  This seems similar to the Bela, based on a Beaglebone Black, and the upcoming Mod Dwarf.  Elk supports OSC, but I don't think the Mod Dwarf does.  I'd been using Ubuntu Studio on an old Macbook, and that is just too glitchy and hard to get latency down.  We'll see how far I get with Elk.  It's a lot more details to deal with but after all I just need stuff to keep my mind occupied.

DL
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 25, 2020, 12:18:05 AM
Here's my first github checkin of Faust and C/C++ code to make a flanger on the ESP32-A1S.

In this version of the code, I have two flangers, one on either side of a fixed delay (you can set this up to about 2.5 seconds) with a little feedback. They are sweeping in opposite directions and have opposite phase shift. Take blocks out to experiment with the sound. Also there is a Faust "12AX7" block in there!  One optional line has a reverb added in.

https://github.com/HolyCityAudio/ESP32

Drill down into the faust folder to find important instructions as to how to use this.

Have fun!  Learn Faust!    https://faust.grame.fr/

DL

Title: Re: ESP32-A1S audio dev board
Post by: Rauch on April 25, 2020, 02:22:34 PM
Hi can I implement a IR loader cab sim pedal with ESP32 or with this blackstomp ? Thanks

Rauch
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 25, 2020, 03:14:30 PM
Quote from: Rauch on April 25, 2020, 02:22:34 PM
Hi can I implement a IR loader cab sim pedal with ESP32 or with this blackstomp ? Thanks

Rauch
I'd say the chances of that are pretty good - at least at some level.  I just can't tell you exactly how to go about it.
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 25, 2020, 04:04:11 PM
I've added code for the "echoFlanger" which is a bit like an oil can delay.  It would be more like an oil can delay if the flanger bit was inside the feedback loop of the echo.  That is left as an exercise for the reader!!!! (hint: you can't do it with ef.echo() as the feedback is self contained).

https://github.com/HolyCityAudio/ESP32/tree/master/faust

DL

Check out the Faust libraries:  https://faust.grame.fr/tools/editor/libraries/doc/library.pdf
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on April 28, 2020, 10:26:18 AM
Here's a "basic echo" which includes an adjustable low pass in the feedback loop.  For this one I decided to use the sdelay() function, which does not pitch bend when you change the delay time.  Call me old fashioned, but I actually like delay time changes with pitch bend.  Fortunately there's another delay type you could try.

This is just a few lines of Faust code, most of which describes the parameter controls.


import("stdfaust.lib");
echoTime = hslider("[7]echoTime", 0.10, 0.10, 2.5, 0.01) : si.smooth(0.99995);
echoFeedback = hslider("[7]echoFeedback", 0.0, 0, 1.0, 0.01) : si.smoo;
echoLPF = hslider("[7]echoLPF", 2500.0, 1000.0, 10000.0, 0.01) : si.smoo;
//=============================================
process = _,_ : + <: _,(( + : de.sdelay(ba.sec2samp(2.5), 1024, ba.sec2samp(echoTime)) : fi.lowpass(2,echoLPF)) ~* (echoFeedback)) * 0.5 :> _ <: _,_;


The Faust delay library can be found here:

https://github.com/grame-cncm/faustlibraries/blob/master/delays.lib

Here I've supplied a link right to the Github code.  The state of documentation and tools in Faust world is "all over the place" as it is an academic rather than a commercial project.  Sometimes you have to dig into the libraries as there is no suitable documentation elsewhere.

As with the first two patches I put up, this uses the 6 available pushbuttons on the ESP32-A1S audio dev board to do up/down adjustments on 3 parameters, which I find is barely acceptable for a lot of things.  For example on this one, I have

- delay time (100 msec - 2.5 seconds)
- delay feedback (which can go over 1, look out!)
- low pass frequency

So there's no delay mix control.  I also have this set up over by my Eurorack stuff, where hands on real time parameter control is way more of a consideration than it is with guitar pedals, for the most part.  I may wind up attaching a couple of these boards to the side of my 19" rack tower, next to my FV-1 dev board, just to have another "thing" to run sounds through, that only does one thing.

https://github.com/HolyCityAudio/ESP32/tree/master/faust/basicEcho

I think next up I'm going to expand this delay to include a high pass in the loop and maybe an adjustable overdrive but the big deal will be the introduction of Wi-Fi connectivity and OSC, so you can bust out of the limitations of only having 3 parameters to adjust with little push buttons.

Anybody trying these?  Any questions or problems?  I realize it takes a bit of perseverance to get everything set up, and maybe Faust is not your cup of tea, but this stuff makes me relatively giddy with power (within the limits of the ESP32 itself).

DL
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on May 07, 2020, 09:58:16 AM
Here's a delay combined with two flangers (one in the feedback loop), controllable by the ESP32-A1S audio dev board's buttons (3 parameters up/down) as well as OSC over WiFi (7 parameters - the phase buttons aren't hooked up yet).  See the readme file for important details about how to build this as it's more complicated than the earlier examples I posted.

https://github.com/HolyCityAudio/ESP32/tree/master/faust/flangerOSC

https://github.com/HolyCityAudio/ESP32/blob/master/faust/flangerOSC/flanger-osc.JPG

What's interesting is that I can't add even a single pole lowpass, fi.lowpass to the patch without getting watchdog timer errors, but I could add another flanger and triangle LFO.  So, it's a trial and error process to see how much you can jam into a single patch.
Title: Re: ESP32-A1S audio dev board
Post by: dschwartz on May 07, 2020, 01:26:07 PM
i read somewhere that the FPU on the esp32 is deactivated by default, and when called in, it takes some time to initialize, causing issues. The solution was to initialize the FPU engine on startup (somehow, i don't know)..

maybe that's causing the watchdog errors..

Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on May 07, 2020, 02:14:34 PM
I can't say that that's not the cause, but I know that adding "too much" code will certainly cause watchdog timer errors.  I'll look into it.  Thanks.

DL
Title: Re: ESP32-A1S audio dev board
Post by: pruttelherrie on May 24, 2020, 10:20:38 AM
Quote from: Digital Larry (in another topic!) on May 07, 2020, 02:14:34 PM
I think a graphical tool is the way to go most of the time, but that's just me.
I second that. I really like tinkering with algorithms in SpinCAD. Writing bare metal code, not so much.

Now on to the issues I'm encountering: so I soldered a blackstomp board and started with the bare Arduino-style pass-through program. (I'm using VSCode+PlatformIO on Linux, by the way). All well. Next up was a simple delay, fixed parameters mix and feedback. Still all well, works and sounds ok, like a digital delay. Then I tried to get some filtering going, borrowing code from Rakarrack, and got stranded pretty fast. And I got fed up with the bare metal coding pretty fast as well.

So I started to look into this codebase: https://github.com/macaba/ESP32Audio/
It's a fork of the Teensy Audio Library, modified for the ESP32. I figured, if I get that up and running, I can add some blocks which aren't ported yet myself (not nice) and use these blocks in the GUI (nice).
Two things had to be done first: (1) add AC101 support (2) recode Arduino-style since Macaba's code is for ESP-IDF.
I think I got somewhere, I got stuff compiled and uploaded, BUT:

* No output. I think I'm doing something wrong with the codec initialisation or so.
* I am unable to pin the audiotask to Core1. xTaskCreate() works (as in: code *after* the call gets executed, so the task gets created) but xTaskCreatePinnedToCore() does not work. I do not understand why.
* I'm getting watchdog timeouts when the audio task is as follows:

void audioTask( void * parameter ) {
  AudioStream *p; 
  for(;;) {
    p->update_all();   
    esp_task_wdt_reset();
  }
}


However, if I add Serial.print("."); to the task, I do not get watchdog errors. I added the esp_task_wdt_reset(); myself, this was not in Macaba's code. Again, I do not understand what's going on.

But it brings me to the following:

Quote from: Digital Larry on May 07, 2020, 02:14:34 PMI know that adding "too much" code will certainly cause watchdog timer errors.  I'll look into it.  Thanks.
Could this have something to do with where in the Faust-generated code the WDT is reset?

Anybody any idea where to go from here?
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on May 24, 2020, 11:22:43 AM
Obviously we are using two different development environments, but I'll offer what I can.

a) In addition to initializing the AC101, you have to turn up the "headphone volume" mixer channel.  See:

https://github.com/HolyCityAudio/ESP32/blob/master/faust/basicEcho/main/main.cpp


    AC101.SetVolumeHeadphone(63);


b) Weird that using the "PinnedToCore" option doesn't work !  No idea there.  The Faust generated C++ code does a lot of things on its own without needing to be specified, although the way I set up my own environment, I do allow and in some cases need to edit the generated C++ code before building the whole project.

Generally speaking, if I was getting watchdog errors, I'd still be getting processed sound, but it would sound like it was going through a shredder, and not in a good way (if there is one).

c) Check the AC101 code generated by Faust here: https://github.com/HolyCityAudio/ESP32/blob/master/faust/basicEcho/main/AC101.cpp

d) You might want to scan through the generated DSP C++ code here.  There are no explicit calls about the WDT at all in this, but look for "task", might be interesting.  https://github.com/HolyCityAudio/ESP32/blob/master/faust/basicEcho/main/basicEcho.cpp

Yes, I suppose it needs to be said that in addition to the DSP which is your main concern, there's no getting around having to learn some of the details of freeRTOS as well.
Title: Re: ESP32-A1S audio dev board
Post by: pruttelherrie on May 24, 2020, 02:07:26 PM
Right, thanks for the pointers. I'll have a look in the generated code.

Quote from: Digital Larry on May 24, 2020, 11:22:43 AMin addition to the DSP which is your main concern, there's no getting around having to learn some of the details of freeRTOS as well.

True, but once we get this sorted out everybody can enjoy the GUI to create algorithms.
Title: Re: ESP32-A1S audio dev board
Post by: pruttelherrie on May 25, 2020, 04:19:00 PM
Update: I'm getting there. Some really useful info about the WDT from the famous sprite_tm (who used to live just a few kilometers from me) here: https://esp32.com/viewtopic.php?f=2&t=809&p=10191&hilit=esp_task_wdt_feed#p10191

I rewrote the AC101.cpp to match the existing structure of the Teensy Audio Lib, then I had to do some debugging on the initialisation, including the setHeadphonesVolume() ;)

After that it turned out the i2s_input and i2s_output routines were not completely compatible with the AC101 (incoming int buffer -> float workingbuffer and the other way around) but after fixing that I do have output in the pass-through example!
Problem is that there's a whine and a lot of distortion on a clean signal, so I'm still doing something wrong with the input and output conversions. It turns out Teensy Audio Library works with  signals from -1 ... +1, didn't know that. [edit] I should rephrase that: the esp32-audio-lib works with signals from -1...+1.

Will keep you posted.
Title: Re: ESP32-A1S audio dev board
Post by: pruttelherrie on May 26, 2020, 04:50:42 PM
Ok, got it working. The pass-through example at least. Took a lot of fiddling with the AC101 register setup to get rid of the whine/distortion and then some programming back and forth to use the AudioStream structures but now I cleaned it up and it still works.

Next I got to figure out this GitHub thing so I can share it.
Title: Re: ESP32-A1S audio dev board
Post by: potul on May 27, 2020, 02:33:48 AM
This is really good news..... I have my board sitting on the table next to my other projects waiting for someting interesting to come... This is promising. Keep us posted
Title: Re: ESP32-A1S audio dev board
Post by: Pentatonic on May 27, 2020, 09:55:25 AM
Good day everyone.

I tried the repo above.  It looks like line-in does not working
Is the sample above working on your board? Btw I am using A1S board.

Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on May 27, 2020, 10:57:16 AM
Quote from: Pentatonic on May 27, 2020, 09:55:25 AM
Good day everyone.

I tried the repo above.  It looks like line-in does not working
Is the sample above working on your board? Btw I am using A1S board.
Please indicate which repo you are talking about?  In all cases, I tested with line in and headphone out. 

That includes everything at: https://github.com/HolyCityAudio/ESP32
(so far, anyway).

I am using the rev 2 of this board:
https://www.electronics-lab.com/esp32-a1s-wi-fibt-audio-development-kit/

I think it is the rev 2 anyway.  It has 8 buttons along the lower edge instead of the 6 shown.
Title: Re: ESP32-A1S audio dev board
Post by: Pentatonic on May 27, 2020, 12:59:12 PM
Thanks for quick response.  :icon_wink: I tried to compile and flash basicEcho example from your repo. But it seems line-in does not work. But when I generate simple white noise from faust and modify mydsp class to check if output is working. Not sure why line-in not working. :icon_neutral:
Title: Re: ESP32-A1S audio dev board
Post by: pruttelherrie on May 27, 2020, 01:06:33 PM
Quote from: potul on May 27, 2020, 02:33:48 AM
This is really good news..... I have my board sitting on the table next to my other projects waiting for someting interesting to come... This is promising. Keep us posted
I got a delay working, with hardcoded delay time, mix level and feedback level, just using the GUI.  Copy/paste the GUI-export and set the time, mix and feedback in the code. The effect_delay block uses the external memory of the ESP32-A1S for all audio memory.

GUI:
(https://i.postimg.cc/wRcwYQgN/Screenshot-at-2020-05-27-18-49-21.png) (https://postimg.cc/wRcwYQgN)

Exported code, to be copied to main.cpp before setup():

// GUItool: begin automatically generated code
AudioInputI2S            i2s1;           //xy=131,258
AudioMixer4              mixer2;         //xy=311,165
AudioEffectDelay         delay1;         //xy=397,377
AudioAmplifier           amp2;           //xy=481,33
AudioAmplifier           amp1;           //xy=568,408
AudioMixer4              mixer1;         //xy=633,254
AudioOutputI2S           i2s2;           //xy=1026,368
AudioConnection          patchCord1(i2s1, 1, mixer1, 0);
AudioConnection          patchCord2(i2s1, 1, mixer2, 1);
AudioConnection          patchCord3(mixer2, delay1);
AudioConnection          patchCord4(delay1, 7, amp1, 0);
AudioConnection          patchCord5(amp2, 0, mixer2, 0);
AudioConnection          patchCord6(amp1, 0, mixer1, 1);
AudioConnection          patchCord7(mixer1, 0, i2s2, 1);
AudioConnection          patchCord8(mixer1, amp2);
// GUItool: end automatically generated code


And then in setup() call something like this:

    AudioMemory(400);
    delay1.delay(7,667);
    amp1.gain(0.5);
    amp2.gain(0.5);


From here on next steps are:
* Implement more blocks (only a subset of blocks is implemented at the moment)
* Add code for interaction, like pots, OSC, web...

As I said before, I use:
* VSCode
* PlatformIO
* Arduino framework (within PlatformIO)

If you're using the same (or willing to use), drop me a PM and I'll share what I have so far.
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on May 27, 2020, 02:47:22 PM
Makes me remember the first time I made a patch with SpinCAD and it actually worked.  I had 3 or 4 simultaneous involuntary bodily functions!  It was then that I realized that world domination was within my grasp.  Good thing I just wanted to make sound effects!  Good work man!   8) :icon_biggrin: :icon_idea: :icon_mrgreen: :icon_surprised:
Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on May 27, 2020, 02:58:23 PM
Quote from: Pentatonic on May 27, 2020, 12:59:12 PM
Thanks for quick response.  :icon_wink: I tried to compile and flash basicEcho example from your repo. But it seems line-in does not work. But when I generate simple white noise from faust and modify mydsp class to check if output is working. Not sure why line-in not working. :icon_neutral:
Well, one step at a time.  I started with the sawtooth oscillator examples.  Also, the patches are supposed to be stereo > mono input and mono < stereo output.  I am using mono eurorack patch cables for I/O and the tip conductor does not map to the default mono input.  Is your board the rev 1 or rev 2?
Title: Re: ESP32-A1S audio dev board
Post by: pruttelherrie on May 27, 2020, 04:07:05 PM
Quote from: Digital Larry on May 27, 2020, 02:47:22 PM
I had 3 or 4 simultaneous involuntary bodily functions!

That's EXACTLY what happened!  :icon_biggrin:
Title: Re: ESP32-A1S audio dev board
Post by: Pentatonic on May 28, 2020, 10:54:24 AM
Good day.

This is my board. Any idea why line-in does not work?
(https://i.postimg.cc/yJXLfGf7/DE55-FE26-2-E9-E-409-D-BC1-B-D12-E6-D08240-F.jpg) (https://postimg.cc/yJXLfGf7)


Title: Re: ESP32-A1S audio dev board
Post by: Digital Larry on May 28, 2020, 02:02:12 PM
Quote from: Pentatonic on May 28, 2020, 10:54:24 AM
Good day.

This is my board. Any idea why line-in does not work?
(https://i.postimg.cc/yJXLfGf7/DE55-FE26-2-E9-E-409-D-BC1-B-D12-E6-D08240-F.jpg) (https://postimg.cc/yJXLfGf7)
No idea, that is exactly my board.

I've uploaded the ELF files to my Github repo for each project (under the build folder), so if you like, you can upload exactly the code I have here, eliminating any possible variation in compiling/development environment.

https://github.com/HolyCityAudio/ESP32/tree/master/faust
Title: Re: ESP32-A1S audio dev board
Post by: pruttelherrie on June 09, 2020, 03:40:28 PM
Hey guys, a short update.
I pushed my stuff on github: https://github.com/pruttelherrie/ESP32-A1S-Teensy-Audio

Two examples included, a delay in SPIMEM with a lowpass on the delayline and changing parameters over OSC!

Using the Teensy Audio lib is a bit of a mixed business: blocks are connected in the GUI, but for control and parameter-setting you still need to code. There's a wavegenerator that can also do LFO's but most blocks don't accept the output (yet ;)

Title: Re: ESP32-A1S audio dev board
Post by: pruttelherrie on July 06, 2020, 04:10:18 AM
Just another note: during dicking around I found that receiving OSC messages over WiFi made noticeable 'chirping' sounds in the output. One might want to implement PLAY and EDIT modes or something like that, and disable WiFi in PLAY mode. Seems smart anyway, unless you want some joker in the audience to have the night of his life :)